Accessing output paths from Nix

When I look at existing derivations, it is possible to access the output paths (e.g. for out or dev) from shell code like a shell variable (e.g. $out or $dev).

But how do I access these from Nix?

Basically, I would like to have a Nix function f that can do something like f "out" resulting it "$out" so I can build strings for runCommand from Nix and use them to fill arbitrary output paths. I can do this for output paths from already realized packages (e.g. f = output: (lib.attrByPath [output] {} pkgs.somepackage), but I can’t get it to work for finding out the paths where to put derivation outputs into.

builtins.placeholder might be what you’re looking for?

1 Like