Skip to content

Commit

Permalink
WIP Bindmount files instead of hardlinking
Browse files Browse the repository at this point in the history
16591eb#diff-19f999107b609d37cfb22c58e7f0bc1cf76edf1180e238dd6389e03cc279b604 (2013) added support for files to doBind

This is work towards allowing users to change the location of chrootRootDir, to, for example, a tmpfs.

inspired by trofi on matrix

> It looks like build sandbox created by nix-daemon runs on the same filesystem, as /nix/store including things like /tmp which makes all small temporary files hit the disk. Is it intentional? If it is is there an easy way to redirect chroot's root to be tmpfs?
  • Loading branch information
Artturin committed Sep 10, 2023
1 parent 151120a commit 26546f2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/libstore/build/local-derivation-goal.cc
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ void LocalDerivationGoal::startBuilder()
if (S_ISDIR(lstat(r).st_mode))
dirsInChroot.insert_or_assign(p, r);
else
linkOrCopy(r, chrootRootDir + p);
filesInChroot.insert_or_assign(p, r);
}

/* If we're repairing, checking or rebuilding part of a
Expand Down Expand Up @@ -1858,6 +1858,10 @@ void LocalDerivationGoal::runChild()
doBind(i.second.source, chrootRootDir + i.first, i.second.optional);
}

for (auto & i : filesInChroot) {
doBind(i.second.source, chrootRootDir + i.first, i.second.optional);
}

/* Bind a new instance of procfs on /proc. */
createDirs(chrootRootDir + "/proc");
if (mount("none", (chrootRootDir + "/proc").c_str(), "proc", 0, 0) == -1)
Expand Down
3 changes: 3 additions & 0 deletions src/libstore/build/local-derivation-goal.hh
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@ struct LocalDerivationGoal : public DerivationGoal
typedef map<Path, ChrootPath> DirsInChroot; // maps target path to source path
DirsInChroot dirsInChroot;

typedef map<Path, ChrootPath> FilesInChroot; // maps target path to source path
FilesInChroot filesInChroot;

typedef map<std::string, std::string> Environment;
Environment env;

Expand Down

0 comments on commit 26546f2

Please sign in to comment.