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

69 lines
1.3 KiB
Nix
Raw Normal View History

{
config,
nix-eval-jobs,
nix-fast-build,
pkgs,
...
}: let
inherit (config.vars) mainUser;
inherit (config.sops) secrets;
2024-05-29 21:18:50 -04:00
nix-eval-jobsPkg =
nix-eval-jobs.packages.${pkgs.system}.default.override {
nix = config.nix.package;
}
// {
nix = config.nix.package;
};
nix-fast-buildPkg = nix-fast-build.packages.${pkgs.system}.nix-fast-build.override {
2024-05-29 21:18:50 -04:00
nix-eval-jobs = nix-eval-jobsPkg;
};
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"];
};
};
}