Move more commands into nix
This commit is contained in:
+4
-14
@@ -9,16 +9,15 @@ variables:
|
||||
|
||||
default:
|
||||
image: registry.thehellings.com/greg/ci-images/vm-test:latest
|
||||
tags:
|
||||
- nix
|
||||
|
||||
generate:
|
||||
stage: generate
|
||||
artifacts:
|
||||
paths:
|
||||
- distros/**/*.pkrvars.hcl
|
||||
script: |-
|
||||
for vars in $(find distros/ -name '*.pkrvars.hcl.sh'); do
|
||||
bash "./${vars}"
|
||||
done
|
||||
script: nix build ".#generate"
|
||||
|
||||
continue:
|
||||
stage: generate
|
||||
@@ -27,8 +26,6 @@ continue:
|
||||
dotenv: build.env
|
||||
paths:
|
||||
- .gitlab-ci-build.yml
|
||||
tags:
|
||||
- nix
|
||||
script:
|
||||
- nix build ".#continue"
|
||||
- cp result .gitlab-ci-build.yml
|
||||
@@ -36,14 +33,10 @@ continue:
|
||||
|
||||
shellcheck:
|
||||
stage: generate
|
||||
tags:
|
||||
- nix
|
||||
script: nix run ".#shellcheck"
|
||||
|
||||
validate:
|
||||
stage: check
|
||||
tags:
|
||||
- nix
|
||||
needs:
|
||||
- generate
|
||||
cache:
|
||||
@@ -59,8 +52,6 @@ validate:
|
||||
downloads:
|
||||
stage: check
|
||||
retry: 2
|
||||
tags:
|
||||
- nix
|
||||
needs:
|
||||
- generate
|
||||
cache:
|
||||
@@ -69,8 +60,7 @@ downloads:
|
||||
- sources/build.pkr.hcl
|
||||
paths:
|
||||
- ./packer_config/
|
||||
script:
|
||||
- nix run ".#cache"
|
||||
script: nix run ".#cache"
|
||||
|
||||
trigger:
|
||||
stage: trigger
|
||||
|
||||
@@ -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