* 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"
"common-console" # shared stuff for interactive local sessions "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 in
let let

View File

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

View File

@ -9,21 +9,8 @@ export LANG=@defaultLocale@
export EDITOR=nano export EDITOR=nano
export INFOPATH=/var/run/current-system/sw/info:/var/run/current-system/sw/share/info export INFOPATH=/var/run/current-system/sw/info:/var/run/current-system/sw/share/info
export LOCATE_PATH=/var/cache/locatedb export LOCATE_PATH=/var/cache/locatedb
@shellInit@
export LOCALE_ARCHIVE=/var/run/current-system/sw/lib/locale/locale-archive export LOCALE_ARCHIVE=/var/run/current-system/sw/lib/locale/locale-archive
@shellInit@
# 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@
# Include the various profiles in the appropriate environment variables. # Include the various profiles in the appropriate environment variables.

View File

@ -178,13 +178,12 @@ let
}; };
}; };
}; };
in in
###### implementation ###### implementation
let let
binsh = config.system.build.binsh;
nixEnvVars = config.nix.envVars;
inherit (config.environment) nix; inherit (config.environment) nix;
in in
@ -193,9 +192,8 @@ in
options options
]; ];
environment = { environment.etc =
etc = [ [ { # Nix configuration.
{ # Nix configuration.
source = source =
let let
# Tricky: if we're using a chroot for builds, then we need # 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 # other paths in the store, we need the closure of /bin/sh
# in `build-chroot-dirs' - otherwise any builder that uses # in `build-chroot-dirs' - otherwise any builder that uses
# /bin/sh won't work. # /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 # Likewise, if chroots are turned on, we need Nix's own
# closure in the chroot. Otherwise nix-channel and nix-env # 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. 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 = '' job = ''
start on startup start on startup
stop on shutdown stop on shutdown
respawn respawn
script script
export PATH=${if config.nix.distributedBuilds then "${pkgs.openssh}/bin:" else ""}${pkgs.openssl}/bin:${nix}/bin:$PATH 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 exec ${nix}/bin/nix-worker --daemon > /dev/null 2>&1
end script 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
'';
} }