mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
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).
This commit is contained in:
parent
a0b971dd9c
commit
c87f4b9324
1 changed files with 21 additions and 2 deletions
|
@ -12,6 +12,8 @@
|
||||||
#include <sys/mount.h>
|
#include <sys/mount.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <queue>
|
||||||
|
|
||||||
using namespace nix;
|
using namespace nix;
|
||||||
|
|
||||||
std::string chrootHelperName = "__run_in_chroot";
|
std::string chrootHelperName = "__run_in_chroot";
|
||||||
|
@ -121,10 +123,27 @@ struct CmdRun : InstallablesCommand
|
||||||
unsetenv(var.c_str());
|
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"), ":");
|
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");
|
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);
|
setenv("PATH", concatStringsSep(":", unixPath).c_str(), 1);
|
||||||
|
|
||||||
std::string cmd = *command.begin();
|
std::string cmd = *command.begin();
|
||||||
|
|
Loading…
Reference in a new issue