nixos-configs/devices/servivi/modules/binary-cache.nix
matt1432 f969c050cf
All checks were successful
Discord / discord commits (push) Successful in 1m13s
feat(servers): add self-hosted bin cache
2023-12-26 00:48:43 -05:00

43 lines
969 B
Nix

{
config,
pkgs,
nixpkgs,
...
}: let
secrets = config.sops.secrets;
vars = config.vars;
in {
services.nix-serve = {
enable = true;
secretKeyFile = secrets.binary-cache-key.path;
};
systemd = {
services.buildAll = {
serviceConfig = {
Type = "oneshot";
User = vars.user;
Group = config.users.users.${vars.user}.group;
};
script = ''
cd /tmp
${pkgs.nix}/bin/nix-shell \
-I "nixpkgs=${nixpkgs}" \
-p openssh nix git nixci --run \
"${builtins.concatStringsSep "; " [
"git clone https://git.nelim.org/matt1432/nixos-configs.git nix-clone"
"cd nix-clone"
"nix flake update"
"nixci ."
"cd .."
"rm -r nix-clone"
]}"
'';
};
timers.buildAll = {
wantedBy = ["timers.target"];
partOf = ["buildAll.service"];
timerConfig.OnCalendar = ["*-*-* 0:00:00"];
};
};
}