diff --git a/default.nix b/default.nix index 3923cb9592b7..46f2d265216f 100644 --- a/default.nix +++ b/default.nix @@ -1,6 +1,6 @@ let - fromEnv = name : default : + fromEnv = name: default: let env = builtins.getEnv name; in if env == "" then default else env; configuration = import (fromEnv "NIXOS_CONFIG" /etc/nixos/configuration.nix); diff --git a/etc/default.nix b/etc/default.nix index 448fa993d73b..c4cb68d94150 100644 --- a/etc/default.nix +++ b/etc/default.nix @@ -1,5 +1,5 @@ { config, pkgs, upstartJobs, systemPath, wrapperDir -, defaultShell, extraEtc, nixEnvVars, modulesTree, nssModulesPath +, defaultShell, extraEtc, nixEnvVars, modulesTree, nssModulesPath, binsh }: let @@ -123,14 +123,27 @@ import ../helpers/make-etc.nix { } { # Nix configuration. - source = pkgs.writeText "nix.conf" '' - # WARNING: this file is generated. - build-users-group = nixbld - build-max-jobs = ${toString (config.nix.maxJobs)} - build-use-chroot = ${if config.nix.useChroot then "true" else "false"} - build-chroot-dirs = /dev /dev/pts /proc /bin - ${config.nix.extraOptions} - ''; + source = + let + # Tricky: if we're using a chroot for builds, then we need + # /bin/sh in the chroot (our own compromise to purity). + # However, since /bin/sh is a symlink to some path in the + # Nix store, which furthermore has runtime dependencies on + # 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. + refs = pkgs.writeReferencesToFile binsh; + in + pkgs.runCommand "nix.conf" {} '' + cat > $out <