Ideomatic way to invoke setup hooks inside `runCommand`

As runCommand-like builders doesn’t have nativeBuildInputs, there seems to be no places for the setup hooks to drop in and get sourced by the builder.

Should we

source "${makeWrapper}/nix-support/setup-hook"

to invoke a setup hook? Or is there a better (more idiomatic) way to do so?

How about buildFHSUserEnv and appimageTools.wrapType2?

  1. runCommand just calls stdenv.mkDerivation anyway, so you can pass nativeBuildInputs to it:
runCommand "name" {
  nativeBuildInputs = [ whatever ];
} ''
  script
''
  1. You can just use stdenv.mkDerivation:
stdenv.mkDerivation {
  name = "name";

  nativeBuildInputs = [ whatever ];

  buildCommand = ''
    script
  '';
}
2 Likes