48 lines
1.3 KiB
Nix
48 lines
1.3 KiB
Nix
|
{ config, lib, pkgs, ... }:
|
||
|
{
|
||
|
|
||
|
# nixpkgs.config.packageOverrides = p: {
|
||
|
# nix-serve = p.haskellPackages.nix-serve-ng;
|
||
|
# };
|
||
|
|
||
|
# generate private key with:
|
||
|
# nix-store --generate-binary-cache-key my-secret-key my-public-key
|
||
|
clan.core.facts.services."nix-serve" = {
|
||
|
secret."nix-serve.key" = { };
|
||
|
public."nix-serve.pub" = { };
|
||
|
generator.path = with pkgs; [ coreutils nix ];
|
||
|
generator.script = ''
|
||
|
nix-store --generate-binary-cache-key "cache.${config.networking.hostName}.wg0" nix-serve.key nix-serve.pub
|
||
|
mv nix-serve.key "$secrets"/nix-serve.key
|
||
|
mv nix-serve.pub "$facts"/nix-serve.pub
|
||
|
'';
|
||
|
};
|
||
|
|
||
|
services.nix-serve = {
|
||
|
enable = true;
|
||
|
secretKeyFile = config.clan.core.facts.services.nix-serve.secret."nix-serve.key".path;
|
||
|
port = 5005;
|
||
|
};
|
||
|
|
||
|
services.nginx = {
|
||
|
enable = true;
|
||
|
virtualHosts."cache.${config.networking.hostName}.wg0" = {
|
||
|
locations."/".extraConfig = ''
|
||
|
proxy_pass http://localhost:${toString config.services.nix-serve.port};
|
||
|
allow ${config.wireguard.wg0.subnet};
|
||
|
deny all;
|
||
|
'';
|
||
|
locations."= /nix-cache-info".extraConfig = ''
|
||
|
alias ${pkgs.writeText "cache-info" ''
|
||
|
StoreDir: /nix/store
|
||
|
WantMassQuery: 1
|
||
|
Priority: 42
|
||
|
''};
|
||
|
allow ${config.wireguard.wg0.subnet};
|
||
|
deny all;
|
||
|
'';
|
||
|
};
|
||
|
};
|
||
|
}
|
||
|
|