Merge branch 'qol-improvements' into 'main'

Fix Rawhide builds

Closes #28, #29, #24, #26, and #19

See merge request greg/vms!14
This commit is contained in:
Greg Hellings
2024-11-19 06:39:27 +00:00
90 changed files with 970 additions and 806 deletions
+1 -1
View File
@@ -1 +1 @@
* text eol=lf * text eol=lf
+1
View File
@@ -1,3 +1,4 @@
.pre-commit-config.yaml
output_* output_*
output/* output/*
*.box *.box
-1
View File
@@ -94,4 +94,3 @@ hyperv-iso.amd64:
description: >- description: >-
Release $CI_COMMIT_TAG, found on [Vagrant Cloud](https://app.vagrantup.com/boxen/) Release $CI_COMMIT_TAG, found on [Vagrant Cloud](https://app.vagrantup.com/boxen/)
as version v${BUILD} as version v${BUILD}
+4
View File
@@ -35,6 +35,10 @@ shellcheck:
stage: generate stage: generate
script: nix run ".#shellcheck" script: nix run ".#shellcheck"
flake-check:
stage: generate
script: nix flake check
validate: validate:
stage: check stage: check
needs: needs:
+2 -2
View File
@@ -33,12 +33,12 @@ Vagrant.configure("2") do |config|
config.vm.provider "libvirt" do |lv| config.vm.provider "libvirt" do |lv|
end end
config.vm.provider "hyperv" do |hv, over| config.vm.provider "hyperv" do |hv, over|
over.vm.network "private_network", bridge: "packer-amd64" over.vm.network "private_network", bridge: "packer-amd64"
#config.vm.network "private_network", bridge: "packer-amd64" #config.vm.network "private_network", bridge: "packer-amd64"
end end
# #
# View the documentation for the provider you are using for more # View the documentation for the provider you are using for more
# information on available options. # information on available options.
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
dnf clean all dnf clean all
+12 -9
View File
@@ -1,9 +1,12 @@
[ { [
version = "8"; {
arch = "amd64"; version = "8";
eol = true; arch = "amd64";
} { eol = true;
version = "9"; }
arch = "amd64"; {
eol = false; version = "9";
} ] arch = "amd64";
eol = false;
}
]
+1 -1
View File
@@ -1,2 +1,2 @@
#!/usr/bin/env sh #!/usr/bin/env sh
set -ex set -ex
+1 -1
View File
@@ -58,4 +58,4 @@ mv in-chroot.sh /mnt
for fs in proc sys dev sys/firmware/efi/efivars; do mount -o bind /${fs} /mnt/${fs}; done for fs in proc sys dev sys/firmware/efi/efivars; do mount -o bind /${fs} /mnt/${fs}; done
chroot /mnt /bin/ash /in-chroot.sh chroot /mnt /bin/ash /in-chroot.sh
rm /mnt/in-chroot.sh rm /mnt/in-chroot.sh
reboot reboot
+1 -1
View File
@@ -54,4 +54,4 @@ virtualbox*)
;; ;;
esac esac
efibootmgr --bootnext "${target}" efibootmgr --bootnext "${target}"
+1 -1
View File
@@ -1,2 +1,2 @@
#!/usr/bin/env sh #!/usr/bin/env sh
set -ex set -ex
+1 -1
View File
@@ -1,2 +1,2 @@
#!/usr/bin/env sh #!/usr/bin/env sh
set -ex set -ex
+1 -1
View File
@@ -58,4 +58,4 @@ mv in-chroot.sh /mnt
for fs in proc sys dev sys/firmware/efi/efivars; do mount -o bind /${fs} /mnt/${fs}; done for fs in proc sys dev sys/firmware/efi/efivars; do mount -o bind /${fs} /mnt/${fs}; done
chroot /mnt /bin/ash /in-chroot.sh chroot /mnt /bin/ash /in-chroot.sh
rm /mnt/in-chroot.sh rm /mnt/in-chroot.sh
reboot reboot
+1 -1
View File
@@ -54,4 +54,4 @@ virtualbox*)
;; ;;
esac esac
efibootmgr --bootnext "${target}" efibootmgr --bootnext "${target}"
+1 -1
View File
@@ -1,2 +1,2 @@
#!/usr/bin/env sh #!/usr/bin/env sh
set -ex set -ex
+12 -9
View File
@@ -1,9 +1,12 @@
[ { [
version = "3.19.0"; {
arch = "amd64"; version = "3.19.0";
eol = false; arch = "amd64";
} { eol = false;
version = "3.20"; }
arch = "amd64"; {
eol = false; version = "3.20";
} ] arch = "amd64";
eol = false;
}
]
+7 -5
View File
@@ -1,5 +1,7 @@
[ { [
version = "rolling"; {
arch = "amd64"; version = "rolling";
eol = false; arch = "amd64";
} ] eol = false;
}
]
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
dnf clean all dnf clean all
+12 -9
View File
@@ -1,9 +1,12 @@
[ { [
version = "8"; {
arch = "amd64"; version = "8";
eol = true; arch = "amd64";
} { eol = true;
version = "9"; }
arch = "amd64"; {
eol = false; version = "9";
} ] arch = "amd64";
eol = false;
}
]
-1
View File
@@ -75,4 +75,3 @@ if [ "${virt}" == "microsoft" ]; then
systemctl enable hypervvssd systemctl enable hypervvssd
fi fi
%end %end
+7 -5
View File
@@ -1,5 +1,7 @@
[ { [
version = "7"; {
arch = "amd64"; version = "7";
eol = true; arch = "amd64";
} ] eol = true;
}
]
+1 -1
View File
@@ -17,4 +17,4 @@ if [ "${virt}" == "microsoft" ]; then
systemctl enable hyperv-daemons.hv-fcopy-daemon systemctl enable hyperv-daemons.hv-fcopy-daemon
systemctl enable hyperv-daemons.hv-kvp-daemon systemctl enable hyperv-daemons.hv-kvp-daemon
systemctl enable hyperv-daemons.hv-vss-daemon systemctl enable hyperv-daemons.hv-vss-daemon
fi fi
+1 -1
View File
@@ -55,4 +55,4 @@ d-i preseed/late_command string
chmod 440 /target/etc/sudoers.d/vagrant; \ chmod 440 /target/etc/sudoers.d/vagrant; \
in-target apt-get update; \ in-target apt-get update; \
in-target apt-get upgrade -y; \ in-target apt-get upgrade -y; \
in-target bash -c 'if [ "$(systemd-detect-virt)" == "microsoft" ]; then apt-get install -y hyperv-daemons; fi' in-target bash -c 'if [ "$(systemd-detect-virt)" == "microsoft" ]; then apt-get install -y hyperv-daemons; fi'
+1 -1
View File
@@ -19,4 +19,4 @@ if [ "${virt}" == "microsoft" ]; then
systemctl enable hv-fcopy-daemon systemctl enable hv-fcopy-daemon
systemctl enable hv-kvp-daemon systemctl enable hv-kvp-daemon
systemctl enable hv-vss-daemon systemctl enable hv-vss-daemon
fi fi
+1 -1
View File
@@ -49,4 +49,4 @@ d-i preseed/late_command string
chmod 440 /target/etc/sudoers.d/vagrant; \ chmod 440 /target/etc/sudoers.d/vagrant; \
sed -i -e 's/ens3/ens5/g' /target/etc/network/interfaces; \ sed -i -e 's/ens3/ens5/g' /target/etc/network/interfaces; \
in-target apt-get update; \ in-target apt-get update; \
in-target apt-get upgrade -y in-target apt-get upgrade -y
+1 -1
View File
@@ -19,4 +19,4 @@ if [ "${virt}" == "microsoft" ]; then
systemctl enable hv-fcopy-daemon systemctl enable hv-fcopy-daemon
systemctl enable hv-kvp-daemon systemctl enable hv-kvp-daemon
systemctl enable hv-vss-daemon systemctl enable hv-vss-daemon
fi fi
+1 -1
View File
@@ -67,4 +67,4 @@ d-i preseed/late_command string
chmod 440 /target/etc/sudoers.d/vagrant; \ chmod 440 /target/etc/sudoers.d/vagrant; \
sed -i -e 's/ens3/ens5/g' /target/etc/network/interfaces; \ sed -i -e 's/ens3/ens5/g' /target/etc/network/interfaces; \
in-target apt-get update; \ in-target apt-get update; \
in-target apt-get upgrade -y in-target apt-get upgrade -y
+25 -20
View File
@@ -1,20 +1,25 @@
[ { [
version = "9"; {
arch = "amd64"; version = "9";
eol = true; arch = "amd64";
} { eol = true;
version = "10"; }
arch = "amd64"; {
eol = true; version = "10";
} { arch = "amd64";
version = "11"; eol = true;
arch = "amd64"; }
eol = false; {
} { version = "11";
version = "12"; arch = "amd64";
arch = "amd64"; eol = false;
eol = false; }
exclude = [ {
"virtualbox-iso" version = "12";
]; arch = "amd64";
} ] eol = false;
exclude = [
"virtualbox-iso"
];
}
]
+11 -11
View File
@@ -1,13 +1,13 @@
{ {
almalinux = import ./almalinux; almalinux = import ./almalinux;
alpine = import ./alpine; alpine = import ./alpine;
archlinux = import ./archlinux; archlinux = import ./archlinux;
centos = import ./centos; centos = import ./centos;
centos-stream = import ./centos-stream; centos-stream = import ./centos-stream;
debian = import ./debian; debian = import ./debian;
fedora = import ./fedora; fedora = import ./fedora;
nixos = import ./nixos; nixos = import ./nixos;
opensuse = import ./opensuse; opensuse = import ./opensuse;
rockylinux = import ./rockylinux; rockylinux = import ./rockylinux;
ubuntu = import ./ubuntu; ubuntu = import ./ubuntu;
} }
-1
View File
@@ -168,4 +168,3 @@ ssh-keygen -A
%end %end
##### end kickstart post ############################################ ##### end kickstart post ############################################
-1
View File
@@ -180,4 +180,3 @@ chcon -R unconfined_u:object_r:user_home_t:s0 /home/vagrant/.ssh
%end %end
##### end kickstart post ############################################ ##### end kickstart post ############################################
-1
View File
@@ -179,4 +179,3 @@ chcon -R unconfined_u:object_r:user_home_t:s0 /home/vagrant/.ssh
%end %end
##### end kickstart post ############################################ ##### end kickstart post ############################################
-1
View File
@@ -179,4 +179,3 @@ chcon -R unconfined_u:object_r:user_home_t:s0 /home/vagrant/.ssh
%end %end
##### end kickstart post ############################################ ##### end kickstart post ############################################
+32 -25
View File
@@ -1,25 +1,32 @@
[ { [
version = "37"; {
arch = "amd64"; version = "37";
eol = true; arch = "amd64";
} { eol = true;
version = "38"; }
arch = "amd64"; {
eol = true; version = "38";
} { arch = "amd64";
version = "39"; eol = true;
arch = "amd64"; }
eol = false; {
} { version = "39";
version = "40"; arch = "amd64";
arch = "amd64"; eol = false;
eol = false; }
} { {
version = "41"; version = "40";
arch = "amd64"; arch = "amd64";
eol = false; eol = false;
} { }
version = "rawhide"; {
arch = "amd64"; version = "41";
eol = false; arch = "amd64";
} ] eol = false;
}
{
version = "rawhide";
arch = "amd64";
eol = false;
}
]
-1
View File
@@ -181,4 +181,3 @@ chcon -R unconfined_u:object_r:user_home_t:s0 /home/vagrant/.ssh
%end %end
##### end kickstart post ############################################ ##### end kickstart post ############################################
+67 -60
View File
@@ -1,67 +1,74 @@
{config, pkgs, lib, ...}: {
pkgs,
lib,
...
}:
{ {
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix
./guest-agent.nix ./guest-agent.nix
]; ];
system.stateVersion = "23.05"; system.stateVersion = "23.05";
# Packages installed on the whole system # Packages installed on the whole system
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
curl curl
nano nano
python3 python3
]; ];
# Services that are running # Services that are running
services = { services = {
openssh.enable = true; openssh.enable = true;
#xserver.enable = true; #xserver.enable = true;
}; };
# User setup # User setup
users.groups.vagrant = {}; users.groups.vagrant = { };
users.users.vagrant = { users.users.vagrant = {
isNormalUser = true; isNormalUser = true;
group = "vagrant"; group = "vagrant";
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];
password = "vagrant"; password = "vagrant";
}; };
security.sudo.extraRules = [ security.sudo.extraRules = [
{ {
users = [ "vagrant" ]; users = [ "vagrant" ];
groups = [ "vagrant" ]; groups = [ "vagrant" ];
commands = [ commands = [
{ command = "ALL"; options = [ "NOPASSWD" ]; } {
]; command = "ALL";
} options = [ "NOPASSWD" ];
]; }
];
}
];
boot.loader = { boot.loader = {
systemd-boot = { systemd-boot = {
enable = true; enable = true;
}; };
efi.canTouchEfiVariables = true; efi.canTouchEfiVariables = true;
}; };
networking = { networking = {
hostName = "vagrant"; hostName = "vagrant";
networkmanager.enable = true; networkmanager.enable = true;
#proxy.default = "http://user:password@proxy:port/"; #proxy.default = "http://user:password@proxy:port/";
#proxy.noProxy = "127.0.0.1,localhost,internal.domain"; #proxy.noProxy = "127.0.0.1,localhost,internal.domain";
}; };
time.timeZone = "UTC"; time.timeZone = "UTC";
i18n.defaultLocale = "en_US.UTF-8";
console = {
font = "Lat2-Terminux16";
keyMap = lib.mkForce "us";
useXkbConfig = true;
};
nix = { i18n.defaultLocale = "en_US.UTF-8";
package = pkgs.nixFlakes; console = {
settings = { font = "Lat2-Terminux16";
experimental-features = "nix-command flakes"; keyMap = lib.mkForce "us";
}; useXkbConfig = true;
}; };
nix = {
package = pkgs.nixFlakes;
settings = {
experimental-features = "nix-command flakes";
};
};
} }
+12 -11
View File
@@ -1,15 +1,16 @@
{ {
description = "A basic NixOS Vagrant install"; description = "A basic NixOS Vagrant install";
inputs = { inputs = {
nixstable.url = "github:nixos/nixpkgs/nixos-23.05"; nixstable.url = "github:nixos/nixpkgs/nixos-23.05";
}; };
outputs = { nixstable, self, ... }@inputs: outputs =
{ { nixstable, ... }:
nixosConfigurations.vagrant = nixstable.lib.nixosSystem { {
system = "x86_64-linux"; nixosConfigurations.vagrant = nixstable.lib.nixosSystem {
modules = [ ./configuration.nix ]; system = "x86_64-linux";
}; modules = [ ./configuration.nix ];
}; };
};
} }
-1
View File
@@ -1 +0,0 @@
ga-qemu.nix
+4
View File
@@ -0,0 +1,4 @@
{ ... }:
{
services.qemuGuest.enable = true;
}
+3 -3
View File
@@ -1,4 +1,4 @@
{...}: { ... }:
{ {
virtualisation.hypervGuest.enable = true; virtualisation.hypervGuest.enable = true;
} }
+6 -6
View File
@@ -1,7 +1,7 @@
{...}: { ... }:
{ {
virtualisation.virtualbox.guest = { virtualisation.virtualbox.guest = {
enable = true; enable = true;
x11 = false; x11 = false;
}; };
} }
+3 -3
View File
@@ -1,4 +1,4 @@
{...}: { ... }:
{ {
services.qemuGuest.enable = true; services.qemuGuest.enable = true;
} }
+3 -3
View File
@@ -1,7 +1,7 @@
{...}: { ... }:
{ {
virtualisation.vmware.guest = { virtualisation.vmware.guest = {
enable = true; enable = true;
headless = false; headless = false;
} };
} }
+1 -1
View File
@@ -61,4 +61,4 @@ rm /mnt/root/in-chroot.sh
umount /mnt/boot umount /mnt/boot
umount /mnt umount /mnt
efibootmgr --bootnext "$(efibootmgr | grep Linux | awk '{print $1}' | sed -E 's/[^0-9]//g')" efibootmgr --bootnext "$(efibootmgr | grep Linux | awk '{print $1}' | sed -E 's/[^0-9]//g')"
reboot reboot
+67 -60
View File
@@ -1,67 +1,74 @@
{config, pkgs, lib, ...}: {
pkgs,
lib,
...
}:
{ {
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix
./guest-agent.nix ./guest-agent.nix
]; ];
system.stateVersion = "23.11"; system.stateVersion = "23.11";
# Packages installed on the whole system # Packages installed on the whole system
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
curl curl
nano nano
python3 python3
]; ];
# Services that are running # Services that are running
services = { services = {
openssh.enable = true; openssh.enable = true;
#xserver.enable = true; #xserver.enable = true;
}; };
# User setup # User setup
users.groups.vagrant = {}; users.groups.vagrant = { };
users.users.vagrant = { users.users.vagrant = {
isNormalUser = true; isNormalUser = true;
group = "vagrant"; group = "vagrant";
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];
password = "vagrant"; password = "vagrant";
}; };
security.sudo.extraRules = [ security.sudo.extraRules = [
{ {
users = [ "vagrant" ]; users = [ "vagrant" ];
groups = [ "vagrant" ]; groups = [ "vagrant" ];
commands = [ commands = [
{ command = "ALL"; options = [ "NOPASSWD" ]; } {
]; command = "ALL";
} options = [ "NOPASSWD" ];
]; }
];
}
];
boot.loader = { boot.loader = {
systemd-boot = { systemd-boot = {
enable = true; enable = true;
}; };
efi.canTouchEfiVariables = true; efi.canTouchEfiVariables = true;
}; };
networking = { networking = {
hostName = "vagrant"; hostName = "vagrant";
networkmanager.enable = true; networkmanager.enable = true;
#proxy.default = "http://user:password@proxy:port/"; #proxy.default = "http://user:password@proxy:port/";
#proxy.noProxy = "127.0.0.1,localhost,internal.domain"; #proxy.noProxy = "127.0.0.1,localhost,internal.domain";
}; };
time.timeZone = "UTC"; time.timeZone = "UTC";
i18n.defaultLocale = "en_US.UTF-8";
console = {
font = "Lat2-Terminux16";
keyMap = lib.mkForce "us";
useXkbConfig = true;
};
nix = { i18n.defaultLocale = "en_US.UTF-8";
package = pkgs.nixFlakes; console = {
settings = { font = "Lat2-Terminux16";
experimental-features = "nix-command flakes"; keyMap = lib.mkForce "us";
}; useXkbConfig = true;
}; };
nix = {
package = pkgs.nixFlakes;
settings = {
experimental-features = "nix-command flakes";
};
};
} }
+12 -11
View File
@@ -1,15 +1,16 @@
{ {
description = "A basic NixOS Vagrant install"; description = "A basic NixOS Vagrant install";
inputs = { inputs = {
nixstable.url = "github:nixos/nixpkgs/nixos-23.11"; nixstable.url = "github:nixos/nixpkgs/nixos-23.11";
}; };
outputs = { nixstable, self, ... }@inputs: outputs =
{ { nixstable, ... }:
nixosConfigurations.vagrant = nixstable.lib.nixosSystem { {
system = "x86_64-linux"; nixosConfigurations.vagrant = nixstable.lib.nixosSystem {
modules = [ ./configuration.nix ]; system = "x86_64-linux";
}; modules = [ ./configuration.nix ];
}; };
};
} }
-1
View File
@@ -1 +0,0 @@
ga-qemu.nix
+4
View File
@@ -0,0 +1,4 @@
{ ... }:
{
services.qemuGuest.enable = true;
}
+3 -3
View File
@@ -1,4 +1,4 @@
{...}: { ... }:
{ {
virtualisation.hypervGuest.enable = true; virtualisation.hypervGuest.enable = true;
} }
+6 -6
View File
@@ -1,7 +1,7 @@
{...}: { ... }:
{ {
virtualisation.virtualbox.guest = { virtualisation.virtualbox.guest = {
enable = true; enable = true;
x11 = false; x11 = false;
}; };
} }
+3 -3
View File
@@ -1,4 +1,4 @@
{...}: { ... }:
{ {
services.qemuGuest.enable = true; services.qemuGuest.enable = true;
} }
+3 -3
View File
@@ -1,7 +1,7 @@
{...}: { ... }:
{ {
virtualisation.vmware.guest = { virtualisation.vmware.guest = {
enable = true; enable = true;
headless = false; headless = false;
} };
} }
+1 -1
View File
@@ -61,4 +61,4 @@ rm /mnt/root/in-chroot.sh
umount /mnt/boot umount /mnt/boot
umount /mnt umount /mnt
efibootmgr --bootnext "$(efibootmgr | grep Linux | awk '{print $1}' | sed -E 's/[^0-9]//g')" efibootmgr --bootnext "$(efibootmgr | grep Linux | awk '{print $1}' | sed -E 's/[^0-9]//g')"
reboot reboot
+1 -1
View File
@@ -1,2 +1,2 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
+1 -1
View File
@@ -1,2 +1,2 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
+1 -1
View File
@@ -1,2 +1,2 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
+67 -60
View File
@@ -1,67 +1,74 @@
{config, pkgs, lib, ...}: {
pkgs,
lib,
...
}:
{ {
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix
./guest-agent.nix ./guest-agent.nix
]; ];
system.stateVersion = "24.05"; system.stateVersion = "24.05";
# Packages installed on the whole system # Packages installed on the whole system
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
curl curl
nano nano
python3 python3
]; ];
# Services that are running # Services that are running
services = { services = {
openssh.enable = true; openssh.enable = true;
#xserver.enable = true; #xserver.enable = true;
}; };
# User setup # User setup
users.groups.vagrant = {}; users.groups.vagrant = { };
users.users.vagrant = { users.users.vagrant = {
isNormalUser = true; isNormalUser = true;
group = "vagrant"; group = "vagrant";
extraGroups = [ "wheel" ]; extraGroups = [ "wheel" ];
password = "vagrant"; password = "vagrant";
}; };
security.sudo.extraRules = [ security.sudo.extraRules = [
{ {
users = [ "vagrant" ]; users = [ "vagrant" ];
groups = [ "vagrant" ]; groups = [ "vagrant" ];
commands = [ commands = [
{ command = "ALL"; options = [ "NOPASSWD" ]; } {
]; command = "ALL";
} options = [ "NOPASSWD" ];
]; }
];
}
];
boot.loader = { boot.loader = {
systemd-boot = { systemd-boot = {
enable = true; enable = true;
}; };
efi.canTouchEfiVariables = true; efi.canTouchEfiVariables = true;
}; };
networking = { networking = {
hostName = "vagrant"; hostName = "vagrant";
networkmanager.enable = true; networkmanager.enable = true;
#proxy.default = "http://user:password@proxy:port/"; #proxy.default = "http://user:password@proxy:port/";
#proxy.noProxy = "127.0.0.1,localhost,internal.domain"; #proxy.noProxy = "127.0.0.1,localhost,internal.domain";
}; };
time.timeZone = "UTC"; time.timeZone = "UTC";
i18n.defaultLocale = "en_US.UTF-8";
console = {
font = "Lat2-Terminux16";
keyMap = lib.mkForce "us";
useXkbConfig = true;
};
nix = { i18n.defaultLocale = "en_US.UTF-8";
package = pkgs.nixFlakes; console = {
settings = { font = "Lat2-Terminux16";
experimental-features = "nix-command flakes"; keyMap = lib.mkForce "us";
}; useXkbConfig = true;
}; };
nix = {
package = pkgs.nixFlakes;
settings = {
experimental-features = "nix-command flakes";
};
};
} }
+12 -11
View File
@@ -1,15 +1,16 @@
{ {
description = "A basic NixOS Vagrant install"; description = "A basic NixOS Vagrant install";
inputs = { inputs = {
nixstable.url = "github:nixos/nixpkgs/nixos-24.05"; nixstable.url = "github:nixos/nixpkgs/nixos-24.05";
}; };
outputs = { nixstable, self, ... }@inputs: outputs =
{ { nixstable, ... }:
nixosConfigurations.vagrant = nixstable.lib.nixosSystem { {
system = "x86_64-linux"; nixosConfigurations.vagrant = nixstable.lib.nixosSystem {
modules = [ ./configuration.nix ]; system = "x86_64-linux";
}; modules = [ ./configuration.nix ];
}; };
};
} }
-1
View File
@@ -1 +0,0 @@
ga-qemu.nix
+4
View File
@@ -0,0 +1,4 @@
{ ... }:
{
services.qemuGuest.enable = true;
}
+3 -3
View File
@@ -1,4 +1,4 @@
{...}: { ... }:
{ {
virtualisation.hypervGuest.enable = true; virtualisation.hypervGuest.enable = true;
} }
+4 -4
View File
@@ -1,6 +1,6 @@
{...}: { ... }:
{ {
virtualisation.virtualbox.guest = { virtualisation.virtualbox.guest = {
enable = true; enable = true;
}; };
} }
+3 -3
View File
@@ -1,4 +1,4 @@
{...}: { ... }:
{ {
services.qemuGuest.enable = true; services.qemuGuest.enable = true;
} }
+3 -3
View File
@@ -1,7 +1,7 @@
{...}: { ... }:
{ {
virtualisation.vmware.guest = { virtualisation.vmware.guest = {
enable = true; enable = true;
headless = false; headless = false;
} };
} }
+1 -1
View File
@@ -61,4 +61,4 @@ rm /mnt/root/in-chroot.sh
umount /mnt/boot umount /mnt/boot
umount /mnt umount /mnt
efibootmgr --bootnext "$(efibootmgr | grep Linux | awk '{print $1}' | sed -E 's/[^0-9]//g')" efibootmgr --bootnext "$(efibootmgr | grep Linux | awk '{print $1}' | sed -E 's/[^0-9]//g')"
reboot reboot
+1 -1
View File
@@ -1,2 +1,2 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
+1 -1
View File
@@ -1,2 +1,2 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
+1 -1
View File
@@ -1,2 +1,2 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
+17 -13
View File
@@ -1,13 +1,17 @@
[ { [
version = "23.05"; {
arch = "amd64"; version = "23.05";
eol = true; arch = "amd64";
} { eol = true;
version = "23.11"; }
arch = "amd64"; {
eol = true; version = "23.11";
} { arch = "amd64";
version = "24.05"; eol = true;
arch = "amd64"; }
eol = false; {
} ] version = "24.05";
arch = "amd64";
eol = false;
}
]
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
zypper clean -a zypper clean -a
+1 -1
View File
@@ -122,4 +122,4 @@ root ALL=(ALL) NOPASSWD: ALL
<file_location>https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub</file_location> <file_location>https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub</file_location>
</file> </file>
</files> </files>
</profile> </profile>
+1 -1
View File
@@ -1,2 +1,2 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
zypper clean -a zypper clean -a
+1 -1
View File
@@ -122,4 +122,4 @@ root ALL=(ALL) NOPASSWD: ALL
<file_location>https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub</file_location> <file_location>https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub</file_location>
</file> </file>
</files> </files>
</profile> </profile>
+1 -1
View File
@@ -1,2 +1,2 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
zypper clean -a zypper clean -a
+1 -1
View File
@@ -122,4 +122,4 @@ root ALL=(ALL) NOPASSWD: ALL
<file_location>https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub</file_location> <file_location>https://raw.githubusercontent.com/hashicorp/vagrant/master/keys/vagrant.pub</file_location>
</file> </file>
</files> </files>
</profile> </profile>
+1 -1
View File
@@ -1,2 +1,2 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
+22 -17
View File
@@ -1,17 +1,22 @@
[ { [
version = "15.5"; {
arch = "amd64"; version = "15.5";
eol = false; arch = "amd64";
} { eol = false;
version = "15.6"; }
arch = "amd64"; {
eol = false; version = "15.6";
} { arch = "amd64";
version = "16.0"; eol = false;
arch = "amd64"; }
eol = true; # Not yet released, and bugged at the moment {
} { version = "16.0";
version = "tumbleweed"; arch = "amd64";
arch = "amd64"; eol = true; # Not yet released, and bugged at the moment
eol = false; }
} ] {
version = "tumbleweed";
arch = "amd64";
eol = false;
}
]
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
zypper clean -a zypper clean -a
+1 -1
View File
@@ -1,2 +1,2 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
+1 -1
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -ex set -ex
dnf clean all dnf clean all
+12 -9
View File
@@ -1,9 +1,12 @@
[ { [
version = "8"; {
arch = "amd64"; version = "8";
eol = true; arch = "amd64";
} { eol = true;
version = "9"; }
arch = "amd64"; {
eol = false; version = "9";
} ] arch = "amd64";
eol = false;
}
]
+1 -1
View File
@@ -1,7 +1,7 @@
distro = "ubuntu" distro = "ubuntu"
version = "24.04" version = "24.04"
iso = { iso = {
url = "http://releases.ubuntu.com/24.04/ubuntu-24.04.01-live-server-amd64.iso" url = "http://releases.ubuntu.com/24.04/ubuntu-24.04.1-live-server-amd64.iso"
checksum = "e240e4b801f7bb68c20d1356b60968ad0c33a41d00d828e74ceb3364a0317be9" checksum = "e240e4b801f7bb68c20d1356b60968ad0c33a41d00d828e74ceb3364a0317be9"
} }
boot_command = [ boot_command = [
+32 -25
View File
@@ -1,25 +1,32 @@
[ { [
version = "18.04"; {
arch = "amd64"; version = "18.04";
eol = true; arch = "amd64";
} { eol = true;
version = "20.04"; }
arch = "amd64"; {
eol = false; version = "20.04";
} { arch = "amd64";
version = "22.04"; eol = false;
arch = "amd64"; }
eol = false; {
} { version = "22.04";
version = "23.10"; arch = "amd64";
arch = "amd64"; eol = false;
eol = true; }
} { {
version = "24.04"; version = "23.10";
arch = "amd64"; arch = "amd64";
eol = false; eol = true;
} { }
version = "24.10"; {
arch = "amd64"; version = "24.04";
eol = false; arch = "amd64";
} ] eol = false;
}
{
version = "24.10";
arch = "amd64";
eol = false;
}
]
Generated
+56 -85
View File
@@ -1,21 +1,18 @@
{ {
"nodes": { "nodes": {
"devshell": { "flake-compat": {
"inputs": { "flake": false,
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
},
"locked": { "locked": {
"lastModified": 1717408969, "lastModified": 1696426674,
"narHash": "sha256-Q0OEFqe35fZbbRPPRdrjTUUChKVhhWXz3T9ZSKmaoVY=", "narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "numtide", "owner": "edolstra",
"repo": "devshell", "repo": "flake-compat",
"rev": "1ebbe68d57457c8cae98145410b164b5477761f4", "rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "numtide", "owner": "edolstra",
"repo": "devshell", "repo": "flake-compat",
"type": "github" "type": "github"
} }
}, },
@@ -37,46 +34,55 @@
"type": "github" "type": "github"
} }
}, },
"flake-root": { "gitignore": {
"inputs": {
"nixpkgs": [
"hooks",
"nixpkgs"
]
},
"locked": { "locked": {
"lastModified": 1713493429, "lastModified": 1709087332,
"narHash": "sha256-ztz8JQkI08tjKnsTpfLqzWoKFQF4JGu2LRz8bkdnYUk=", "narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
"owner": "srid", "owner": "hercules-ci",
"repo": "flake-root", "repo": "gitignore.nix",
"rev": "bc748b93b86ee76e2032eecda33440ceb2532fcd", "rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "srid", "owner": "hercules-ci",
"repo": "flake-root", "repo": "gitignore.nix",
"type": "github" "type": "github"
} }
}, },
"flake-utils": { "hooks": {
"inputs": { "inputs": {
"systems": "systems" "flake-compat": "flake-compat",
"gitignore": "gitignore",
"nixpkgs": "nixpkgs",
"nixpkgs-stable": "nixpkgs-stable"
}, },
"locked": { "locked": {
"lastModified": 1701680307, "lastModified": 1731363552,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", "narHash": "sha256-vFta1uHnD29VUY4HJOO/D6p6rxyObnf+InnSMT4jlMU=",
"owner": "numtide", "owner": "cachix",
"repo": "flake-utils", "repo": "git-hooks.nix",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725", "rev": "cd1af27aa85026ac759d5d3fccf650abe7e1bbf0",
"type": "github" "type": "github"
}, },
"original": { "original": {
"owner": "numtide", "owner": "cachix",
"repo": "flake-utils", "repo": "git-hooks.nix",
"type": "github" "type": "github"
} }
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1704161960, "lastModified": 1730768919,
"narHash": "sha256-QGua89Pmq+FBAro8NriTuoO/wNaUtugt29/qqA8zeeM=", "narHash": "sha256-8AKquNnnSaJRXZxc5YmF/WfmxiHX6MMZZasRP6RRQkE=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "63143ac2c9186be6d9da6035fa22620018c85932", "rev": "a04d33c0c3f1a59a2c1cb0c6e34cd24500e5a1dc",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -98,6 +104,22 @@
"url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz" "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz"
} }
}, },
"nixpkgs-stable": {
"locked": {
"lastModified": 1730741070,
"narHash": "sha256-edm8WG19kWozJ/GqyYx2VjW99EdhjKwbY3ZwdlPAAlo=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "d063c1dd113c91ab27959ba540c0d9753409edf3",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-24.05",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1720750130, "lastModified": 1720750130,
@@ -114,22 +136,6 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_3": {
"locked": {
"lastModified": 1708475490,
"narHash": "sha256-g1v0TsWBQPX97ziznfJdWhgMyMGtoBFs102xSYO4syU=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "0e74ca98a74bc7270d28838369593635a5db3260",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"process-compose": { "process-compose": {
"locked": { "locked": {
"lastModified": 1718031437, "lastModified": 1718031437,
@@ -147,45 +153,10 @@
}, },
"root": { "root": {
"inputs": { "inputs": {
"devshell": "devshell",
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"flake-root": "flake-root", "hooks": "hooks",
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_2",
"process-compose": "process-compose", "process-compose": "process-compose"
"treefmt-nix": "treefmt-nix"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
},
"treefmt-nix": {
"inputs": {
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1718522839,
"narHash": "sha256-ULzoKzEaBOiLRtjeY3YoGFJMwWSKRYOic6VNw2UyTls=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "68eb1dc333ce82d0ab0c0357363ea17c31ea1f81",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
} }
} }
}, },
+167 -197
View File
@@ -1,205 +1,175 @@
# github.com/brianmcgee has lots of great ideas for going above and beyond for this # github.com/brianmcgee has lots of great ideas for going above and beyond for this
{ {
description = "Greg's homepage"; description = "Greg's homepage";
inputs = { inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
devshell.url = "github:numtide/devshell"; flake-parts.url = "github:hercules-ci/flake-parts";
flake-parts.url = "github:hercules-ci/flake-parts"; process-compose.url = "github:Platonic-Systems/process-compose-flake";
flake-root.url = "github:srid/flake-root"; hooks.url = "github:cachix/git-hooks.nix";
process-compose.url = "github:Platonic-Systems/process-compose-flake"; };
treefmt-nix.url = "github:numtide/treefmt-nix";
};
outputs = { devshell, flake-parts, flake-root, process-compose, treefmt-nix, nixpkgs, ... }@inputs: let outputs =
lib = nixpkgs.lib; { flake-parts, nixpkgs, ... }@inputs:
providers = [ let
"qemu" lib = nixpkgs.lib;
"virtualbox-iso" providers = [
"hyperv-iso" "qemu"
]; "virtualbox-iso"
distros = import ./distros; "hyperv-iso"
# Inserts the distro name into each element in the list ];
insertNames = lib.attrsets.mapAttrsToList (distro: val: (builtins.map (x: x // { inherit distro; }) val)) distros; distros = import ./distros;
# Flattens all the distros into a single list # Inserts the distro name into each element in the list
flat = lib.lists.flatten insertNames; insertNames = lib.attrsets.mapAttrsToList (
# Combines providers list with flattened list distro: val: (builtins.map (x: x // { inherit distro; }) val)
withProviders = lib.attrsets.mapCartesianProduct ) distros;
({d, provider}: d // { inherit provider; }) # Flattens all the distros into a single list
{ d = flat; provider = providers; }; flat = lib.lists.flatten insertNames;
active = builtins.filter (x: (x?eol) && (!x.eol)) withProviders; # Combines providers list with flattened list
name = d: "-${d.distro}-${d.arch}-${d.provider}-${d.version}"; withProviders = lib.attrsets.mapCartesianProduct ({ d, provider }: d // { inherit provider; }) {
distroFile = d: "distros/${d.distro}/${d.version}/${d.arch}.pkrvars.hcl"; d = flat;
cmd = d: '' provider = providers;
# This is a workaround for a goofy behavior in CI };
if [ -e "''${PACKER_CONFIG_DIR}" ]; then active = builtins.filter (
find "''${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";" x:
fi !(x.eol or false) && ((lib.lists.findFirstIndex (y: y == x.provider) (-1) (x.exclude or [ ])) == -1)
packer init sources ) withProviders;
packer build -only=${d.provider}.${d.arch} -var-file=${distroFile d}''; name = d: "-${d.distro}-${d.arch}-${d.provider}-${d.version}";
in flake-parts.lib.mkFlake { inherit inputs; } distroFile = d: "distros/${d.distro}/${d.version}/${d.arch}.pkrvars.hcl";
{ in
imports = [ flake-parts.lib.mkFlake { inherit inputs; } {
inputs.devshell.flakeModule flake = {
inputs.flake-root.flakeModule # Universal things
inputs.treefmt-nix.flakeModule };
]; systems = [
flake = { "x86_64-linux"
# Universal things "aarch64-linux"
}; ];
systems = [ perSystem =
"x86_64-linux" {
"aarch64-linux" pkgs,
]; self',
perSystem = { config, pkgs, self', system, ... }: system,
{ ...
_module.args.pkgs = import inputs.nixpkgs { }@inputs':
inherit system; {
config.allowUnfree = true; _module.args.pkgs = import inputs.nixpkgs {
}; inherit system;
# https://numtide.github.io/devshell/intro.html config.allowUnfree = true;
devshells.default = { };
# These commands will be shown in the motd that users read
# upon entering the shell
commands = [ {
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";
help = "Run shellchecks";
} {
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";
value = "${pkgs.OVMF.fd}/FV/";
} {
name = "PACKER_CONFIG_DIR";
value = "./packer_config";
} {
name = "STORAGE_URL";
value = "http://s3.thehellings.lan:9000";
} ];
};
# This is not special, this is just flakes devShells.default = pkgs.mkShell {
packages = let buildInputs = self'.checks.pre-commit.enabledPackages;
base = { shellHook = self'.checks.pre-commit.shellHook;
runtimeInputs = with pkgs; [
cdrtools
findutils
packer
qemu_full
vagrant
xorriso
];
};
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/
vagrant box add --provider ${vp d} ./output/${vp d}/${d.distro}-${d.version}.box --name test_box --force
'';
});
cibuild = d: pkgs.writeShellApplication (base // {
name = "ci${name d}";
text = ''
set -x
${cmd d} -except=upload sources/
'';
});
upload = d: pkgs.writeShellApplication (base // {
name = "upload${name d}";
text = ''
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;
cibuilds = lib.lists.foldr (d: acc: acc // { "ci${name d}" = (cibuild d); }) {} withProviders;
qemu_list = builtins.toJSON (builtins.map (d: { buildcmd = (name d); }) (builtins.filter (x: x.provider == "qemu") active));
vbox_list = builtins.toJSON (builtins.map (d: { buildcmd = (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 // cibuilds // {
continue = pkgs.writeText "continue.yml"
(builtins.replaceStrings ["QEMU_MATRIX" "VBOX_MATRIX" "HYPERV_MATRIX"] [qemu_list vbox_list hyperv_list]
(builtins.readFile ./.gitlab-ci-build.yml.in)
);
cache = pkgs.callPackage (import ./nix/cache.nix) { inherit active distroFile; };
validate = pkgs.callPackage (import ./nix/validate.nix) {};
cache-restore = pkgs.writeShellApplication {
name = "cache-restore";
runtimeInputs = with pkgs; [
jq
minio-client
packer
];
text = builtins.readFile ./cache-restore.sh;
};
generate = pkgs.writeShellApplication {
name = "generate";
runtimeInputs = with pkgs; [
bash
coreutils
curl
jq
pup
];
text = ''
shopt -s globstar
for vars in distros/**/*.pkrvars.hcl.sh; do
bash "./''${vars}"
done
set -x
echo "BUILD=$(date "+%Y.%m.%d.%H")" >> build.env
'';
};
shellcheck = pkgs.writeShellApplication {
name = "shellcheck";
runtimeInputs = with pkgs; [
shellcheck
];
text = ''
scripts=()
shopt -s globstar
for f in **/*.sh; do
scripts+=("$f")
done
shellcheck -e SC2239 "''${scripts[@]}"
'';
};
};
# https://numtide.github.io/treefmt/ packages =
treefmt.config = { (with pkgs; [
inherit (config.flake-root) projectRootFile; vagrant
package = pkgs.treefmt; ])
++ (with self'.packages; [
cache
generate
shellcheck
validate
])
++ (builtins.map (d: self'.packages."build${name d}") withProviders);
# These commands will be shown in the motd that users read
# upon entering the shell
env = {
EFI_DIR = "${pkgs.OVMF.fd}/FV/";
PACKER_CONFIG_DIR = "./packer_config";
STORAGE_URL = "http://s3.thehellings.lan:9000";
};
};
programs = { # This is not special, this is just flakes
deadnix.enable = true; packages =
}; let
base =
prefix: d: args:
pkgs.writeShellApplication {
name = "${prefix}${name d}";
runtimeInputs = with pkgs; [
cdrtools
findutils
packer
qemu_full
vagrant
xorriso
];
text = ''
# This is a workaround for a goofy behavior in CI
if [ -e "''${PACKER_CONFIG_DIR}" ]; then
find "''${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";"
fi
packer init sources
packer build -only=${d.provider}.${d.arch} -var-file=${distroFile d} ${args} sources/
'';
};
builds = lib.lists.foldr (
d: acc: acc // { "build${name d}" = (base "build" d "-except=upload -var headless=false"); }
) { } withProviders;
cibuilds = lib.lists.foldr (
d: acc: acc // { "ci${name d}" = (base "ci" d "-except=upload"); }
) { } withProviders;
uploads = lib.lists.foldr (
d: acc: acc // { "upload${name d}" = (base "upload" d ""); }
) { } withProviders;
qemu_list = builtins.map (d: { buildcmd = (name d); }) (
builtins.filter (x: x.provider == "qemu") active
);
vbox_list = builtins.map (d: { buildcmd = (name d); }) (
builtins.filter (x: x.provider == "virtualbox-iso") active
);
hyperv_list = builtins.map (d: { distro = distroFile d; }) (
builtins.filter (x: x.provider == "hyperv-iso") active
);
in
builds
// uploads
// cibuilds
// {
continue = (
import ./nix/continue.nix {
inherit
pkgs
qemu_list
vbox_list
hyperv_list
;
}
);
cache = pkgs.callPackage (import ./nix/cache.nix) { inherit active distroFile; };
validate = pkgs.callPackage (import ./nix/validate.nix) { };
cache-restore = pkgs.writeShellApplication {
name = "cache-restore";
runtimeInputs = with pkgs; [
jq
minio-client
packer
];
text = builtins.readFile ./cache-restore.sh;
};
generate = pkgs.callPackage (import ./nix/generate.nix) { };
shellcheck = pkgs.callPackage (import ./nix/shellcheck.nix) { };
};
settings.formatter = { checks = {
}; pre-commit = inputs.hooks.lib.${inputs'.system}.run {
}; src = ./.;
}; hooks = {
}; check-added-large-files.enable = true;
check-case-conflicts.enable = true;
check-merge-conflicts.enable = true;
check-symlinks.enable = true;
deadnix.enable = true;
end-of-file-fixer.enable = true;
fix-byte-order-marker.enable = true;
mixed-line-endings.enable = true;
nixfmt-rfc-style.enable = true;
trim-trailing-whitespace.enable = true;
};
};
};
};
};
} }
+40 -37
View File
@@ -1,44 +1,47 @@
{ {
writeShellApplication, writeShellApplication,
active, active,
distroFile, distroFile,
curl, curl,
minio-client, minio-client,
packer, packer,
... ...
}: }:
let let
inherit (builtins) concatStringsSep map; inherit (builtins) concatStringsSep map;
in writeShellApplication { in
name = "cache-isos"; writeShellApplication {
runtimeInputs = [ name = "cache-isos";
curl runtimeInputs = [
minio-client curl
packer minio-client
]; packer
text = '' ];
push="''${1:-yes}" text =
if [ "$push" == "yes" ]; then ''
mc alias set storage "$STORAGE_URL" root "$MINIO_SECRET" push="''${1:-yes}"
fi if [ "$push" == "yes" ]; then
mkdir -p cache mc alias set storage "$STORAGE_URL" root "$MINIO_SECRET"
'' + (concatStringsSep "\n" ( fi
map (d: '' mkdir -p cache
url=$(echo var.iso.url | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/) ''
sha=$(echo var.iso.checksum | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/) + (concatStringsSep "\n" (
distro=$(echo var.distro | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/) map (d: ''
# shellcheck disable=SC2143 url=$(echo var.iso.url | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/)
if [ -z "$(mc ls "storage/isos/cache/$distro" | grep "$sha")" ]; then sha=$(echo var.iso.checksum | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/)
curl -L --retry 3 --retry-all-errors -o "cache/$sha.iso" "$url" distro=$(echo var.distro | packer console -var-file="${distroFile d}" -config-type=hcl2 sources/)
if [ "$push" == "yes" ]; then # shellcheck disable=SC2143
mc put "cache/$sha.iso" "storage/isos/cache/$distro/$sha.iso" if [ -z "$(mc ls "storage/isos/cache/$distro" | grep "$sha")" ]; then
fi curl -L --retry 3 --retry-all-errors -o "cache/$sha.iso" "$url"
else if [ "$push" == "yes" ]; then
echo "Skipping ${d.distro} - cache/$sha.iso" mc put "cache/$sha.iso" "storage/isos/cache/$distro/$sha.iso"
fi fi
'') active else
)); echo "Skipping ${d.distro} - cache/$sha.iso"
fi
'') active
));
} }
+98
View File
@@ -0,0 +1,98 @@
{
pkgs,
qemu_list,
vbox_list,
hyperv_list,
...
}:
let
general = {
stage = "build";
cache = [
{
key = {
files = [ "sources/build.pkr.hcl" ];
};
paths = [ "./packer_config/" ];
}
];
rules = [
{
"if" = "$CI_COMMIT_TAG";
variables = {
EXCEPT = "";
JOB_PREFIX = "upload";
};
}
{
"if" = "$CI_COMMIT_TAG =~ \"/^$/\"";
variables = {
EXCEPT = "-except=upload";
JOB_PREIX = "ci";
};
}
];
needs = [
{
pipeline = "$PARENT_PIPELINE_ID";
job = "generate";
artifacts = true;
}
];
script = [
"nix run \".#\\\"\${JOB_PREIX}\${buildcmd}\\\"\" || exit 1"
];
};
variables = {
PACKER_CONFIG_DIR = "./packer_config/";
PACKER_CACHE_DIR = "./cache/";
PACKER_LOG = "1";
};
continue = {
stages = [
"build"
"release"
];
"qemu.amd64" = general // {
variables = variables // {
only = "-only=qemu.amd64";
};
tags = [ "qemu" ];
parallel = {
matrix = qemu_list;
};
before_script = [
"echo $BUILD"
"env"
];
};
"virtualbox-iso.amd64" = general // {
variables = variables // {
only = "-only=\"virtualbox-iso.amd64\"";
};
tags = [ "vbox" ];
parallel = {
matrix = vbox_list;
};
};
"hyperv-iso.amd64" = general // {
variables = variables // {
only = "-only=\"hyperv-iso.amd64\"";
};
tags = [ "hyperv" ];
parallel = {
matrix = hyperv_list;
};
script = [
"packer init sources"
"packer build -only=\"hyperv-iso.amd64\" -var-file=\"\${distro}\" -var build=\${BUILD} -var cpus=2 -var memory=4096 \${EXCEPT} sources"
"if (-not $?) { throw \"Error in build\" }"
];
};
};
in
pkgs.writeText "continue.yml" (builtins.toJSON continue)
+27
View File
@@ -0,0 +1,27 @@
{
writeShellApplication,
bash,
coreutils,
curl,
jq,
pup,
}:
writeShellApplication {
name = "generate";
runtimeInputs = [
bash
coreutils
curl
jq
pup
];
text = ''
shopt -s globstar
for vars in distros/**/*.pkrvars.hcl.sh; do
bash "./''${vars}"
done
set -x
echo "BUILD=$(date "+%Y.%m.%d.%H")" >> build.env
'';
}
+15
View File
@@ -0,0 +1,15 @@
{ writeShellApplication, shellcheck }:
writeShellApplication {
name = "shellcheck";
runtimeInputs = [
shellcheck
];
text = ''
scripts=()
shopt -s globstar
for f in **/*.sh; do
scripts+=("$f")
done
shellcheck -e SC2239 "''${scripts[@]}"
'';
}
+19 -19
View File
@@ -1,23 +1,23 @@
{ {
writeShellApplication, writeShellApplication,
findutils, findutils,
packer, packer,
... ...
}: }:
writeShellApplication { writeShellApplication {
name = "validate"; name = "validate";
runtimeInputs = [ runtimeInputs = [
findutils findutils
packer packer
]; ];
text = '' text = ''
shopt -s globstar shopt -s globstar
if [ -e "''${PACKER_CONFIG_DIR}" ]; then if [ -e "''${PACKER_CONFIG_DIR}" ]; then
find "''${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";" find "''${PACKER_CONFIG_DIR}" -name '*_linux_amd64' -exec chmod +x '{}' ";"
fi fi
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/
done done
''; '';
} }
+9 -4
View File
@@ -22,9 +22,14 @@ elif [ -n "$swap_device_label" ]; then
fi fi
if [ -n "${swap_device}" ] && [ -e "${swap_device}" ]; then if [ -n "${swap_device}" ] && [ -e "${swap_device}" ]; then
sudo /sbin/swapoff "$swap_device" case ${swap_device} in
sudo dd if=/dev/zero of="$swap_device" bs=1M || : "/dev/zram"*) ;;
sudo /sbin/mkswap ${swap_device_label:+-L "$swap_device_label"} ${swap_device_uuid:+-U "$swap_device_uuid"} "$swap_device" *)
sudo /sbin/swapoff "$swap_device"
sudo dd if=/dev/zero of="$swap_device" bs=1M || :
sudo /sbin/mkswap ${swap_device_label:+-L "$swap_device_label"} ${swap_device_uuid:+-U "$swap_device_uuid"} "$swap_device"
;;
esac
fi fi
sleep 15 # Hyper-v seems to be super fast during boot sleep 15 # Hyper-v seems to be super fast during boot