aboutsummaryrefslogtreecommitdiff
path: root/src/nix
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2018-08-09 13:01:03 +0200
committerEelco Dolstra <edolstra@gmail.com>2018-08-09 13:01:03 +0200
commitc87f4b9324b87a059cf760a477177f322bb8dc26 (patch)
treeada7f098e448e6b1b194b3ca65246be420603308 /src/nix
parenta0b971dd9c19819d4f7a3a8ab102be9d7101e3e0 (diff)
nix run: Respect propagated-user-env-packages
Also, add $path/bin to $PATH even if it doesn't exist. This makes 'man' work properly (since it looks for ../share/man relative to $PATH entries).
Diffstat (limited to 'src/nix')
-rw-r--r--src/nix/run.cc23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/nix/run.cc b/src/nix/run.cc
index d04e106e0..65ced3475 100644
--- a/src/nix/run.cc
+++ b/src/nix/run.cc
@@ -12,6 +12,8 @@
#include <sys/mount.h>
#endif
+#include <queue>
+
using namespace nix;
std::string chrootHelperName = "__run_in_chroot";
@@ -121,10 +123,27 @@ struct CmdRun : InstallablesCommand
unsetenv(var.c_str());
}
+ std::unordered_set<Path> done;
+ std::queue<Path> todo;
+ for (auto & path : outPaths) todo.push(path);
+
auto unixPath = tokenizeString<Strings>(getEnv("PATH"), ":");
- for (auto & path : outPaths)
- if (accessor->stat(path + "/bin").type != FSAccessor::tMissing)
+
+ while (!todo.empty()) {
+ Path path = todo.front();
+ todo.pop();
+ if (!done.insert(path).second) continue;
+
+ if (true)
unixPath.push_front(path + "/bin");
+
+ auto propPath = path + "/nix-support/propagated-user-env-packages";
+ if (accessor->stat(propPath).type == FSAccessor::tRegular) {
+ for (auto & p : tokenizeString<Paths>(readFile(propPath)))
+ todo.push(p);
+ }
+ }
+
setenv("PATH", concatStringsSep(":", unixPath).c_str(), 1);
std::string cmd = *command.begin();