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