Reputation: 53
Installing package in Nix with nix-env -i <pkg>
and adding Nix environment with source ~/.nix-profile/etc/profile.d/nix.sh
causes that package to appear on top of the $PATH
which is usually desirable.
What if I want to install and specify a runtime dependency (e.g. python
or perl
interpreter) for already existing package but don't want the dependency to appear for the rest of packages and system environment?
In my case I want to add perl
dependency to fzf package as it uses perl here. But I don't want it to be present for the rest of the system for compatibility reasons.
I tried overriding fzf
with packageOverrides
but first it seems to work only for build dependencies and second there is no argument to specify perl
.
Upvotes: 3
Views: 1960
Reputation: 7359
Usually you'd use wrapProgram to replace an executable by a script that modifies PATH
before invoking the real executable.
In this case it's a bit more complicated, because it's not a standalone program but a script to be imported, so it can not use a wrapper. In postInstall
you could use substituteInPlace, which will look somewhat like
substituteInPlace $out/path-to-keybindings.zsh --replace '| perl ' '| ${pkgs.perl}/bin/perl '
This will patch the script to reference perl by its absolute store path, without modifying the environment.
Upvotes: 3