feat: drop xtask

This commit is contained in:
Harsh Shandilya 2024-02-02 02:17:50 +05:30
parent 1aac97d906
commit 2e5b98bdee
4 changed files with 25 additions and 48 deletions

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,27 @@
};
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;
};
formatter = eachSystem (system:
pkgs.${system}.writeShellApplication {
name = "format";
runtimeInputs = with pkgs.${system}; [
alejandra
deadnix
shfmt
statix
];
text = ''
set -euo pipefail
shfmt --write --simplify --language-dialect bash --indent 2 --case-indent --space-redirects .;
deadnix --edit
statix check . || statix fix .
alejandra --quiet .
'';
});
};
}

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