baremetal-builders: more 'intelligent' gc
This commit is contained in:
parent
bd8aa2eb08
commit
15a684c5d7
|
@ -146,14 +146,23 @@ in
|
|||
};
|
||||
|
||||
systemd.services.hydra-gc = {
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
description = "Nix Garbage Collector";
|
||||
script = "exec ${config.nix.package.out}/bin/nix-store --gc --store /mnt";
|
||||
script = ''
|
||||
while : ; do
|
||||
percent_filled=$(($(stat -f --format="100-(100*%a/%b)" /)))
|
||||
if [ "$percent_filled" -gt "85" ]; then
|
||||
${config.nix.package.out}/bin/nix-store --gc --max-freed 100G --store /mnt
|
||||
else
|
||||
break
|
||||
fi
|
||||
done
|
||||
'';
|
||||
serviceConfig.Type = "oneshot";
|
||||
serviceConfig.User = "builder";
|
||||
};
|
||||
systemd.timers.hydra-gc = {
|
||||
timerConfig.OnStartupSec = "4h";
|
||||
timerConfig.OnUnitActiveSec = "20h";
|
||||
timerConfig.OnUnitInactiveSec = "10min";
|
||||
wantedBy = [ "timers.target" ];
|
||||
};
|
||||
systemd.timers.hydra-gc.timerConfig.Persistent = true;
|
||||
|
|
Loading…
Reference in a new issue