nixos-configs/devices/servivi/modules/binary-cache.nix

66 lines
1.3 KiB
Nix
Raw Normal View History

{
config,
nix-fast-build,
pkgs,
...
}: let
inherit (config.vars) mainUser;
inherit (config.sops) secrets;
nix-fast-buildPkg = nix-fast-build.packages.${pkgs.system}.nix-fast-build.override {
2024-07-23 21:40:13 -04:00
nix-eval-jobs =
2024-07-24 21:58:37 -04:00
pkgs.nix-eval-jobs.override {
nix = config.nix.package;
}
2024-07-23 21:40:13 -04:00
// {
nix = config.nix.package;
};
};
in {
services.nix-serve = {
enable = true;
secretKeyFile = secrets.binary-cache-key.path;
};
environment.systemPackages = [
nix-fast-buildPkg
2024-04-14 15:02:19 -04:00
];
# Populate cache
systemd = {
services.buildAll = {
serviceConfig = {
Type = "oneshot";
User = mainUser;
Group = config.users.users.${mainUser}.group;
};
2024-05-04 20:43:07 -04:00
path =
[
nix-fast-buildPkg
]
++ (with pkgs; [
git
openssh
]);
script = ''
cd /tmp
2024-01-30 14:56:47 -05:00
if [[ -d ./nix-clone ]]; then
rm -r ./nix-clone
fi
git clone https://git.nelim.org/matt1432/nixos-configs.git nix-clone
cd nix-clone
nix-fast-build
cd ..
rm -r nix-clone
'';
};
timers.buildAll = {
wantedBy = ["timers.target"];
partOf = ["buildAll.service"];
timerConfig.OnCalendar = ["0:00:00"];
};
};
}