diff --git a/flake.nix b/flake.nix index 2eb2632..f439363 100644 --- a/flake.nix +++ b/flake.nix @@ -29,16 +29,12 @@ d = flat; 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}"; 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 flake-parts.lib.mkFlake { inherit inputs; } { flake = { @@ -88,68 +84,36 @@ # This is not special, this is just flakes packages = let - base = { - runtimeInputs = with pkgs; [ - cdrtools - findutils - packer - qemu_full - vagrant - xorriso - ]; - }; - build = - d: - let - vp = - x: - if x.provider == "qemu" then - "libvirt" - else if x.provider == "virtualbox-iso" then - "virtualbox" - else if x.provider == "hyperv-iso" then - "hyperv" - else - "unknown"; - in - pkgs.writeShellApplication ( - base - // { - name = "build${name d}"; - text = '' - set -x - ${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; + base = + prefix: d: args: + pkgs.writeShellApplication { + name = "${prefix}${name d}"; + runtimeInputs = with pkgs; [ + cdrtools + findutils + packer + qemu_full + vagrant + xorriso + ]; + text = '' + # 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} ${args} sources/ + ''; + }; + builds = lib.lists.foldr ( + d: acc: acc // { "build${name d}" = (base "build" d "-except=upload -var headless=false"); } + ) { } withProviders; + cibuilds = lib.lists.foldr ( + d: acc: acc // { "ci${name d}" = (base "ci" d "-except=upload"); } + ) { } withProviders; + uploads = lib.lists.foldr ( + d: acc: acc // { "upload${name d}" = (base "upload" d ""); } + ) { } withProviders; qemu_list = builtins.map (d: { buildcmd = (name d); }) ( builtins.filter (x: x.provider == "qemu") active );