But, in my system, /nix/store/wxm9qds5wayqnfryk3mgqikg0v4gm98l-nix-2.31.3/bin/nix is a symlink to /nix/store/y7m2phpvda41km4m4hqg1p08acvqi44r-nix-2.31.3/bin/nix.
How do I get the /nix/store/y7m2phpvda41km4m4hqg1p08acvqi44r-nix-2.31.3/bin/nix path using nix code?
For context, I need the real path to create OpenSnitch rule, I’m using lib.getExe pkgs.nix but the resulting path is not what OpenSnitch expects.
which nix points to a symlink in a “merged set” of packages made for your PATH, which points into the actual nix package. You’d need to use realpath to follow the chain of symlinks to its actual end.
As for why there’s another layer of symlink, that seems to be because the nix package is built in pieces and then symlinked together into a single store object.
If I’m following the nix packaging correctly, you can find the underlying package with the cli command in it, from inside the nix language, from lib.getExe pkgs.nix.nix-cli.
Thanks a lot @tejing, lib.getExe pkgs.nix.nix-cli works.
If I’m following the nix packaging correctly, you can find the underlying package with the cli command in it, from inside the nix language, from lib.getExe pkgs.nix.nix-cli.
Would you mind telling me how you figured this out? I’ve been checking nixpkgs since your reply, but still have no clue how to do it.