wiki/notebook/tools.nix.nixpkgs.setup-hooks.org
Gabriel Arazas 5242780327 Revise Nix-related notes
Added more notes as I developed the Guix overlay for NixOS over time. It
does have a nice experience, overall (albeit clunky one due to the documentation).
2022-10-25 16:58:19 +08:00

1.6 KiB

nixpkgs setup hooks

Setup hooks are additional steps given from a package typically written as a shell script.

They are usually defined in a package with common build steps that would otherwise be repeated on a lot of packages such as…

  • Meson where it gives common arguments such as the GNU directory variables relative to the output from the derivation (i.e., out).
  • Guile where it set up different search paths related to GNU Guile.
  • Python also works similarly to Guile's only with a lot more of setup hooks for building and wrapping programs build with Python as it is used for various functions (e.g., buildPythonPackage, buildPythonApplication).

You can see more setup hooks example at pkgs/build-support/setup-hooks from roam:nixpkgs.

  • Adding a setup hook is made with setupHook attribute from stdenv.mkDerivation where it needs either a path or a derivation.
  • You could also make a setup hook with additional environment with makeSetupHook function.