Add build-flakes script for nix-cache
Some checks failed
Run nix flake check / flake-check (push) Failing after 4m20s

This commit is contained in:
Torjus Håkestad 2025-01-24 01:12:14 +01:00
parent 5ef2b3aafa
commit e70e892ab2
Signed by: torjus
SSH Key Fingerprint: SHA256:KjAds8wHfD2mBYK2H815s/+ABcSdcIHUndwHEdSxml4
4 changed files with 50 additions and 0 deletions

View File

@ -2,5 +2,6 @@
{
imports = [
./configuration.nix
../../services/nix-cache
];
}

View File

@ -138,6 +138,7 @@
"ns2.home.2rjus.net:9100"
"http-proxy.home.2rjus.net:9100"
"ha1.home.2rjus.net:9100"
"nix-cache01.home.2rjus.net:9100"
];
}
];

View File

@ -0,0 +1,42 @@
{ pkgs, ... }:
let
build-flake-script = pkgs.writeShellApplication {
name = "build-flake-script";
runtimeInputs = with pkgs; [
git
nix
nixos-rebuild
jq
];
text = ''
cd /root/nixos-servers
git pull
echo "Starting nixos-servers builds"
for host in $(nix flake show --json| jq -r '.nixosConfigurations | keys[]'); do
echo "Building $host"
nixos-rebuild --verbose -L --flake ".#$host" build
done
echo "All nixos-servers builds complete"
echo "Building gunter"
cd /root/nixos
git pull
nixos-rebuild --verbose -L --flake ".#gunter" build
'';
};
in
{
systemd.services."build-flakes" = {
serviceConfig = {
Type = "oneshot";
ExecStart = "${build-flake-script}/bin/build-flake-script";
};
};
systemd.timers."build-flakes" = {
enable = true;
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "Sun 06:00:00";
};
};
}

View File

@ -0,0 +1,6 @@
{ ... }:
{
imports = [
./build-flakes.nix
];
}