diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2018-08-09T11·01+0200 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2018-08-09T11·01+0200 |
commit | c87f4b9324b87a059cf760a477177f322bb8dc26 (patch) | |
tree | ada7f098e448e6b1b194b3ca65246be420603308 /src | |
parent | a0b971dd9c19819d4f7a3a8ab102be9d7101e3e0 (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')
-rw-r--r-- | src/nix/run.cc | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/src/nix/run.cc b/src/nix/run.cc index d04e106e037b..65ced34759b1 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(); |