In Nix chroots, provide plain bash, not bash-interactive
This way we don't get ncurses in the chroot. Also, use a bind-mount of /bin/sh to bash, rather than the entire /bin from the host filesystem.
This commit is contained in:
@@ -22,14 +22,11 @@ let
|
|||||||
|
|
||||||
nixConf =
|
nixConf =
|
||||||
let
|
let
|
||||||
# Tricky: if we're using a chroot for builds, then we need
|
# If we're using a chroot for builds, then provide /bin/sh in
|
||||||
# /bin/sh in the chroot (our own compromise to purity).
|
# the chroot as a bind-mount to bash. This means we also need to
|
||||||
# However, since /bin/sh is a symlink to some path in the
|
# include the entire closure of bash.
|
||||||
# Nix store, which furthermore has runtime dependencies on
|
sh = pkgs.stdenv.shell;
|
||||||
# other paths in the store, we need the closure of /bin/sh
|
binshDeps = pkgs.writeReferencesToFile sh;
|
||||||
# in `build-chroot-dirs' - otherwise any builder that uses
|
|
||||||
# /bin/sh won't work.
|
|
||||||
binshDeps = pkgs.writeReferencesToFile config.system.build.binsh;
|
|
||||||
in
|
in
|
||||||
pkgs.runCommand "nix.conf" {extraOptions = cfg.extraOptions; } ''
|
pkgs.runCommand "nix.conf" {extraOptions = cfg.extraOptions; } ''
|
||||||
extraPaths=$(for i in $(cat ${binshDeps}); do if test -d $i; then echo $i; fi; done)
|
extraPaths=$(for i in $(cat ${binshDeps}); do if test -d $i; then echo $i; fi; done)
|
||||||
@@ -40,7 +37,7 @@ let
|
|||||||
build-users-group = nixbld
|
build-users-group = nixbld
|
||||||
build-max-jobs = ${toString (cfg.maxJobs)}
|
build-max-jobs = ${toString (cfg.maxJobs)}
|
||||||
build-use-chroot = ${if cfg.useChroot then "true" else "false"}
|
build-use-chroot = ${if cfg.useChroot then "true" else "false"}
|
||||||
build-chroot-dirs = ${toString cfg.chrootDirs} $(echo $extraPaths)
|
build-chroot-dirs = ${toString cfg.chrootDirs} /bin/sh=${sh} $(echo $extraPaths)
|
||||||
binary-caches = ${toString cfg.binaryCaches}
|
binary-caches = ${toString cfg.binaryCaches}
|
||||||
trusted-binary-caches = ${toString cfg.trustedBinaryCaches}
|
trusted-binary-caches = ${toString cfg.trustedBinaryCaches}
|
||||||
$extraOptions
|
$extraOptions
|
||||||
@@ -253,8 +250,6 @@ in
|
|||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
|
||||||
nix.chrootDirs = [ "/bin" ];
|
|
||||||
|
|
||||||
environment.etc."nix/nix.conf".source = nixConf;
|
environment.etc."nix/nix.conf".source = nixConf;
|
||||||
|
|
||||||
# List of machines for distributed Nix builds in the format
|
# List of machines for distributed Nix builds in the format
|
||||||
|
|||||||
Reference in New Issue
Block a user