@@ -24,7 +24,6 @@ fi
2424# Parse the command line for the -I flag
2525extraBuildFlags=()
2626chrootCommand=(/run/current-system/sw/bin/bash)
27−bootLoader=1
2827
2928while [ "$#" -gt 0 ]; do
3029 i="$1"; shift 1
@@ -51,7 +50,7 @@ while [ "$#" -gt 0 ]; do
5150 noRootPasswd=1
5251 ;;
5352 --no-bootloader)
54− bootLoader=0
53+ noBootLoader=1
5554 ;;
5655 --show-trace)
5756 extraBuildFlags+=("$i")
@@ -142,7 +141,7 @@ mkdir -m 0755 -p \
142141 $mountPoint/nix/var/log/nix/drvs
143142
144143mkdir -m 1775 -p $mountPoint/nix/store
145−chown root:nixbld $mountPoint/nix/store
144+chown root:@nixbld_gid@ $mountPoint/nix/store
146145
147146
148147# There is no daemon in the chroot.
@@ -155,14 +154,14 @@ export LC_ALL=
155154export LC_TIME=
156155
157156
158−# Create a temporary Nix config file that causes the nixbld users to
159−# be used.
160−echo "build-users-group = nixbld" > $mountPoint/tmp/nix.conf # FIXME: remove in Nix 1.8
161−binary_caches=$(@perl@/bin/perl -I @nix@/lib/perl5/site_perl/*/* -e 'use Nix::Config; Nix::Config::readConfig; print $Nix::Config::config{"binary-caches"};')
162−if test -n "$binary_caches"; then
163− echo "binary-caches = $binary_caches" >> $mountPoint/tmp/nix.conf
164−fi
165−export NIX_CONF_DIR=/tmp
157+# Builds will use users that are members of this group
158+extraBuildFlags+=(--option "build-users-group" "nixbld")
159+
160+
161+# Inherit binary caches from the host
162+binary_caches="$(@perl@/bin/perl -I @nix@/lib/perl5/site_perl/*/* -e 'use Nix::Config; Nix::Config::readConfig; print $Nix::Config::config{"binary-caches"};')"
163+extraBuildFlags+=(--option "binary-caches" "$binary_caches")
164+
166165
167166touch $mountPoint/etc/passwd $mountPoint/etc/group
168167mount --bind -o ro /etc/passwd $mountPoint/etc/passwd
@@ -263,16 +262,17 @@ touch $mountPoint/etc/NIXOS
263262# a menu default pointing at the kernel/initrd/etc of the new
264263# configuration.
265264echo "finalising the installation..."
266−NIXOS_INSTALL_GRUB="$bootLoader" chroot $mountPoint \
267− /nix/var/nix/profiles/system/bin/switch-to-configuration boot
268−
265+if [ -z "$noBootLoader" ]; then
266+ NIXOS_INSTALL_GRUB=1 chroot $mountPoint \
267+ /nix/var/nix/profiles/system/bin/switch-to-configuration boot
268+fi
269269
270270# Run the activation script.
271271chroot $mountPoint /nix/var/nix/profiles/system/activate
272272
273273
274274# Ask the user to set a root password.
275−if [ -z "$noRootPasswd" ] && [ "$(chroot $mountPoint /run/current-system/sw/bin/sh -l -c "nix-instantiate --eval '<nixpkgs/nixos>' -A config.users.mutableUsers")" = true ] && [ -t 0 ] ; then
275+if [ -z "$noRootPasswd" ] && [ -x $mountPoint/var/setuid-wrappers/passwd ] && [ -t 0 ]; then
276276 echo "setting root password..."
277277 chroot $mountPoint /var/setuid-wrappers/passwd
278278fi