Use nix to do builds
This commit is contained in:
+9
-12
@@ -31,19 +31,8 @@ stages:
|
||||
PACKER_CONFIG_DIR: ./packer_config/
|
||||
PACKER_CACHE_DIR: ./cache/
|
||||
PACKER_LOG: 1
|
||||
COMMAND: >
|
||||
packer build ${only}
|
||||
-var-file="${distro}"
|
||||
-var build=${BUILD}
|
||||
-var cpus=2
|
||||
-var memory=4096
|
||||
${EXCEPT}
|
||||
sources
|
||||
script:
|
||||
- find "${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";"
|
||||
- packer init sources
|
||||
- echo $COMMAND > build.sh
|
||||
- bash build.sh || exit 1
|
||||
- nix run ".#${buildcmd}" || exit 1
|
||||
|
||||
qemu.amd64:
|
||||
extends: .build
|
||||
@@ -69,6 +58,14 @@ hyperv-iso.amd64:
|
||||
<<: *variables
|
||||
only: '-only="hyperv-iso.amd64"'
|
||||
tag: hyperv
|
||||
COMMAND: >
|
||||
packer build ${only}
|
||||
-var-file="${distro}"
|
||||
-var build=${BUILD}
|
||||
-var cpus=2
|
||||
-var memory=4096
|
||||
${EXCEPT}
|
||||
sources
|
||||
parallel:
|
||||
matrix: HYPERV_MATRIX
|
||||
script:
|
||||
|
||||
@@ -45,8 +45,6 @@ validate:
|
||||
- sources/build.pkr.hcl
|
||||
paths:
|
||||
- ./packer_config/
|
||||
before_script:
|
||||
- find "${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";"
|
||||
script: nix run ".#validate"
|
||||
|
||||
# Makes sure that all of the ISO files we are looking for are
|
||||
|
||||
Generated
+3
-3
@@ -100,11 +100,11 @@
|
||||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1718870667,
|
||||
"narHash": "sha256-jab3Kpc8O1z3qxwVsCMHL4+18n5Wy/HHKyu1fcsF7gs=",
|
||||
"lastModified": 1720750130,
|
||||
"narHash": "sha256-y2wc7CdK0vVSIbx7MdVoZzuMcUoLvZXm+pQf2RIr1OU=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9b10b8f00cb5494795e5f51b39210fed4d2b0748",
|
||||
"rev": "6794d064edc69918bb0fc0e0eda33ece324be17a",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -30,6 +30,9 @@
|
||||
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
|
||||
find "''${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";"
|
||||
packer init sources
|
||||
version="''${1:-1}"
|
||||
packer build -var "build=$version" -only=${d.provider}.${d.arch} -var-file=${distroFile d}'';
|
||||
in flake-parts.lib.mkFlake { inherit inputs; }
|
||||
@@ -88,6 +91,7 @@
|
||||
base = {
|
||||
runtimeInputs = with pkgs; [
|
||||
packer
|
||||
findutils
|
||||
qemu_full
|
||||
vagrant
|
||||
];
|
||||
@@ -114,8 +118,8 @@
|
||||
});
|
||||
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;
|
||||
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));
|
||||
qemu_list = builtins.toJSON (builtins.map (d: { buildcmd = "build${name d}"; }) (builtins.filter (x: x.provider == "qemu") active));
|
||||
vbox_list = builtins.toJSON (builtins.map (d: { buildcmd = "build${name 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));
|
||||
in builds // uploads // {
|
||||
continue = pkgs.writeText "continue.yml"
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
{
|
||||
writeShellApplication,
|
||||
findutils,
|
||||
packer,
|
||||
...
|
||||
}:
|
||||
writeShellApplication {
|
||||
name = "validate";
|
||||
runtimeInputs = [
|
||||
findutils
|
||||
packer
|
||||
];
|
||||
text = ''
|
||||
shopt -s globstar
|
||||
find "${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";"
|
||||
packer init sources
|
||||
for vars in distros/**/*.pkrvars.hcl; do
|
||||
packer validate -except=upload "-var-file=''${vars}" sources/
|
||||
|
||||
Reference in New Issue
Block a user