nixos-servers/services/nix-cache/build-flakes.nix
Torjus Håkestad 006d0b9213
Some checks failed
Run nix flake check / flake-check (push) Failing after 4m3s
Finish nix-cache
2025-01-24 15:48:03 +01:00

43 lines
989 B
Nix

{ 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 = "exec";
ExecStart = "${build-flake-script}/bin/build-flake-script";
};
};
systemd.timers."build-flakes" = {
enable = true;
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "*-*-* *:30:00";
};
};
}