Something went wrong. Try again.
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283# quine.de side: every Saturday night build the latest main of the Pi system and publish it as a# signed static binary cache on its own vhost, behind basic auth (Nix can do netrc, not client# certificates). nixpkgs comes from the repo's flake.lock: bumping it is a deliberate step,# since each bump means hours of armv6l builds and possibly new test failures. Needs# extra-platforms = armv6l-linux and the gccarch-armv6kz system feature on the host.{ config, lib, pkgs, ...}:let cfg = config.services.inkling-cache; dir = "/var/lib/inkling";in{ options.services.inkling-cache = { flake = lib.mkOption { type = lib.types.str; default = "git+https://tangled.org/quine.de/inkling"; }; virtualHost = lib.mkOption { type = lib.types.str; default = "inkling.quine.de"; }; secretKeyFile = lib.mkOption { type = lib.types.path; description = "Nix signing key; its public half is cachePublicKey in configuration.nix."; }; htpasswdFile = lib.mkOption { type = lib.types.path; description = "nginx basic auth file; the Pi has the matching netrc."; }; };
config = { users.users.inkling = { isSystemUser = true; group = "inkling"; }; users.groups.inkling = { }; nix.settings.allowed-users = [ "inkling" ];
systemd.services.inkling-cache = { startAt = "Sat 03:00"; path = [ config.nix.package pkgs.git ]; environment.XDG_CACHE_HOME = "/var/cache/inkling"; serviceConfig = { Type = "oneshot"; User = "inkling"; StateDirectory = "inkling"; CacheDirectory = "inkling"; }; script = '' cd ${dir} nix build --refresh --out-link system \ '${cfg.flake}#nixosConfigurations.inkling.config.system.build.toplevel' out=$(readlink system)
# Root the build-time closure too: without it the weekly nix-gc would make every # build start again from gcc (nothing armv6l is on cache.nixos.org). mapfile -t deps < <(nix-store -qR --include-outputs "$(nix-store -qd "$out")" | grep -v '\.drv$') rm -rf roots && mkdir roots nix-store --add-root roots/r --indirect --realise "''${deps[@]}" > /dev/null
# Fresh cache each week instead of pruning old paths. rm -rf cache.new nix copy --to "file://${dir}/cache.new?compression=zstd&secret-key=${cfg.secretKeyFile}" "$out" echo "$out" > cache.new/latest rm -rf cache.old; [ ! -e cache ] || mv cache cache.old; mv cache.new cache; rm -rf cache.old ''; };
services.nginx.virtualHosts.${cfg.virtualHost} = { basicAuthFile = cfg.htpasswdFile; root = "${dir}/cache"; }; };}