nix-serve should no longer use the default store. Move binaryCaches into the machine submodule.
This commit is contained in:
parent
89debb2c37
commit
345c054448
3 changed files with 19 additions and 9 deletions
|
@ -1,6 +1,8 @@
|
||||||
{ config, lib, ... }:
|
{ config, lib, ... }:
|
||||||
|
|
||||||
{
|
let
|
||||||
|
cfg = config.machine;
|
||||||
|
in {
|
||||||
nix = {
|
nix = {
|
||||||
maxJobs = 4;
|
maxJobs = 4;
|
||||||
buildCores = 1;
|
buildCores = 1;
|
||||||
|
@ -9,14 +11,12 @@
|
||||||
extraOptions = ''
|
extraOptions = ''
|
||||||
build-timeout = 86400 # 24 hours
|
build-timeout = 86400 # 24 hours
|
||||||
'';
|
'';
|
||||||
binaryCachePublicKeys = [ (lib.fileContents "${config.machine.secretPath}/hydra_cache.pub") ];
|
binaryCachePublicKeys = [ (lib.fileContents "${cfg.secretPath}/hydra_cache.pub") ];
|
||||||
trustedBinaryCaches = [
|
trustedBinaryCaches = [
|
||||||
"https://cache.nixos.org"
|
"https://cache.nixos.org"
|
||||||
"https://cache.ophanim.de"
|
] ++ cfg.binaryCaches;
|
||||||
];
|
|
||||||
binaryCaches = [
|
binaryCaches = [
|
||||||
"https://cache.nixos.org"
|
"https://cache.nixos.org"
|
||||||
"https://cache.ophanim.de"
|
] ++ cfg.binaryCaches;
|
||||||
];
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,6 +59,13 @@ in {
|
||||||
The Machines HostName
|
The Machines HostName
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
binaryCaches = mkOption {
|
||||||
|
type = types.listOf types.str;
|
||||||
|
default = [];
|
||||||
|
description = ''
|
||||||
|
Adds binary caches to both nix.trustedBinaryCaches and nix.binaryCaches. ("https://cache.nixos.org" is kept by default)
|
||||||
|
'';
|
||||||
|
};
|
||||||
secretPath = mkOption {
|
secretPath = mkOption {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = (findFirst (elem: elem.prefix == "secretPath") { path = "/secret"; } builtins.nixPath).path;
|
default = (findFirst (elem: elem.prefix == "secretPath") { path = "/secret"; } builtins.nixPath).path;
|
||||||
|
|
|
@ -10,7 +10,9 @@
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
mkIf (elem "hydra" config.machine.services) {
|
let
|
||||||
|
cacheDir = "/var/cache/hydra";
|
||||||
|
in mkIf (elem "hydra" config.machine.services) {
|
||||||
# also take a look at ../conf/nix.nix
|
# also take a look at ../conf/nix.nix
|
||||||
nix.buildMachines = [
|
nix.buildMachines = [
|
||||||
{
|
{
|
||||||
|
@ -40,7 +42,7 @@ mkIf (elem "hydra" config.machine.services) {
|
||||||
# hydra.conf: binary_cache_secret_key_file is deprecated and ignored. use store_uri=...?secret-key= instead
|
# hydra.conf: binary_cache_secret_key_file is deprecated and ignored. use store_uri=...?secret-key= instead
|
||||||
extraConfig = ''
|
extraConfig = ''
|
||||||
max_output_size = 4294967296
|
max_output_size = 4294967296
|
||||||
store_uri = file:///var/cache/hydra?secret-key=${cfg.secretPath}/hydra_cache&write-nar-listing=1&ls-compression=br&log-compression=br
|
store_uri = file://${cacheDir}?secret-key=${cfg.secretPath}/hydra_cache&write-nar-listing=1&ls-compression=br&log-compression=br
|
||||||
# add ?local-nar-cache= to set nar cache location
|
# add ?local-nar-cache= to set nar cache location
|
||||||
server_store_uri = https://cache.${cfg.domain}
|
server_store_uri = https://cache.${cfg.domain}
|
||||||
binary_cache_public_uri https://cache.${cfg.domain}
|
binary_cache_public_uri https://cache.${cfg.domain}
|
||||||
|
@ -60,4 +62,5 @@ mkIf (elem "hydra" config.machine.services) {
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
systemd.services.nix-serve.environment.NIX_STORE_DIR = cacheDir;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue