Compare commits

...

3 Commits

Author SHA1 Message Date
Harsh Shandilya 2dcee60a26 feat: replace xtask with a Nix-native app 2024-01-28 20:03:43 +05:30
Harsh Shandilya 1aac97d906 treewide: fmt 2024-01-28 20:00:18 +05:30
Harsh Shandilya d8672c5940 pkgs: add gphotos-cdp 2024-01-28 20:00:14 +05:30
8 changed files with 64 additions and 51 deletions

View File

@ -13,6 +13,7 @@ NixOS packages for personal use.
- [file-collector] : Simple CLI tool to watch directories and move their files to a single dumping ground
- [gdrive] : Golang CLI to interact with Google Drive
- [gitice] : Simple Rust CLI that snapshots the state of Git repositories to allow re-cloning in a separate location
- [gphotos-cdp] : Use the Chrome DevTools Protocol to drive a Chrome session that downloads your photos stored in Google Photos.
- [hcctl]: CLI to look up the status of checks on https://healthchecks.io
- [healthchecks-monitor]: CLI tool to run commands and report its result to https://healthchecks.io
- [hyperlink]: Very fast link checker for CI
@ -36,6 +37,7 @@ NixOS packages for personal use.
[file-collector]: https://msfjarvis.dev/g/file-collector
[gdrive]: https://msfjarvis.dev/g/gdrive
[gitice]: https://msfjarvis.dev/g/gitice
[gphotos-cdp]: https://msfjarvis.dev/g/gphotos-cdp
[hcctl]: https://msfjarvis.dev/g/healthchecks-rs
[healthchecks-monitor]: https://msfjarvis.dev/g/healthchecks-rs
[hyperlink]: https://github.com/untitaker/hyperlink

View File

@ -56,7 +56,7 @@ let
with (fromJSON (readFile ./flake.lock)).nodes.${name}.locked; {
inherit rev;
outPath = fetchurl {
url = url;
inherit url;
sha256 = narHash;
};
};

View File

@ -32,9 +32,33 @@
};
in {
packages = eachSystem (system: packagesFn pkgs.${system});
overlays.default = final: prev: packagesFn prev;
overlays.default = packagesFn;
githubActions = nix-github-actions.lib.mkGithubMatrix {
checks = nixpkgs.lib.getAttrs [ "x86_64-linux" ] self.packages;
checks = nixpkgs.lib.getAttrs ["x86_64-linux"] self.packages;
};
apps = eachSystem (system: {
format = {
type = "app";
program = let
pkgs' = pkgs.${system};
script = pkgs'.writeShellApplication {
name = "format";
runtimeInputs = with pkgs'; [
alejandra
deadnix
shfmt
statix
];
text = ''
set -euo pipefail
shfmt --write --simplify --language-dialect bash --indent 2 --case-indent --space-redirects .
deadnix --edit
statix check .
alejandra --quiet .
'';
};
in "${script}/bin/format";
};
});
};
}

View File

@ -17,6 +17,7 @@ in {
inherit (fenix) fromManifestFile;
inherit rust-manifest;
};
gphotos-cdp = callPackage ./gphotos-cdp {};
hcctl = callPackage ./hcctl {};
healthchecks-monitor = callPackage ./healthchecks-monitor {};
hyperlink = callPackage ./hyperlink {};

View File

@ -0,0 +1,28 @@
{
lib,
buildGoModule,
fetchFromGitHub,
}:
buildGoModule {
pname = "gphotos-cdp";
version = "unstable-2024-01-28";
src = fetchFromGitHub {
owner = "msfjarvis";
repo = "gphotos-cdp";
rev = "4262092a2fe585f4b66bd50bd4c235e8f24824f6";
hash = "sha256-xLCldbD37JEDQTwFSUqiEOM09vH+KaB/I8O3WoNqR6A=";
};
vendorHash = "sha256-FzGDVMKzAjISb4P7/vBIBTbBWpyAUnR26gXcvUWnjHw=";
ldflags = ["-s" "-w"];
meta = with lib; {
description = "This program uses the Chrome DevTools Protocol to drive a Chrome session that downloads your photos stored in Google Photos";
homepage = "https://github.com/msfjarvis/gphotos-cdp";
license = licenses.asl20;
maintainers = with maintainers; [];
mainProgram = "gphotos-cdp";
};
}

View File

@ -24,8 +24,7 @@ in
hash = "sha256-lxKMmSySY5EbnK7GccoFBcQGaqkuir95nVOJkd4L08s=";
};
buildInputs =
lib.optionals stdenv.isDarwin [
buildInputs = lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.Security
darwin.apple_sdk.frameworks.SystemConfiguration
];

5
statix.toml Normal file
View File

@ -0,0 +1,5 @@
disabled = [
"repeated_keys"
]
nix_version = '2.4'
ignore = ['.direnv']

46
xtask
View File

@ -1,46 +0,0 @@
#!/usr/bin/env bash
set -e
set -u
set -o pipefail
case "${1:-nothing}" in
build)
nix flake show --json | jq -r '.packages."x86_64-linux"|keys[]' | xargs -I {} nix build .#{}
;;
clean)
fd -Itl -X rm -rfv
;;
hash)
shift
declare -a FIELDS=()
FULL_SLUG="${1}"
REV="${2}"
IFS='/' read -r -a FIELDS <<<"${FULL_SLUG:?}"
if [[ ${#FIELDS[@]} -eq 2 ]]; then
CHECKSUM="$(nix-prefetch-url --type sha256 --unpack "https://github.com/${FULL_SLUG}/archive/${REV:?}.tar.gz" 2>/dev/null)"
nix hash to-sri --type sha256 "${CHECKSUM:?}"
else
echo -e "${CL_RED}Repo slug should be in OWNER/REPO format${CL_RST}"
fi
;;
fmt)
alejandra --quiet .
shfmt -w -s -i 2 -ci xtask update.sh
;;
update)
shift
PACKAGE="${1-}"
VERSION="${2-}"
echo "{\"package\": \"${PACKAGE}\", \"version\": \"${VERSION}\"}" | gh workflow run update.yml --json
sleep 5
gh run list --workflow=update.yml --json databaseId | jq .[0].databaseId | xargs gh run watch
;;
sri)
shift
nix hash to-sri --type sha256 "${1:?}"
;;
nothing)
echo -e "${CL_RED}USAGE:${CL_RST}\n${CL_YLW}${0} '<action>'\n\t[possible values: 'clean' 'hash' 'fmt' 'update' 'sri']${CL_RST}"
;;
esac