mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 12:29:19 -08:00
chore: nf-lint-nix and nf-fmt-nix
This commit is contained in:
parent
ee53c89e40
commit
2a76c4fc98
11 changed files with 100 additions and 13 deletions
|
|
@ -18,7 +18,7 @@ with lib; {
|
|||
};
|
||||
config = {
|
||||
network.importing = {
|
||||
nixosImports = mkDefault (map (path: toString path) [
|
||||
nixosImports = mkDefault (map toString [
|
||||
(root + "/nixos/systems/HN.nix")
|
||||
(root + "/nixos/systems/HN/nixos.nix")
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@
|
|||
inherit (lib.options) mkOption;
|
||||
inherit (lib.types) attrsOf package;
|
||||
inherit (lib.meta) getExe;
|
||||
inherit (lib.strings) concatStringsSep concatMapStringsSep;
|
||||
cfg = config.outputs.packages;
|
||||
fmt = import ../../ci/fmt.nix;
|
||||
in {
|
||||
options.outputs.packages = mkOption {
|
||||
type = attrsOf package;
|
||||
|
|
@ -15,13 +17,54 @@ in {
|
|||
};
|
||||
|
||||
config.outputs.packages = {
|
||||
inherit (pkgs.buildPackages) terraform tflint;
|
||||
inherit (pkgs.buildPackages)
|
||||
terraform tflint
|
||||
alejandra deadnix statix
|
||||
;
|
||||
nf-deploy = pkgs.writeShellScriptBin "nf-deploy" ''
|
||||
exec ${pkgs.runtimeShell} ${../../ci/deploy.sh} "$@"
|
||||
'';
|
||||
nf-statix = pkgs.writeShellScriptBin "nf-statix" ''
|
||||
if [[ $# -eq 0 ]]; then
|
||||
set -- check
|
||||
fi
|
||||
|
||||
if [[ ''${1-} = check ]]; then
|
||||
shift
|
||||
set -- check --config ${../../ci/statix.toml} "$@"
|
||||
fi
|
||||
|
||||
exec ${getExe cfg.statix} "$@"
|
||||
'';
|
||||
nf-deadnix = let
|
||||
inherit (fmt.nix) blacklistDirs;
|
||||
excludes = "${getExe pkgs.buildPackages.findutils} ${concatStringsSep " " blacklistDirs} -type f";
|
||||
in pkgs.writeShellScriptBin "nf-deadnix" ''
|
||||
exec ${getExe cfg.deadnix} "$@" \
|
||||
--no-lambda-arg \
|
||||
--exclude $(${excludes})
|
||||
'';
|
||||
nf-alejandra = let
|
||||
inherit (fmt.nix) blacklistDirs;
|
||||
excludes = concatMapStringsSep " " (dir: "--exclude ${dir}") blacklistDirs;
|
||||
in pkgs.writeShellScriptBin "nf-alejandra" ''
|
||||
exec ${getExe cfg.alejandra} \
|
||||
${excludes} \
|
||||
"$@"
|
||||
'';
|
||||
nf-lint-tf = pkgs.writeShellScriptBin "nf-lint-tf" ''
|
||||
${getExe cfg.terraform} fmt "$@" &&
|
||||
${cfg.tflint}/bin/tflint
|
||||
'';
|
||||
nf-lint-nix = pkgs.writeShellScriptBin "nf-lint-nix" ''
|
||||
${getExe cfg.nf-statix} check "$@" &&
|
||||
${getExe cfg.nf-deadnix} -f "$@"
|
||||
'';
|
||||
nf-fmt-nix = let
|
||||
inherit (fmt.nix) whitelist;
|
||||
includes = concatStringsSep " " whitelist;
|
||||
in pkgs.writeShellScriptBin "nf-fmt-nix" ''
|
||||
exec ${getExe cfg.nf-alejandra} ${includes} "$@"
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue