43 lines
991 B
Nix
43 lines
991 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 = "oneshot";
|
||
|
ExecStart = "${build-flake-script}/bin/build-flake-script";
|
||
|
};
|
||
|
};
|
||
|
systemd.timers."build-flakes" = {
|
||
|
enable = true;
|
||
|
wantedBy = [ "timers.target" ];
|
||
|
timerConfig = {
|
||
|
OnCalendar = "Sun 06:00:00";
|
||
|
};
|
||
|
};
|
||
|
}
|