prebuild: add gaming closure, stagger timers
This commit is contained in:
parent
b55d6de636
commit
55dc95dd2b
1 changed files with 48 additions and 28 deletions
|
|
@ -1,39 +1,59 @@
|
||||||
# services/prebuild.nix — nightly pre-build of the Macbook's system closure.
|
# services/prebuild.nix — nightly pre-build of the other hosts' system closures.
|
||||||
#
|
#
|
||||||
# The Macbook runs with max-jobs = 0 and offloads every build to this host
|
# Both laptops/desktops offload builds to this host (nix.buildMachines in
|
||||||
# (nix.buildMachines in common.nix). Realising its toplevel here ahead of time
|
# common.nix), and the Macbook can't build at all (max-jobs = 0). Realising
|
||||||
# turns `update` on the laptop into a pure copy: the offloaded build finds the
|
# their toplevels here ahead of time turns `update` on those machines into a
|
||||||
# path already in this store and just ships it back over SSH.
|
# pure copy: the offloaded build finds the path already in this store and just
|
||||||
|
# ships it back over SSH.
|
||||||
#
|
#
|
||||||
# --out-link doubles as the gc root, so `clean` doesn't reap the closure
|
# --out-link doubles as the gc root, so `clean` doesn't reap the closures
|
||||||
# before the laptop ever asks for it.
|
# before the other machines ever ask for them.
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
let
|
||||||
|
mkService = host: {
|
||||||
|
description = "Pre-build the ${host} system closure";
|
||||||
|
after = [ "network-online.target" ];
|
||||||
|
wants = [ "network-online.target" ];
|
||||||
|
path = [ pkgs.git ];
|
||||||
|
environment.HOME = "/root";
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
StateDirectory = "prebuild";
|
||||||
|
};
|
||||||
|
# Gaming's kernel comes from lantian's attic (see hosts/hardware/
|
||||||
|
# FredOS-Gaming.nix). That substituter isn't configured on this host, so
|
||||||
|
# without it the cachyos kernel gets built from source here instead of
|
||||||
|
# fetched — hours, not minutes. Harmless for the Macbook.
|
||||||
|
script = ''
|
||||||
|
${config.nix.package}/bin/nix build --refresh \
|
||||||
|
--option extra-substituters https://attic.xuyh0120.win/lantian \
|
||||||
|
--option extra-trusted-public-keys lantian:EeAUQ+W+6r7EtwnmYjeVwx5kOGEBpjlBfPlzGlTNvHc= \
|
||||||
|
--out-link /var/lib/prebuild/${host} \
|
||||||
|
'git+https://forg.gregersen.it/rope/nixos#nixosConfigurations.${host}.config.system.build.toplevel'
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
# Staggered so the two builds don't fight over cores and bandwidth.
|
||||||
|
mkTimer = startAt: {
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
timerConfig = {
|
||||||
|
OnCalendar = startAt;
|
||||||
|
Persistent = true;
|
||||||
|
RandomizedDelaySec = "20m";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
{
|
{
|
||||||
config = lib.mkIf (config.networking.hostName == "FredOS-Mediaserver") {
|
config = lib.mkIf (config.networking.hostName == "FredOS-Mediaserver") {
|
||||||
systemd.services.prebuild-macbook = {
|
systemd.services = {
|
||||||
description = "Pre-build the FredOS-Macbook system closure";
|
prebuild-macbook = mkService "FredOS-Macbook";
|
||||||
after = [ "network-online.target" ];
|
prebuild-gaming = mkService "FredOS-Gaming";
|
||||||
wants = [ "network-online.target" ];
|
|
||||||
path = [ pkgs.git ];
|
|
||||||
environment.HOME = "/root";
|
|
||||||
serviceConfig = {
|
|
||||||
Type = "oneshot";
|
|
||||||
StateDirectory = "prebuild";
|
|
||||||
};
|
|
||||||
script = ''
|
|
||||||
${config.nix.package}/bin/nix build --refresh --out-link /var/lib/prebuild/FredOS-Macbook \
|
|
||||||
'git+https://forg.gregersen.it/rope/nixos#nixosConfigurations.FredOS-Macbook.config.system.build.toplevel'
|
|
||||||
'';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
systemd.timers.prebuild-macbook = {
|
systemd.timers = {
|
||||||
wantedBy = [ "timers.target" ];
|
prebuild-macbook = mkTimer "04:00";
|
||||||
timerConfig = {
|
prebuild-gaming = mkTimer "05:00";
|
||||||
OnCalendar = "04:00";
|
|
||||||
Persistent = true;
|
|
||||||
RandomizedDelaySec = "30m";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue