parent
83ef3a0b9b
commit
9a33ca1283
1 changed files with 18 additions and 22 deletions
|
@ -4,12 +4,11 @@
|
||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
let
|
||||||
|
port = 5005;
|
||||||
|
in
|
||||||
{
|
{
|
||||||
|
|
||||||
# nixpkgs.config.packageOverrides = p: {
|
|
||||||
# nix-serve = p.haskellPackages.nix-serve-ng;
|
|
||||||
# };
|
|
||||||
|
|
||||||
# generate private key with:
|
# generate private key with:
|
||||||
# nix-store --generate-binary-cache-key my-secret-key my-public-key
|
# nix-store --generate-binary-cache-key my-secret-key my-public-key
|
||||||
clan.core.facts.services."nix-serve" = {
|
clan.core.facts.services."nix-serve" = {
|
||||||
|
@ -26,34 +25,31 @@
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
services.nix-serve = {
|
services.harmonia = {
|
||||||
enable = true;
|
enable = true;
|
||||||
secretKeyFile = config.clan.core.facts.services.nix-serve.secret."nix-serve.key".path;
|
signKeyPaths = [ config.clan.core.facts.services.nix-serve.secret."nix-serve.key".path ];
|
||||||
port = 5005;
|
settings = {
|
||||||
|
bind = "127.0.0.1:${toString port}";
|
||||||
|
priority = 100;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
healthchecks.closed.public.ports.nix-serve = [ config.services.nix-serve.port ];
|
healthchecks.closed.public.ports.nix-cache = [ port ];
|
||||||
healthchecks.http.nix-serve = {
|
healthchecks.http.nix-cache = {
|
||||||
url = "cache.${config.networking.hostName}.wg0/nix-cache-info";
|
url = "cache.${config.networking.hostName}.wg0/nix-cache-info";
|
||||||
expectedContent = "Priority: 50";
|
expectedContent = "Priority: ${toString config.services.harmonia.settings.priority}";
|
||||||
};
|
};
|
||||||
|
|
||||||
services.nginx = {
|
services.nginx = {
|
||||||
enable = true;
|
enable = true;
|
||||||
virtualHosts."cache.${config.networking.hostName}.wg0" = {
|
virtualHosts."cache.${config.networking.hostName}.wg0" = {
|
||||||
locations."/".extraConfig = ''
|
locations."/".extraConfig = ''
|
||||||
proxy_pass http://localhost:${toString config.services.nix-serve.port};
|
proxy_pass http://localhost:${toString port};
|
||||||
allow ${config.wireguard.wg0.subnet};
|
proxy_set_header Host $host;
|
||||||
deny all;
|
proxy_http_version 1.1;
|
||||||
'';
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||||
# curl https://cache.nixos.org/nix-cache-info
|
proxy_set_header Upgrade $http_upgrade;
|
||||||
# lower priority means ask first.
|
proxy_set_header Connection $connection_upgrade;
|
||||||
locations."= /nix-cache-info".extraConfig = ''
|
|
||||||
alias ${pkgs.writeText "cache-info" ''
|
|
||||||
StoreDir: /nix/store
|
|
||||||
WantMassQuery: 1
|
|
||||||
Priority: 50
|
|
||||||
''};
|
|
||||||
allow ${config.wireguard.wg0.subnet};
|
allow ${config.wireguard.wg0.subnet};
|
||||||
deny all;
|
deny all;
|
||||||
'';
|
'';
|
||||||
|
|
Loading…
Add table
Reference in a new issue