Enable filtering

Honor the value of `exclude` in a distro listing. It has already been in
use to exclude Debian 12 from building on virtualbox-iso, but now we
will actually honor that call.

Also, tightens up the code that generates all the scripts so that it is
less verbose and more legible

Fixes #26
This commit is contained in:
Greg Hellings
2024-11-18 23:28:04 -06:00
parent 57ac996a38
commit f14c55e0c9
+34 -70
View File
@@ -29,16 +29,12 @@
d = flat; d = flat;
provider = providers; provider = providers;
}; };
active = builtins.filter (x: (x ? eol) && (!x.eol)) withProviders; active = builtins.filter (
x:
!(x.eol or false) && ((lib.lists.findFirstIndex (y: y == x.provider) (-1) (x.exclude or [ ])) == -1)
) withProviders;
name = d: "-${d.distro}-${d.arch}-${d.provider}-${d.version}"; name = d: "-${d.distro}-${d.arch}-${d.provider}-${d.version}";
distroFile = d: "distros/${d.distro}/${d.version}/${d.arch}.pkrvars.hcl"; distroFile = d: "distros/${d.distro}/${d.version}/${d.arch}.pkrvars.hcl";
cmd = d: ''
# This is a workaround for a goofy behavior in CI
if [ -e "''${PACKER_CONFIG_DIR}" ]; then
find "''${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";"
fi
packer init sources
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; } {
flake = { flake = {
@@ -88,68 +84,36 @@
# This is not special, this is just flakes # This is not special, this is just flakes
packages = packages =
let let
base = { base =
runtimeInputs = with pkgs; [ prefix: d: args:
cdrtools pkgs.writeShellApplication {
findutils name = "${prefix}${name d}";
packer runtimeInputs = with pkgs; [
qemu_full cdrtools
vagrant findutils
xorriso packer
]; qemu_full
}; vagrant
build = xorriso
d: ];
let text = ''
vp = # This is a workaround for a goofy behavior in CI
x: if [ -e "''${PACKER_CONFIG_DIR}" ]; then
if x.provider == "qemu" then find "''${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";"
"libvirt" fi
else if x.provider == "virtualbox-iso" then packer init sources
"virtualbox" packer build -only=${d.provider}.${d.arch} -var-file=${distroFile d} ${args} sources/
else if x.provider == "hyperv-iso" then '';
"hyperv" };
else builds = lib.lists.foldr (
"unknown"; d: acc: acc // { "build${name d}" = (base "build" d "-except=upload -var headless=false"); }
in ) { } withProviders;
pkgs.writeShellApplication ( cibuilds = lib.lists.foldr (
base d: acc: acc // { "ci${name d}" = (base "ci" d "-except=upload"); }
// { ) { } withProviders;
name = "build${name d}"; uploads = lib.lists.foldr (
text = '' d: acc: acc // { "upload${name d}" = (base "upload" d ""); }
set -x ) { } withProviders;
${cmd d} -except=upload -var headless=false sources/
vagrant box add --provider ${vp d} ./output/${vp d}/${d.distro}-${d.version}.box --name test_box --force
'';
}
);
cibuild =
d:
pkgs.writeShellApplication (
base
// {
name = "ci${name d}";
text = ''
set -x
${cmd d} -except=upload sources/
'';
}
);
upload =
d:
pkgs.writeShellApplication (
base
// {
name = "upload${name d}";
text = ''
set -x
${cmd d} sources/
'';
}
);
builds = lib.lists.foldr (d: acc: acc // { "build${name d}" = (build d); }) { } withProviders;
uploads = lib.lists.foldr (d: acc: acc // { "upload${name d}" = (upload d); }) { } withProviders;
cibuilds = lib.lists.foldr (d: acc: acc // { "ci${name d}" = (cibuild d); }) { } withProviders;
qemu_list = builtins.map (d: { buildcmd = (name d); }) ( qemu_list = builtins.map (d: { buildcmd = (name d); }) (
builtins.filter (x: x.provider == "qemu") active builtins.filter (x: x.provider == "qemu") active
); );