Suppose I install the package pkgs.foo
in Nix (with home-manager), which provides the binary ${pkgs.foo}/bin/foo
.
How can I add a wrapper (in a nix-way) so that when I run foo
, it executes: VAR=bar foo
?
home.packages = [
# Do not add pkgs.foo directly; the below is a replacement
(pkgs.runCommand
"foo"
{ nativeBuildInputs = [ pkgs.makeWrapper ]; }
"makeWrapper ${pkgs.foo}/bin/foo $out/bin/foo --set VAR bar"
)
];