mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-12 20:55:31 +03:00
* When doing chroot builds, the `build-chroot-dirs' option should
include the closure of /bin/sh. Otherwise all builders that call /bin/sh will fail when using the new chroot implementation, which only bind-mounts the inputs of a build rather than the whole Nix store. svn path=/nixos/trunk/; revision=13640
This commit is contained in:
parent
8373c890a8
commit
c155a3f46e
4 changed files with 32 additions and 15 deletions
|
@ -1,6 +1,6 @@
|
||||||
let
|
let
|
||||||
|
|
||||||
fromEnv = name : default :
|
fromEnv = name: default:
|
||||||
let env = builtins.getEnv name; in
|
let env = builtins.getEnv name; in
|
||||||
if env == "" then default else env;
|
if env == "" then default else env;
|
||||||
configuration = import (fromEnv "NIXOS_CONFIG" /etc/nixos/configuration.nix);
|
configuration = import (fromEnv "NIXOS_CONFIG" /etc/nixos/configuration.nix);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{ config, pkgs, upstartJobs, systemPath, wrapperDir
|
{ config, pkgs, upstartJobs, systemPath, wrapperDir
|
||||||
, defaultShell, extraEtc, nixEnvVars, modulesTree, nssModulesPath
|
, defaultShell, extraEtc, nixEnvVars, modulesTree, nssModulesPath, binsh
|
||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
@ -123,14 +123,27 @@ import ../helpers/make-etc.nix {
|
||||||
}
|
}
|
||||||
|
|
||||||
{ # Nix configuration.
|
{ # Nix configuration.
|
||||||
source = pkgs.writeText "nix.conf" ''
|
source =
|
||||||
# WARNING: this file is generated.
|
let
|
||||||
build-users-group = nixbld
|
# Tricky: if we're using a chroot for builds, then we need
|
||||||
build-max-jobs = ${toString (config.nix.maxJobs)}
|
# /bin/sh in the chroot (our own compromise to purity).
|
||||||
build-use-chroot = ${if config.nix.useChroot then "true" else "false"}
|
# However, since /bin/sh is a symlink to some path in the
|
||||||
build-chroot-dirs = /dev /dev/pts /proc /bin
|
# Nix store, which furthermore has runtime dependencies on
|
||||||
${config.nix.extraOptions}
|
# 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 <<END
|
||||||
|
# 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 = $(echo $(cat ${refs}))
|
||||||
|
${config.nix.extraOptions}
|
||||||
|
END
|
||||||
|
'';
|
||||||
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.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ done
|
||||||
# Create the required /bin/sh symlink; otherwise lots of things
|
# Create the required /bin/sh symlink; otherwise lots of things
|
||||||
# (notably the system() function) won't work.
|
# (notably the system() function) won't work.
|
||||||
mkdir -m 0755 -p $mountPoint/bin
|
mkdir -m 0755 -p $mountPoint/bin
|
||||||
ln -sfn @bash@/bin/sh $mountPoint/bin/sh
|
ln -sfn @binsh@/bin/sh $mountPoint/bin/sh
|
||||||
|
|
||||||
|
|
||||||
# Allow the kernel to find our wrapped modprobe (which searches in the
|
# Allow the kernel to find our wrapped modprobe (which searches in the
|
||||||
|
|
|
@ -116,7 +116,7 @@ rec {
|
||||||
# The static parts of /etc.
|
# The static parts of /etc.
|
||||||
etc = import ../etc/default.nix {
|
etc = import ../etc/default.nix {
|
||||||
inherit config pkgs upstartJobs systemPath wrapperDir
|
inherit config pkgs upstartJobs systemPath wrapperDir
|
||||||
defaultShell nixEnvVars modulesTree nssModulesPath;
|
defaultShell nixEnvVars modulesTree nssModulesPath binsh;
|
||||||
extraEtc =
|
extraEtc =
|
||||||
(pkgs.lib.concatLists (map (job: job.extraEtc) upstartJobs.jobs))
|
(pkgs.lib.concatLists (map (job: job.extraEtc) upstartJobs.jobs))
|
||||||
++ config.environment.etc;
|
++ config.environment.etc;
|
||||||
|
@ -262,6 +262,10 @@ rec {
|
||||||
|
|
||||||
defaultShell = "/var/run/current-system/sw/bin/bash";
|
defaultShell = "/var/run/current-system/sw/bin/bash";
|
||||||
|
|
||||||
|
|
||||||
|
# The shell that we want to use for /bin/sh.
|
||||||
|
binsh = pkgs.bashInteractive;
|
||||||
|
|
||||||
|
|
||||||
# The script that activates the configuration, i.e., it sets up
|
# The script that activates the configuration, i.e., it sets up
|
||||||
# /etc, accounts, etc. It doesn't do anything that can only be done
|
# /etc, accounts, etc. It doesn't do anything that can only be done
|
||||||
|
@ -270,8 +274,10 @@ rec {
|
||||||
src = ./activate-configuration.sh;
|
src = ./activate-configuration.sh;
|
||||||
isExecutable = true;
|
isExecutable = true;
|
||||||
|
|
||||||
inherit etc wrapperDir systemPath modprobe defaultShell kernel;
|
inherit etc wrapperDir systemPath modprobe defaultShell kernel binsh;
|
||||||
|
|
||||||
hostName = config.networking.hostName;
|
hostName = config.networking.hostName;
|
||||||
|
|
||||||
setuidPrograms =
|
setuidPrograms =
|
||||||
config.security.setuidPrograms ++
|
config.security.setuidPrograms ++
|
||||||
config.security.extraSetuidPrograms ++
|
config.security.extraSetuidPrograms ++
|
||||||
|
@ -288,8 +294,6 @@ rec {
|
||||||
pkgs.pwdutils
|
pkgs.pwdutils
|
||||||
];
|
];
|
||||||
|
|
||||||
bash = pkgs.bashInteractive;
|
|
||||||
|
|
||||||
adjustSetuidOwner = pkgs.lib.concatStrings (map
|
adjustSetuidOwner = pkgs.lib.concatStrings (map
|
||||||
(_entry: let entry = {
|
(_entry: let entry = {
|
||||||
owner = "nobody";
|
owner = "nobody";
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue