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
+1
View File
@@ -1,3 +1,4 @@
.pre-commit-config.yaml
output_* output_*
output/* output/*
*.box *.box
Generated
+62 -40
View File
@@ -1,21 +1,18 @@
{ {
"nodes": { "nodes": {
"devshell": { "flake-compat": {
"inputs": { "flake": false,
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
},
"locked": { "locked": {
"lastModified": 1717408969, "lastModified": 1696426674,
"narHash": "sha256-Q0OEFqe35fZbbRPPRdrjTUUChKVhhWXz3T9ZSKmaoVY=", "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "numtide", "owner": "edolstra",
"repo": "devshell", "repo": "flake-compat",
"rev": "1ebbe68d57457c8cae98145410b164b5477761f4", "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "numtide", "owner": "edolstra",
"repo": "devshell", "repo": "flake-compat",
"type": "github" "type": "github"
} }
}, },
@@ -37,31 +34,55 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils": { "gitignore": {
"inputs": { "inputs": {
"systems": "systems" "nixpkgs": [
"hooks",
"nixpkgs"
]
}, },
"locked": { "locked": {
"lastModified": 1701680307, "lastModified": 1709087332,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "numtide", "owner": "hercules-ci",
"repo": "flake-utils", "repo": "gitignore.nix",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725", "rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "numtide", "owner": "hercules-ci",
"repo": "flake-utils", "repo": "gitignore.nix",
"type": "github"
}
},
"hooks": {
"inputs": {
"flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": "nixpkgs",
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1731363552,
"narHash": "sha256-vFta1uHnD29VUY4HJOO/D6p6rxyObnf+InnSMT4jlMU=",
"owner": "cachix",
"repo": "git-hooks.nix",
"rev": "cd1af27aa85026ac759d5d3fccf650abe7e1bbf0",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "git-hooks.nix",
"type": "github" "type": "github"
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1704161960, "lastModified": 1730768919,
"narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=", "narHash": "sha256-8AKquNnnSaJRXZxc5YmF/WfmxiHX6MMZZasRP6RRQkE=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "63143ac2c9186be6d9da6035fa22620018c85932", "rev": "a04d33c0c3f1a59a2c1cb0c6e34cd24500e5a1dc",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -83,6 +104,22 @@
"url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz" "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz"
} }
}, },
"nixpkgs-stable": {
"locked": {
"lastModified": 1730741070,
"narHash": "sha256-edm8WG19kWozJ/GqyYx2VjW99EdhjKwbY3ZwdlPAAlo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d063c1dd113c91ab27959ba540c0d9753409edf3",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1720750130, "lastModified": 1720750130,
@@ -116,26 +153,11 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"devshell": "devshell",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"hooks": "hooks",
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_2",
"process-compose": "process-compose" "process-compose": "process-compose"
} }
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",
+38 -70
View File
@@ -3,9 +3,9 @@
description = "Greg's homepage"; description = "Greg's homepage";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
devshell.url = "github:numtide/devshell";
flake-parts.url = "github:hercules-ci/flake-parts"; flake-parts.url = "github:hercules-ci/flake-parts";
process-compose.url = "github:Platonic-Systems/process-compose-flake"; process-compose.url = "github:Platonic-Systems/process-compose-flake";
hooks.url = "github:cachix/git-hooks.nix";
}; };
outputs = outputs =
@@ -41,11 +41,6 @@
packer build -only=${d.provider}.${d.arch} -var-file=${distroFile d}''; packer build -only=${d.provider}.${d.arch} -var-file=${distroFile d}'';
in in
flake-parts.lib.mkFlake { inherit inputs; } { flake-parts.lib.mkFlake { inherit inputs; } {
imports = [
inputs.devshell.flakeModule
inputs.flake-root.flakeModule
inputs.treefmt-nix.flakeModule
];
flake = { flake = {
# Universal things # Universal things
}; };
@@ -65,56 +60,29 @@
inherit system; inherit system;
config.allowUnfree = true; 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 # These commands will be shown in the motd that users read
# upon entering the shell # upon entering the shell
commands = env = {
[ EFI_DIR = "${pkgs.OVMF.fd}/FV/";
{ PACKER_CONFIG_DIR = "./packer_config";
package = self'.packages.cache; STORAGE_URL = "http://s3.thehellings.lan:9000";
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";
}
];
}; };
# This is not special, this is just flakes # This is not special, this is just flakes
@@ -162,8 +130,8 @@
// { // {
name = "ci${name d}"; name = "ci${name d}";
text = '' text = ''
set -x set -x
${cmd d} -except=upload sources/ ${cmd d} -except=upload sources/
''; '';
} }
); );
@@ -174,8 +142,8 @@
// { // {
name = "upload${name d}"; name = "upload${name d}";
text = '' text = ''
set -x set -x
${cmd d} sources/ ${cmd d} sources/
''; '';
} }
); );
@@ -235,12 +203,12 @@
pup pup
]; ];
text = '' text = ''
shopt -s globstar shopt -s globstar
for vars in distros/**/*.pkrvars.hcl.sh; do for vars in distros/**/*.pkrvars.hcl.sh; do
bash "./''${vars}" bash "./''${vars}"
done done
set -x set -x
echo "BUILD=$(date "+%Y.%m.%d.%H")" >> build.env echo "BUILD=$(date "+%Y.%m.%d.%H")" >> build.env
''; '';
}; };
shellcheck = pkgs.writeShellApplication { shellcheck = pkgs.writeShellApplication {
@@ -249,12 +217,12 @@
shellcheck shellcheck
]; ];
text = '' text = ''
scripts=() scripts=()
shopt -s globstar shopt -s globstar
for f in **/*.sh; do for f in **/*.sh; do
scripts+=("$f") scripts+=("$f")
done done
shellcheck -e SC2239 "''${scripts[@]}" shellcheck -e SC2239 "''${scripts[@]}"
''; '';
}; };
}; };