* Move the generation of /etc/nix.machines to the nix-daemon module.

svn path=/nixos/branches/modular-nixos/; revision=15765
This commit is contained in:
Eelco Dolstra 2009-05-28 12:56:56 +00:00
parent e4716ce3ef
commit de7aae5d5e
4 changed files with 37 additions and 42 deletions

View file

@ -88,19 +88,8 @@ let
"common"
"common-console" # shared stuff for interactive local sessions
]
)
);
# List of machines for distributed Nix builds in the format expected
# by build-remote.pl.
++ optional config.nix.distributedBuilds {
source = pkgs.writeText "nix.machines"
(pkgs.lib.concatStrings (map (machine:
"${machine.sshUser}@${machine.hostName} ${machine.system} ${machine.sshKey} ${toString machine.maxJobs}\n"
) config.nix.buildMachines));
target = "nix.machines";
}
;
in
let

View file

@ -15,7 +15,6 @@
wrapperDir = config.security.wrapperDir;
modulesTree = config.system.modulesTree;
defaultLocale = config.i18n.defaultLocale;
nixEnvVars = config.nix.envVars;
shellInit = config.environment.shellInit;
};
target = "bashrc";

View file

@ -9,21 +9,8 @@ export LANG=@defaultLocale@
export EDITOR=nano
export INFOPATH=/var/run/current-system/sw/info:/var/run/current-system/sw/share/info
export LOCATE_PATH=/var/cache/locatedb
@shellInit@
export LOCALE_ARCHIVE=/var/run/current-system/sw/lib/locale/locale-archive
# Set up secure multi-user builds: non-root users build through the
# Nix daemon.
if test "$USER" != root; then
export NIX_REMOTE=daemon
else
export NIX_REMOTE=
fi
# Set up the environment variables for running Nix.
@nixEnvVars@
@shellInit@
# Include the various profiles in the appropriate environment variables.

View file

@ -178,13 +178,12 @@ let
};
};
};
in
###### implementation
let
binsh = config.system.build.binsh;
nixEnvVars = config.nix.envVars;
inherit (config.environment) nix;
in
@ -193,9 +192,8 @@ in
options
];
environment = {
etc = [
{ # Nix configuration.
environment.etc =
[ { # Nix configuration.
source =
let
# Tricky: if we're using a chroot for builds, then we need
@ -205,7 +203,7 @@ in
# other paths in the store, we need the closure of /bin/sh
# in `build-chroot-dirs' - otherwise any builder that uses
# /bin/sh won't work.
binshDeps = pkgs.writeReferencesToFile binsh;
binshDeps = pkgs.writeReferencesToFile config.system.build.binsh;
# Likewise, if chroots are turned on, we need Nix's own
# closure in the chroot. Otherwise nix-channel and nix-env
@ -226,23 +224,45 @@ in
'';
target = "nix.conf"; # will be symlinked from /nix/etc/nix/nix.conf in activate-configuration.sh.
}
];
};
]
++ optional config.nix.distributedBuilds
{ # List of machines for distributed Nix builds in the format expected
# by build-remote.pl.
source = pkgs.writeText "nix.machines"
(pkgs.lib.concatStrings (map (machine:
"${machine.sshUser}@${machine.hostName} ${machine.system} ${machine.sshKey} ${toString machine.maxJobs}\n"
) config.nix.buildMachines));
target = "nix.machines";
};
services.extraJobs = [
{ name = "nix-daemon";
services = {
extraJobs = [{
name = "nix-daemon";
job = ''
start on startup
stop on shutdown
respawn
script
export PATH=${if config.nix.distributedBuilds then "${pkgs.openssh}/bin:" else ""}${pkgs.openssl}/bin:${nix}/bin:$PATH
${nixEnvVars}
${config.nix.envVars}
exec ${nix}/bin/nix-worker --daemon > /dev/null 2>&1
end script
'';
}];
};
}
];
environment.shellInit =
''
# Set up the environment variables for running Nix.
${config.nix.envVars}
# Set up secure multi-user builds: non-root users build through the
# Nix daemon.
if test "$USER" != root; then
export NIX_REMOTE=daemon
else
export NIX_REMOTE=
fi
'';
}