From 2e5b98bdee604b01d9a64ec1f6c228d4daf4b5d7 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Fri, 2 Feb 2024 02:17:50 +0530 Subject: [PATCH] feat: drop xtask --- default.nix | 2 +- flake.nix | 20 +++++++++++++++++++- statix.toml | 5 +++++ xtask | 46 ---------------------------------------------- 4 files changed, 25 insertions(+), 48 deletions(-) create mode 100644 statix.toml delete mode 100755 xtask diff --git a/default.nix b/default.nix index 67b0649..3914ba8 100644 --- a/default.nix +++ b/default.nix @@ -56,7 +56,7 @@ let with (fromJSON (readFile ./flake.lock)).nodes.${name}.locked; { inherit rev; outPath = fetchurl { - url = url; + inherit url; sha256 = narHash; }; }; diff --git a/flake.nix b/flake.nix index 5445861..daf27a6 100644 --- a/flake.nix +++ b/flake.nix @@ -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 . + ''; + }); }; } diff --git a/statix.toml b/statix.toml new file mode 100644 index 0000000..190b092 --- /dev/null +++ b/statix.toml @@ -0,0 +1,5 @@ +disabled = [ + "repeated_keys" +] +nix_version = '2.4' +ignore = ['.direnv'] diff --git a/xtask b/xtask deleted file mode 100755 index f0fd472..0000000 --- a/xtask +++ /dev/null @@ -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} ''\n\t[possible values: 'clean' 'hash' 'fmt' 'update' 'sri']${CL_RST}" - ;; -esac