diff --git a/flake.nix b/flake.nix index f439363..6d6c572 100644 --- a/flake.nix +++ b/flake.nix @@ -149,38 +149,8 @@ ]; text = builtins.readFile ./cache-restore.sh; }; - generate = pkgs.writeShellApplication { - name = "generate"; - runtimeInputs = with pkgs; [ - bash - coreutils - curl - jq - pup - ]; - text = '' - shopt -s globstar - for vars in distros/**/*.pkrvars.hcl.sh; do - bash "./''${vars}" - done - set -x - echo "BUILD=$(date "+%Y.%m.%d.%H")" >> build.env - ''; - }; - shellcheck = pkgs.writeShellApplication { - name = "shellcheck"; - runtimeInputs = with pkgs; [ - shellcheck - ]; - text = '' - scripts=() - shopt -s globstar - for f in **/*.sh; do - scripts+=("$f") - done - shellcheck -e SC2239 "''${scripts[@]}" - ''; - }; + generate = pkgs.callPackage (import ./nix/generate.nix) { }; + shellcheck = pkgs.callPackage (import ./nix/shellcheck.nix) { }; }; checks = { diff --git a/nix/generate.nix b/nix/generate.nix new file mode 100644 index 0000000..699c813 --- /dev/null +++ b/nix/generate.nix @@ -0,0 +1,27 @@ +{ + writeShellApplication, + bash, + coreutils, + curl, + jq, + pup, +}: + +writeShellApplication { + name = "generate"; + runtimeInputs = [ + bash + coreutils + curl + jq + pup + ]; + text = '' + shopt -s globstar + for vars in distros/**/*.pkrvars.hcl.sh; do + bash "./''${vars}" + done + set -x + echo "BUILD=$(date "+%Y.%m.%d.%H")" >> build.env + ''; +} diff --git a/nix/shellcheck.nix b/nix/shellcheck.nix new file mode 100644 index 0000000..4940db2 --- /dev/null +++ b/nix/shellcheck.nix @@ -0,0 +1,15 @@ +{ writeShellApplication, shellcheck }: +writeShellApplication { + name = "shellcheck"; + runtimeInputs = [ + shellcheck + ]; + text = '' + scripts=() + shopt -s globstar + for f in **/*.sh; do + scripts+=("$f") + done + shellcheck -e SC2239 "''${scripts[@]}" + ''; +}