2022-06-12 15:39:15 +00:00
|
|
|
{
|
|
|
|
pkgs,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
system,
|
|
|
|
...
|
2023-10-09 15:17:39 +00:00
|
|
|
}: {
|
2022-01-27 16:16:42 +00:00
|
|
|
imports = [
|
|
|
|
./workarounds
|
|
|
|
];
|
2022-01-14 13:03:14 +00:00
|
|
|
nixpkgs.config.allowUnfree = true;
|
|
|
|
nix = {
|
2022-02-08 08:55:28 +00:00
|
|
|
settings = {
|
|
|
|
sandbox = true;
|
2023-01-14 19:58:07 +00:00
|
|
|
trusted-users = ["@wheel" "remote-build"];
|
2022-04-12 09:37:53 +00:00
|
|
|
require-sigs = true;
|
2022-02-08 09:48:37 +00:00
|
|
|
builders-use-substitutes = true;
|
2022-03-03 07:50:45 +00:00
|
|
|
substituters = [
|
2023-11-03 14:08:41 +00:00
|
|
|
"https://cache.chir.rs/"
|
2023-05-31 15:07:03 +00:00
|
|
|
"https://hydra.int.chir.rs"
|
2022-04-12 09:33:58 +00:00
|
|
|
];
|
|
|
|
trusted-public-keys = [
|
|
|
|
"nixcache:8KKuGz95Pk4UJ5W/Ni+pN+v+LDTkMMFV4yrGmAYgkDg="
|
|
|
|
"hydra.nixos.org-1:CNHJZBh9K4tP3EKF6FkkgeVYsS3ohTl+oS0Qa8bezVs="
|
2023-10-09 15:20:21 +00:00
|
|
|
"chir-rs:/iTDNHmQw1HklELHTBAVDFVAFaJ3ACGu3eezVUtplKc="
|
2023-03-05 20:51:07 +00:00
|
|
|
"riscv:TZX1ReuoIGt7QiSQups+92ym8nKJUSV0O2NkS4HAqH8="
|
2023-06-18 06:22:04 +00:00
|
|
|
"cache.ztier.link-1:3P5j2ZB9dNgFFFVkCQWT3mh0E+S3rIWtZvoql64UaXM="
|
2022-03-03 07:50:45 +00:00
|
|
|
];
|
2023-01-17 10:02:41 +00:00
|
|
|
auto-optimise-store = true;
|
2022-02-08 08:55:28 +00:00
|
|
|
};
|
2022-09-13 17:27:49 +00:00
|
|
|
package = pkgs.nix;
|
2022-01-14 13:03:14 +00:00
|
|
|
extraOptions = ''
|
2022-04-18 14:07:18 +00:00
|
|
|
experimental-features = nix-command flakes ca-derivations
|
2022-01-14 13:03:14 +00:00
|
|
|
'';
|
|
|
|
gc = {
|
|
|
|
automatic = true;
|
|
|
|
dates = "weekly";
|
|
|
|
options = "--delete-older-than 7d";
|
|
|
|
};
|
2023-05-21 17:32:58 +00:00
|
|
|
buildMachines = with lib;
|
|
|
|
mkMerge [
|
|
|
|
(mkIf (config.networking.hostName != "instance-20221213-1915") [
|
|
|
|
{
|
|
|
|
hostName = "build-aarch64";
|
|
|
|
systems = [
|
|
|
|
"aarch64-linux"
|
2023-10-19 08:02:43 +00:00
|
|
|
"riscv32-linux"
|
|
|
|
"riscv64-linux"
|
2023-05-21 17:32:58 +00:00
|
|
|
];
|
|
|
|
maxJobs = 4;
|
|
|
|
speedFactor = 1;
|
|
|
|
supportedFeatures = ["nixos-test" "benchmark" "ca-derivations" "gccarch-armv8-a" "gccarch-armv8.1-a" "gccarch-armv8.2-a" "big-parallel"];
|
|
|
|
}
|
|
|
|
])
|
2023-10-19 08:02:43 +00:00
|
|
|
(mkIf (config.networking.hostName != "nas") [
|
|
|
|
{
|
|
|
|
hostName = "build-nas";
|
|
|
|
systems = [
|
|
|
|
"armv7l-linux"
|
|
|
|
"powerpc-linux"
|
|
|
|
"powerpc64-linux"
|
|
|
|
"powerpc64le-linux"
|
|
|
|
"wasm32-wasi"
|
|
|
|
"riscv32-linux"
|
|
|
|
"riscv64-linux"
|
|
|
|
];
|
|
|
|
maxJobs = 12;
|
|
|
|
speedFactor = 1;
|
|
|
|
supportedFeatures = [
|
|
|
|
"kvm"
|
|
|
|
"nixos-test"
|
|
|
|
"big-parallel"
|
|
|
|
"benchmark"
|
|
|
|
"gccarch-znver1"
|
|
|
|
"gccarch-skylake"
|
|
|
|
"ca-derivations"
|
|
|
|
];
|
|
|
|
}
|
|
|
|
])
|
|
|
|
(mkIf (config.networking.hostName != "nutty-noon") [
|
|
|
|
{
|
|
|
|
hostName = "build-pc";
|
|
|
|
systems = [
|
|
|
|
"armv7l-linux"
|
|
|
|
"powerpc-linux"
|
|
|
|
"powerpc64-linux"
|
|
|
|
"powerpc64le-linux"
|
|
|
|
"wasm32-wasi"
|
|
|
|
"riscv32-linux"
|
|
|
|
"riscv64-linux"
|
|
|
|
];
|
|
|
|
maxJobs = 16;
|
|
|
|
speedFactor = 1;
|
|
|
|
supportedFeatures = [
|
|
|
|
"kvm"
|
|
|
|
"nixos-test"
|
|
|
|
"big-parallel"
|
|
|
|
"benchmark"
|
|
|
|
"gccarch-znver2"
|
|
|
|
"gccarch-znver1"
|
|
|
|
"gccarch-skylake"
|
|
|
|
"ca-derivations"
|
|
|
|
];
|
|
|
|
}
|
|
|
|
])
|
|
|
|
(mkIf (config.networking.hostName != "vf2") [
|
|
|
|
{
|
|
|
|
hostName = "build-riscv";
|
|
|
|
systems = [
|
|
|
|
"riscv32-linux"
|
|
|
|
"riscv64-linux"
|
|
|
|
];
|
|
|
|
maxJobs = 4;
|
|
|
|
speedFactor = 2;
|
|
|
|
supportedFeatures = [
|
|
|
|
"nixos-test"
|
|
|
|
"big-parallel"
|
|
|
|
"benchmark"
|
|
|
|
"ca-derivations"
|
|
|
|
# There are many more combinations but i simply do not care lol
|
|
|
|
"gccarch-rv64gc_zba_zbb"
|
|
|
|
"gccarch-rv64gc_zba"
|
|
|
|
"gccarch-rv64gc_zbb"
|
|
|
|
"gccarch-rv64gc"
|
|
|
|
"gccarch-rv32gc_zba_zbb"
|
|
|
|
"gccarch-rv32gc_zba"
|
|
|
|
"gccarch-rv32gc_zbb"
|
|
|
|
"gccarch-rv32gc"
|
|
|
|
"native-riscv"
|
|
|
|
];
|
|
|
|
}
|
|
|
|
])
|
2023-05-21 17:32:58 +00:00
|
|
|
];
|
2022-02-08 09:48:37 +00:00
|
|
|
distributedBuilds = true;
|
2022-01-14 13:03:14 +00:00
|
|
|
};
|
2023-07-08 07:14:28 +00:00
|
|
|
systemd.services.nix-daemon.environment.TMPDIR = "/build";
|
|
|
|
systemd.services.nixos-upgrade = {
|
|
|
|
description = "NixOS Upgrade";
|
|
|
|
|
|
|
|
restartIfChanged = false;
|
|
|
|
unitConfig.X-StopOnRemoval = false;
|
|
|
|
|
|
|
|
serviceConfig.Type = "oneshot";
|
|
|
|
|
|
|
|
path = with pkgs; [
|
|
|
|
coreutils
|
|
|
|
gnutar
|
|
|
|
xz.bin
|
|
|
|
gzip
|
|
|
|
gitMinimal
|
|
|
|
config.nix.package.out
|
|
|
|
config.programs.ssh.package
|
|
|
|
jq
|
|
|
|
curl
|
2022-01-14 13:07:01 +00:00
|
|
|
];
|
2023-07-08 07:14:28 +00:00
|
|
|
|
2023-07-09 17:17:46 +00:00
|
|
|
script = lib.mkDefault ''
|
|
|
|
#!${pkgs.bash}/bin/bash
|
|
|
|
|
|
|
|
set -ex
|
|
|
|
|
2023-07-22 07:03:17 +00:00
|
|
|
builds=$(${pkgs.curl}/bin/curl -H 'accept: application/json' https://hydra.int.chir.rs/jobset/flakes/nixos-config/evals | ${pkgs.jq}/bin/jq -r '.evals[0].builds[]')
|
2023-07-09 17:17:46 +00:00
|
|
|
|
|
|
|
for build in $builds; do
|
|
|
|
doc=$(${pkgs.curl}/bin/curl -H 'accept: application/json' https://hydra.int.chir.rs/build/$build)
|
|
|
|
jobname=$(echo $doc | ${pkgs.jq}/bin/jq -r '.job')
|
|
|
|
if [ "$jobname" = "${config.networking.hostName}.${system}" ]; then
|
|
|
|
drvname=$(echo $doc | ${pkgs.jq}/bin/jq -r '.drvpath')
|
|
|
|
output=$(${pkgs.nix}/bin/nix-store -r $drvname)
|
|
|
|
$output/bin/switch-to-configuration boot
|
|
|
|
booted="$(${pkgs.coreutils}/bin/readlink /run/booted-system/{initrd,kernel,kernel-modules})"
|
|
|
|
built="$(${pkgs.coreutils}/bin/readlink /nix/var/nix/profiles/system/{initrd,kernel,kernel-modules})"
|
|
|
|
if [ "$booted" = "$built" ]; then
|
|
|
|
$output/bin/switch-to-configuration switch
|
|
|
|
else
|
|
|
|
${pkgs.systemd}/bin/shutdown -r +1
|
|
|
|
fi
|
|
|
|
exit
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
'';
|
2023-07-08 07:14:28 +00:00
|
|
|
after = ["network-online.target"];
|
|
|
|
wants = ["network-online.target"];
|
|
|
|
};
|
|
|
|
systemd.timers.nixos-upgrade = {
|
|
|
|
timerConfig = {
|
|
|
|
OnBootSec = 300;
|
|
|
|
RandomizedDelaySec = 3600;
|
2023-07-11 16:44:45 +00:00
|
|
|
OnUnitActiveSec = 3600;
|
2023-07-08 07:14:28 +00:00
|
|
|
};
|
2023-07-08 18:24:41 +00:00
|
|
|
requires = ["nixos-upgrade.service"];
|
2023-07-08 07:14:28 +00:00
|
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
};
|
|
|
|
systemd.sockets.nixos-upgrade = {
|
|
|
|
socketConfig = {
|
|
|
|
Service = "nixos-upgrade.service";
|
|
|
|
BindIPv6Only = true;
|
|
|
|
ListenDatagram = "[::]:15553";
|
|
|
|
};
|
2022-01-14 13:07:01 +00:00
|
|
|
};
|
2022-01-14 13:03:14 +00:00
|
|
|
}
|