How to write Nix friendly `Make install` targets?

What should the install target generally look like in a Makefile such that I don’t need a custom installPhase in mkDerivation?

Anything that follows the GNU Makefile Conventions should work fine. install should do nothing more than create directories as needed and copy files to their respective locations.

2 Likes

Mostly what’s good practice for portability generally is good for nix, too. But here are some important specifics:

  • Respect the configured prefix, or if you have no real configure step, allow the builder to set a prefix through make args. In nix, the prefix will be a nix store path.
  • Follow fhs conventions ($prefix/{bin,lib,share} etc, but no usr or opt or whatnot. That should be part of the prefix, conceptually.)

That’s most of it.

3 Likes