Move more commands into nix
This commit is contained in:
+4
-14
@@ -9,16 +9,15 @@ variables:
|
|||||||
|
|
||||||
default:
|
default:
|
||||||
image: registry.thehellings.com/greg/ci-images/vm-test:latest
|
image: registry.thehellings.com/greg/ci-images/vm-test:latest
|
||||||
|
tags:
|
||||||
|
- nix
|
||||||
|
|
||||||
generate:
|
generate:
|
||||||
stage: generate
|
stage: generate
|
||||||
artifacts:
|
artifacts:
|
||||||
paths:
|
paths:
|
||||||
- distros/**/*.pkrvars.hcl
|
- distros/**/*.pkrvars.hcl
|
||||||
script: |-
|
script: nix build ".#generate"
|
||||||
for vars in $(find distros/ -name '*.pkrvars.hcl.sh'); do
|
|
||||||
bash "./${vars}"
|
|
||||||
done
|
|
||||||
|
|
||||||
continue:
|
continue:
|
||||||
stage: generate
|
stage: generate
|
||||||
@@ -27,8 +26,6 @@ continue:
|
|||||||
dotenv: build.env
|
dotenv: build.env
|
||||||
paths:
|
paths:
|
||||||
- .gitlab-ci-build.yml
|
- .gitlab-ci-build.yml
|
||||||
tags:
|
|
||||||
- nix
|
|
||||||
script:
|
script:
|
||||||
- nix build ".#continue"
|
- nix build ".#continue"
|
||||||
- cp result .gitlab-ci-build.yml
|
- cp result .gitlab-ci-build.yml
|
||||||
@@ -36,14 +33,10 @@ continue:
|
|||||||
|
|
||||||
shellcheck:
|
shellcheck:
|
||||||
stage: generate
|
stage: generate
|
||||||
tags:
|
|
||||||
- nix
|
|
||||||
script: nix run ".#shellcheck"
|
script: nix run ".#shellcheck"
|
||||||
|
|
||||||
validate:
|
validate:
|
||||||
stage: check
|
stage: check
|
||||||
tags:
|
|
||||||
- nix
|
|
||||||
needs:
|
needs:
|
||||||
- generate
|
- generate
|
||||||
cache:
|
cache:
|
||||||
@@ -59,8 +52,6 @@ validate:
|
|||||||
downloads:
|
downloads:
|
||||||
stage: check
|
stage: check
|
||||||
retry: 2
|
retry: 2
|
||||||
tags:
|
|
||||||
- nix
|
|
||||||
needs:
|
needs:
|
||||||
- generate
|
- generate
|
||||||
cache:
|
cache:
|
||||||
@@ -69,8 +60,7 @@ downloads:
|
|||||||
- sources/build.pkr.hcl
|
- sources/build.pkr.hcl
|
||||||
paths:
|
paths:
|
||||||
- ./packer_config/
|
- ./packer_config/
|
||||||
script:
|
script: nix run ".#cache"
|
||||||
- nix run ".#cache"
|
|
||||||
|
|
||||||
trigger:
|
trigger:
|
||||||
stage: trigger
|
stage: trigger
|
||||||
|
|||||||
@@ -60,6 +60,10 @@
|
|||||||
package = self'.packages.cache;
|
package = self'.packages.cache;
|
||||||
category = "utils";
|
category = "utils";
|
||||||
help = "Downloads ISO files and adds them to the S3 bucket";
|
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;
|
package = self'.packages.shellcheck;
|
||||||
category = "utils";
|
category = "utils";
|
||||||
@@ -68,6 +72,10 @@
|
|||||||
package = self'.packages.validate;
|
package = self'.packages.validate;
|
||||||
category = "utils";
|
category = "utils";
|
||||||
help = "Validate all the files";
|
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);
|
} ] ++ (builtins.map (d: { package = self'.packages."build${name d}"; category = "builds"; }) withProviders);
|
||||||
env = [{
|
env = [{
|
||||||
name = "EFI_DIR";
|
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
|
packages = let
|
||||||
base = {
|
base = {
|
||||||
runtimeInputs = with pkgs; [
|
runtimeInputs = with pkgs; [
|
||||||
packer
|
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}";
|
name = "build${name d}";
|
||||||
text = ''
|
text = ''
|
||||||
set -x
|
set -x
|
||||||
${cmd d} -except=upload -var headless=false sources/
|
${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 // {
|
upload = d: pkgs.writeShellApplication (base // {
|
||||||
name = "upload${name d}";
|
name = "upload${name d}";
|
||||||
text = ''
|
text = ''
|
||||||
set -x
|
set -x
|
||||||
${cmd d} sources/
|
${cmd d} sources/
|
||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
builds = lib.lists.foldr (d: acc: acc // { "build${name d}" = (build d); }) {} withProviders;
|
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;
|
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));
|
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));
|
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));
|
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;
|
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 {
|
shellcheck = pkgs.writeShellApplication {
|
||||||
name = "shellcheck";
|
name = "shellcheck";
|
||||||
runtimeInputs = with pkgs; [
|
runtimeInputs = with pkgs; [
|
||||||
|
|||||||
Reference in New Issue
Block a user