Add option ‘build-extra-chroot-dirs’
This is useful for extending (rather than overriding) the default set of chroot paths.
This commit is contained in:
parent
4d73e2e893
commit
d5a076c36f
5 changed files with 10 additions and 14 deletions
|
@ -98,7 +98,7 @@ let
|
||||||
preHook = lib.optionalString stdenv.isLinux (
|
preHook = lib.optionalString stdenv.isLinux (
|
||||||
let sh = stdenv.shell; in
|
let sh = stdenv.shell; in
|
||||||
''
|
''
|
||||||
NIX_CFLAGS_COMPILE+=" -DDEFAULT_CHROOT_DIRS=\"/bin/sh=${sh}:$(tr '\n' ':' < ${writeReferencesToFile sh})\""
|
export DEFAULT_CHROOT_DIRS="/bin/sh=${sh} $(tr '\n' ' ' < ${writeReferencesToFile sh})"
|
||||||
'');
|
'');
|
||||||
|
|
||||||
enableParallelBuilding = true;
|
enableParallelBuilding = true;
|
||||||
|
|
|
@ -1792,12 +1792,15 @@ void DerivationGoal::startBuilder()
|
||||||
|
|
||||||
/* Bind-mount a user-configurable set of directories from the
|
/* Bind-mount a user-configurable set of directories from the
|
||||||
host file system. */
|
host file system. */
|
||||||
foreach (StringSet::iterator, i, settings.dirsInChroot) {
|
PathSet dirs = tokenizeString<StringSet>(settings.get(string("build-chroot-dirs"), DEFAULT_CHROOT_DIRS));
|
||||||
size_t p = i->find('=');
|
PathSet dirs2 = tokenizeString<StringSet>(settings.get(string("build-extra-chroot-dirs"), ""));
|
||||||
|
dirs.insert(dirs2.begin(), dirs2.end());
|
||||||
|
for (auto & i : dirs) {
|
||||||
|
size_t p = i.find('=');
|
||||||
if (p == string::npos)
|
if (p == string::npos)
|
||||||
dirsInChroot[*i] = *i;
|
dirsInChroot[i] = i;
|
||||||
else
|
else
|
||||||
dirsInChroot[string(*i, 0, p)] = string(*i, p + 1);
|
dirsInChroot[string(i, 0, p)] = string(i, p + 1);
|
||||||
}
|
}
|
||||||
dirsInChroot[tmpDir] = tmpDir;
|
dirsInChroot[tmpDir] = tmpDir;
|
||||||
|
|
||||||
|
|
|
@ -48,9 +48,6 @@ Settings::Settings()
|
||||||
useSubstitutes = true;
|
useSubstitutes = true;
|
||||||
buildUsersGroup = getuid() == 0 ? "nixbld" : "";
|
buildUsersGroup = getuid() == 0 ? "nixbld" : "";
|
||||||
useChroot = false;
|
useChroot = false;
|
||||||
#ifdef DEFAULT_CHROOT_DIRS
|
|
||||||
dirsInChroot = tokenizeString<StringSet>(DEFAULT_CHROOT_DIRS, ":");
|
|
||||||
#endif
|
|
||||||
useSshSubstituter = true;
|
useSshSubstituter = true;
|
||||||
impersonateLinux26 = false;
|
impersonateLinux26 = false;
|
||||||
keepLog = true;
|
keepLog = true;
|
||||||
|
@ -148,7 +145,6 @@ void Settings::update()
|
||||||
get(useSubstitutes, "build-use-substitutes");
|
get(useSubstitutes, "build-use-substitutes");
|
||||||
get(buildUsersGroup, "build-users-group");
|
get(buildUsersGroup, "build-users-group");
|
||||||
get(useChroot, "build-use-chroot");
|
get(useChroot, "build-use-chroot");
|
||||||
get(dirsInChroot, "build-chroot-dirs");
|
|
||||||
get(impersonateLinux26, "build-impersonate-linux-26");
|
get(impersonateLinux26, "build-impersonate-linux-26");
|
||||||
get(keepLog, "build-keep-log");
|
get(keepLog, "build-keep-log");
|
||||||
get(compressLog, "build-compress-log");
|
get(compressLog, "build-compress-log");
|
||||||
|
|
|
@ -144,10 +144,6 @@ struct Settings {
|
||||||
/* Whether to build in chroot. */
|
/* Whether to build in chroot. */
|
||||||
bool useChroot;
|
bool useChroot;
|
||||||
|
|
||||||
/* The directories from the host filesystem to be included in the
|
|
||||||
chroot. */
|
|
||||||
StringSet dirsInChroot;
|
|
||||||
|
|
||||||
/* Set of ssh connection strings for the ssh substituter */
|
/* Set of ssh connection strings for the ssh substituter */
|
||||||
Strings sshSubstituterHosts;
|
Strings sshSubstituterHosts;
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,8 @@ libstore_CXXFLAGS = \
|
||||||
-DNIX_LOG_DIR=\"$(localstatedir)/log/nix\" \
|
-DNIX_LOG_DIR=\"$(localstatedir)/log/nix\" \
|
||||||
-DNIX_CONF_DIR=\"$(sysconfdir)/nix\" \
|
-DNIX_CONF_DIR=\"$(sysconfdir)/nix\" \
|
||||||
-DNIX_LIBEXEC_DIR=\"$(libexecdir)\" \
|
-DNIX_LIBEXEC_DIR=\"$(libexecdir)\" \
|
||||||
-DNIX_BIN_DIR=\"$(bindir)\"
|
-DNIX_BIN_DIR=\"$(bindir)\" \
|
||||||
|
-DDEFAULT_CHROOT_DIRS="\"$(DEFAULT_CHROOT_DIRS)\""
|
||||||
|
|
||||||
$(d)/local-store.cc: $(d)/schema.sql.hh
|
$(d)/local-store.cc: $(d)/schema.sql.hh
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue