Fix flake.nix and use its hooks

Fixes #24
This commit is contained in:
Greg Hellings
2024-11-18 22:02:07 -06:00
parent e7d1b0f7bd
commit ee831b6c48
3 changed files with 101 additions and 110 deletions
+38 -70
View File
@@ -3,9 +3,9 @@
description = "Greg's homepage";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
devshell.url = "github:numtide/devshell";
flake-parts.url = "github:hercules-ci/flake-parts";
process-compose.url = "github:Platonic-Systems/process-compose-flake";
hooks.url = "github:cachix/git-hooks.nix";
};
outputs =
@@ -41,11 +41,6 @@
packer build -only=${d.provider}.${d.arch} -var-file=${distroFile d}'';
in
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.devshell.flakeModule
inputs.flake-root.flakeModule
inputs.treefmt-nix.flakeModule
];
flake = {
# Universal things
};
@@ -65,56 +60,29 @@
inherit system;
config.allowUnfree = true;
};
# https://numtide.github.io/devshell/intro.html
devshells.default = {
devShells.default = pkgs.mkShell {
buildInputs = self'.checks.pre-commit.enabledPackages;
shellHook = self'.checks.pre-commit.shellHook;
packages =
(with pkgs; [
vagrant
])
++ (with self'.packages; [
cache
generate
shellcheck
validate
])
++ (builtins.map (d: self'.packages."build${name d}") withProviders);
# These commands will be shown in the motd that users read
# upon entering the shell
commands =
[
{
package = self'.packages.cache;
category = "utils";
help = "Downloads ISO files and adds them to the S3 bucket";
}
{
package = self'.packages.generate;
category = "utils";
help = "Generate dynamic HCL files";
}
{
package = self'.packages.shellcheck;
category = "utils";
help = "Run shellchecks";
}
{
package = self'.packages.validate;
category = "utils";
help = "Validate all the files";
}
{
package = pkgs.vagrant;
category = "utils";
help = "Vagrant to help with testing";
}
]
++ (builtins.map (d: {
package = self'.packages."build${name d}";
category = "builds";
}) withProviders);
env = [
{
name = "EFI_DIR";
value = "${pkgs.OVMF.fd}/FV/";
}
{
name = "PACKER_CONFIG_DIR";
value = "./packer_config";
}
{
name = "STORAGE_URL";
value = "http://s3.thehellings.lan:9000";
}
];
env = {
EFI_DIR = "${pkgs.OVMF.fd}/FV/";
PACKER_CONFIG_DIR = "./packer_config";
STORAGE_URL = "http://s3.thehellings.lan:9000";
};
};
# This is not special, this is just flakes
@@ -162,8 +130,8 @@
// {
name = "ci${name d}";
text = ''
set -x
${cmd d} -except=upload sources/
set -x
${cmd d} -except=upload sources/
'';
}
);
@@ -174,8 +142,8 @@
// {
name = "upload${name d}";
text = ''
set -x
${cmd d} sources/
set -x
${cmd d} sources/
'';
}
);
@@ -235,12 +203,12 @@
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
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 {
@@ -249,12 +217,12 @@
shellcheck
];
text = ''
scripts=()
shopt -s globstar
for f in **/*.sh; do
scripts+=("$f")
done
shellcheck -e SC2239 "''${scripts[@]}"
scripts=()
shopt -s globstar
for f in **/*.sh; do
scripts+=("$f")
done
shellcheck -e SC2239 "''${scripts[@]}"
'';
};
};