Move more commands into nix
This commit is contained in:
@@ -60,6 +60,10 @@
|
||||
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";
|
||||
@@ -68,6 +72,10 @@
|
||||
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";
|
||||
@@ -75,31 +83,37 @@
|
||||
}];
|
||||
};
|
||||
|
||||
# This is not special, this is just flakes
|
||||
# This is not special, this is just flakes
|
||||
packages = let
|
||||
base = {
|
||||
runtimeInputs = with pkgs; [
|
||||
packer
|
||||
qemu_full
|
||||
qemu_full
|
||||
vagrant
|
||||
];
|
||||
};
|
||||
build = d: pkgs.writeShellApplication (base // {
|
||||
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/
|
||||
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
|
||||
'';
|
||||
});
|
||||
});
|
||||
upload = d: pkgs.writeShellApplication (base // {
|
||||
name = "upload${name d}";
|
||||
text = ''
|
||||
set -x
|
||||
${cmd d} sources/
|
||||
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;
|
||||
toYAML = x: (pkgs.formats.yaml x).generate;
|
||||
qemu_list = builtins.toJSON (builtins.map (d: { distro = distroFile d; }) (builtins.filter (x: x.provider == "qemu") active));
|
||||
vbox_list = builtins.toJSON (builtins.map (d: { distro = distroFile d; }) (builtins.filter (x: x.provider == "virtualbox-iso") active));
|
||||
hyperv_list = builtins.toJSON (builtins.map (d: { distro = distroFile d; }) (builtins.filter (x: x.provider == "hyperv-iso") active));
|
||||
@@ -118,6 +132,21 @@
|
||||
];
|
||||
text = builtins.readFile ./cache-restore.sh;
|
||||
};
|
||||
generate = pkgs.writeShellApplication {
|
||||
name = "generate";
|
||||
runtimeInputs = with pkgs; [
|
||||
bash
|
||||
curl
|
||||
jq
|
||||
pup
|
||||
];
|
||||
text = ''
|
||||
shopt -s globstar
|
||||
for vars in distros/**/*.pkrvars.hcl.sh; do
|
||||
bash "./''${vars}"
|
||||
done
|
||||
'';
|
||||
};
|
||||
shellcheck = pkgs.writeShellApplication {
|
||||
name = "shellcheck";
|
||||
runtimeInputs = with pkgs; [
|
||||
|
||||
Reference in New Issue
Block a user