nix-daemon.nix: Drop Nix 1.x compatibility
Probably didn't work anyway anymore.
This commit is contained in:
parent
4e0d6a5ff8
commit
4b950c42cd
@ -10,7 +10,6 @@ let
|
|||||||
|
|
||||||
nixVersion = getVersion nix;
|
nixVersion = getVersion nix;
|
||||||
|
|
||||||
isNix20 = versionAtLeast nixVersion "2.0pre";
|
|
||||||
isNix23 = versionAtLeast nixVersion "2.3pre";
|
isNix23 = versionAtLeast nixVersion "2.3pre";
|
||||||
|
|
||||||
makeNixBuildUser = nr:
|
makeNixBuildUser = nr:
|
||||||
@ -28,39 +27,26 @@ let
|
|||||||
nixbldUsers = map makeNixBuildUser (range 1 cfg.nrBuildUsers);
|
nixbldUsers = map makeNixBuildUser (range 1 cfg.nrBuildUsers);
|
||||||
|
|
||||||
nixConf =
|
nixConf =
|
||||||
let
|
assert versionAtLeast nixVersion "2.2";
|
||||||
# In Nix < 2.0, If we're using sandbox for builds, then provide
|
pkgs.runCommand "nix.conf" { preferLocalBuild = true; extraOptions = cfg.extraOptions; } (
|
||||||
# /bin/sh in the sandbox as a bind-mount to bash. This means we
|
''
|
||||||
# also need to include the entire closure of bash. Nix >= 2.0
|
|
||||||
# provides a /bin/sh by default.
|
|
||||||
sh = pkgs.runtimeShell;
|
|
||||||
binshDeps = pkgs.writeReferencesToFile sh;
|
|
||||||
in
|
|
||||||
pkgs.runCommand "nix.conf" { preferLocalBuild = true; extraOptions = cfg.extraOptions; } (''
|
|
||||||
${optionalString (!isNix20) ''
|
|
||||||
extraPaths=$(for i in $(cat ${binshDeps}); do if test -d $i; then echo $i; fi; done)
|
|
||||||
''}
|
|
||||||
cat > $out <<END
|
cat > $out <<END
|
||||||
# WARNING: this file is generated from the nix.* options in
|
# WARNING: this file is generated from the nix.* options in
|
||||||
# your NixOS configuration, typically
|
# your NixOS configuration, typically
|
||||||
# /etc/nixos/configuration.nix. Do not edit it!
|
# /etc/nixos/configuration.nix. Do not edit it!
|
||||||
build-users-group = nixbld
|
build-users-group = nixbld
|
||||||
${if isNix20 then "max-jobs" else "build-max-jobs"} = ${toString (cfg.maxJobs)}
|
max-jobs = ${toString (cfg.maxJobs)}
|
||||||
${if isNix20 then "cores" else "build-cores"} = ${toString (cfg.buildCores)}
|
cores = ${toString (cfg.buildCores)}
|
||||||
${if isNix20 then "sandbox" else "build-use-sandbox"} = ${if (builtins.isBool cfg.useSandbox) then boolToString cfg.useSandbox else cfg.useSandbox}
|
sandbox = ${if (builtins.isBool cfg.useSandbox) then boolToString cfg.useSandbox else cfg.useSandbox}
|
||||||
${if isNix20 then "extra-sandbox-paths" else "build-sandbox-paths"} = ${toString cfg.sandboxPaths} ${optionalString (!isNix20) "/bin/sh=${sh} $(echo $extraPaths)"}
|
extra-sandbox-paths = ${toString cfg.sandboxPaths}
|
||||||
${if isNix20 then "substituters" else "binary-caches"} = ${toString cfg.binaryCaches}
|
substituters = ${toString cfg.binaryCaches}
|
||||||
${if isNix20 then "trusted-substituters" else "trusted-binary-caches"} = ${toString cfg.trustedBinaryCaches}
|
trusted-substituters = ${toString cfg.trustedBinaryCaches}
|
||||||
${if isNix20 then "trusted-public-keys" else "binary-cache-public-keys"} = ${toString cfg.binaryCachePublicKeys}
|
trusted-public-keys = ${toString cfg.binaryCachePublicKeys}
|
||||||
auto-optimise-store = ${boolToString cfg.autoOptimiseStore}
|
auto-optimise-store = ${boolToString cfg.autoOptimiseStore}
|
||||||
${if isNix20 then ''
|
require-sigs = ${if cfg.requireSignedBinaryCaches then "true" else "false"}
|
||||||
require-sigs = ${if cfg.requireSignedBinaryCaches then "true" else "false"}
|
|
||||||
'' else ''
|
|
||||||
signed-binary-caches = ${if cfg.requireSignedBinaryCaches then "*" else ""}
|
|
||||||
''}
|
|
||||||
trusted-users = ${toString cfg.trustedUsers}
|
trusted-users = ${toString cfg.trustedUsers}
|
||||||
allowed-users = ${toString cfg.allowedUsers}
|
allowed-users = ${toString cfg.allowedUsers}
|
||||||
${optionalString (isNix20 && !cfg.distributedBuilds) ''
|
${optionalString (!cfg.distributedBuilds) ''
|
||||||
builders =
|
builders =
|
||||||
''}
|
''}
|
||||||
system-features = ${toString cfg.systemFeatures}
|
system-features = ${toString cfg.systemFeatures}
|
||||||
@ -422,8 +408,7 @@ in
|
|||||||
|
|
||||||
systemd.services.nix-daemon =
|
systemd.services.nix-daemon =
|
||||||
{ path = [ nix pkgs.utillinux config.programs.ssh.package ]
|
{ path = [ nix pkgs.utillinux config.programs.ssh.package ]
|
||||||
++ optionals cfg.distributedBuilds [ pkgs.gzip ]
|
++ optionals cfg.distributedBuilds [ pkgs.gzip ];
|
||||||
++ optionals (!isNix20) [ pkgs.openssl.bin ];
|
|
||||||
|
|
||||||
environment = cfg.envVars
|
environment = cfg.envVars
|
||||||
// { CURL_CA_BUNDLE = "/etc/ssl/certs/ca-certificates.crt"; }
|
// { CURL_CA_BUNDLE = "/etc/ssl/certs/ca-certificates.crt"; }
|
||||||
@ -440,34 +425,13 @@ in
|
|||||||
restartTriggers = [ nixConf ];
|
restartTriggers = [ nixConf ];
|
||||||
};
|
};
|
||||||
|
|
||||||
nix.envVars =
|
|
||||||
optionalAttrs (!isNix20) {
|
|
||||||
NIX_CONF_DIR = "/etc/nix";
|
|
||||||
|
|
||||||
# Enable the copy-from-other-stores substituter, which allows
|
|
||||||
# builds to be sped up by copying build results from remote
|
|
||||||
# Nix stores. To do this, mount the remote file system on a
|
|
||||||
# subdirectory of /run/nix/remote-stores.
|
|
||||||
NIX_OTHER_STORES = "/run/nix/remote-stores/*/nix";
|
|
||||||
}
|
|
||||||
|
|
||||||
// optionalAttrs (cfg.distributedBuilds && !isNix20) {
|
|
||||||
NIX_BUILD_HOOK = "${nix}/libexec/nix/build-remote.pl";
|
|
||||||
};
|
|
||||||
|
|
||||||
# Set up the environment variables for running Nix.
|
# Set up the environment variables for running Nix.
|
||||||
environment.sessionVariables = cfg.envVars //
|
environment.sessionVariables = cfg.envVars //
|
||||||
{ NIX_PATH = cfg.nixPath;
|
{ NIX_PATH = cfg.nixPath;
|
||||||
};
|
};
|
||||||
|
|
||||||
environment.extraInit = optionalString (!isNix20)
|
environment.extraInit =
|
||||||
''
|
''
|
||||||
# Set up secure multi-user builds: non-root users build through the
|
|
||||||
# Nix daemon.
|
|
||||||
if [ "$USER" != root -o ! -w /nix/var/nix/db ]; then
|
|
||||||
export NIX_REMOTE=daemon
|
|
||||||
fi
|
|
||||||
'' + ''
|
|
||||||
if [ -e "$HOME/.nix-defexpr/channels" ]; then
|
if [ -e "$HOME/.nix-defexpr/channels" ]; then
|
||||||
export NIX_PATH="$HOME/.nix-defexpr/channels''${NIX_PATH:+:$NIX_PATH}"
|
export NIX_PATH="$HOME/.nix-defexpr/channels''${NIX_PATH:+:$NIX_PATH}"
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user