When packaging with Nix, sometimes the source files come in formats like .deb
or .tar.gz
, and the main application files may not follow the typical structure with bin
, lib
, etc. For example, a .deb
package might install files under a path like /opt/hello
. In such cases, what is the expected target path in the Nix out
directory?
It’s not very well documented. For one, there’s the concept of multi-output packages, which sets some expectations. For packages which definte that correctly, users can exclude certain general categories of installables (e.g. “documentation”) from what ends up on their system, so while it’s stringly typed and therefore free-form it’s worth being aware of the typical ones.
On NixOS, there is also pathsToLink
, which configures yet more standard paths that end up being used for e.g. fonts, or even vim plugins; Its configuration isn’t centralized so it’s tricky to get a full picture.
Generally, though, it’s the same as on other distros, except substituting $out
for $PREFIX
(in make terms). NixOS doesn’t follow fhs, so you might think this odd, but the /run/current-system
symlink still needs to be populated with something vaguely fhsey for a lot of software to work. So, when in doubt, put your files wherever the fhs spec says you should (treating $out
as /
).