nix/module/RemoteBuilder.nix

20 lines
583 B
Nix
Raw Normal View History

2024-03-10 07:54:10 +03:00
{ pkgs, ... }: let
keyPath = "/root/.nixcache";
in {
systemd.services.generate-nix-cache-key = {
wantedBy = [ "multi-user.target" ];
serviceConfig.Type = "oneshot";
path = [ pkgs.nix ];
script = ''
[[ -f "${keyPath}/private-key" ]] && exit
mkdir ${keyPath} || true
nix-store --generate-binary-cache-key "$HOSTNAME-1" "${keyPath}/private-key" "${keyPath}/public-key"
2024-03-10 08:00:13 +03:00
nix store sign --all -k "${keyPath}/private-key"
2024-03-10 07:54:10 +03:00
'';
};
2024-03-10 06:46:02 +03:00
# To apply: nix store sign --all -k /path/to/secret-key-file
2024-03-09 18:38:41 +03:00
nix.extraOptions = ''
2024-03-10 08:00:13 +03:00
secret-key-files = ${keyPath}/private-key
2024-03-09 18:38:41 +03:00
'';
}