1
1
mirror of https://github.com/LnL7/nix-darwin.git synced 2024-11-09 20:38:22 +03:00

nix.distributedBuilds: create directory for current load

This commit is contained in:
Daiderd Jordan 2017-01-09 22:30:15 +01:00
parent 30ccc15bed
commit 5a5ec9ac42
No known key found for this signature in database
GPG Key ID: D02435D05B810C96
6 changed files with 42 additions and 6 deletions

View File

@ -6,6 +6,7 @@ let
check = true;
modules =
[ configuration
./modules/alias.nix
./modules/system
./modules/system/activation-scripts.nix
./modules/system/defaults-write.nix

25
modules/alias.nix Normal file
View File

@ -0,0 +1,25 @@
{ config, lib, pkgs, ... }:
with lib;
let
in
{
options = {
nix.profile = mkOption { default = null; };
};
config = {
assertions =
[ { assertion = config.nix.profile == null; message = "nix.profile was renamed to nix.package"; }
];
nix.package = mkIf (config.nix.profile != null) config.nix.profile;
};
}

View File

@ -47,12 +47,12 @@ in
nix = {
profile = mkOption {
package = mkOption {
type = types.path;
default = "/nix/var/nix/profiles/default";
defaultText = "pkgs.nix";
example = "pkgs.nix";
description = ''
This option specifies the profile that contains the Nix package instance to use throughout the system.
This option specifies the package or profile that contains the version of Nix to use throughout the system.
'';
};
@ -337,7 +337,7 @@ in
}
// optionalAttrs cfg.distributedBuilds {
NIX_BUILD_HOOK = "${cfg.profile}/libexec/nix/build-remote.pl";
NIX_BUILD_HOOK = "${cfg.package}/libexec/nix/build-remote.pl";
NIX_REMOTE_SYSTEMS = "/etc/nix/machines";
NIX_CURRENT_LOAD = "/run/nix/current-load";
};
@ -347,5 +347,11 @@ in
{ NIX_PATH = concatStringsSep ":" cfg.nixPath;
};
system.activationScripts.nix.text = mkIf cfg.distributedBuilds ''
if [ ! -d ${cfg.envVars.NIX_CURRENT_LOAD} ]; then
mkdir -p ${cfg.envVars.NIX_CURRENT_LOAD}
fi
'';
};
}

View File

@ -19,6 +19,8 @@ let
# Prevent the current configuration from being garbage-collected.
ln -sfn /run/current-system /nix/var/nix/gcroots/current-system
${config.system.activationScripts.nix.text}
'';
in

View File

@ -38,7 +38,7 @@ in
'';
launchd.daemons.nix-daemon = {
serviceConfig.ProgramArguments = [ "/bin/sh" "-c" "exec ${config.nix.profile}/bin/nix-daemon" ];
serviceConfig.ProgramArguments = [ "/bin/sh" "-c" "exec ${config.nix.package}/bin/nix-daemon" ];
serviceConfig.KeepAlive = true;
serviceConfig.ProcessType = "Background";
serviceConfig.LowPriorityIO = config.nix.daemonIONice;
@ -47,7 +47,7 @@ in
serviceConfig.EnvironmentVariables = config.nix.envVars
# // { CURL_CA_BUNDLE = "/etc/ssl/certs/ca-certificates.crt"; }
// { SSL_CERT_FILE = "${config.nix.profile}/etc/ssl/certs/ca-bundle.crt"; }
// { SSL_CERT_FILE = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt"; }
// { TMPDIR = "${cfg.tempDir}"; };
};
};

View File

@ -59,6 +59,8 @@ in
# Prevent the current configuration from being garbage-collected.
ln -sfn /run/current-system /nix/var/nix/gcroots/current-system
${cfg.activationScripts.nix.text}
${cfg.activationScripts.etc.text}
${cfg.activationScripts.launchd.text}
${cfg.activationScripts.time.text}