I know that a lot of what Nix does is working around its break from FHS, but I can imagine there are still things that seep through. Are there any unsolvable problems due to this?
I saw on this post that it is possible to use FHS on Nix. Does this solve all potential issues then?
It’s the same for Nixpkgs.
In well behaved build systems, it’s likely easier to package than most other distros. If it’s not as well behaved you will have to do some “exploration” and the complexity can get quite out of control if the build system is exceptionally terrible.
Here is the package for the GNU
hello
program which uses a well-behaved build system:https://github.com/NixOS/nixpkgs/blob/94b11073db6a7ca5733bc2d45378d800d9542975/pkgs/by-name/he/hello/package.nix
If you ignore the optional
passthru.tests
, this is very simple. You provide metadata, sources etc. to the genericmkDerivation
function and that’s it. The most complex non-standard thing this derivation does is enable the build system’s tests.You don’t even need to run the provided build instructions because Nixpkgs’ stdenv abstracts those away. If it finds a makefile, it’ll automatically run
make
andmake install
with the correct flags for instance. Same for other standard build systems; if you passcmake
intonativeBuildInputs
, it’ll attempt to build, install, check etc. usingcmake
’s standardised interfaces.If the build system is poorly behaved however (like for instance Anki’s), you will have to get into the weeds and do some rather advanced things:
https://github.com/NixOS/nixpkgs/blob/94b11073db6a7ca5733bc2d45378d800d9542975/pkgs/games/anki/default.nix
Luckily though, most packages aren’t like this.
Thank you for the thorough comment!