vuls: init at 0.27.0
[NixPkgs.git] / doc / build-helpers / special / makesetuphook.section.md
blob179d8d456372cb7bae88c3b21ed06619ccfa68cc
1 # pkgs.makeSetupHook {#sec-pkgs.makeSetupHook}
3 `pkgs.makeSetupHook` is a build helper that produces hooks that go in to `nativeBuildInputs`
5 ## Usage {#sec-pkgs.makeSetupHook-usage}
7 ```nix
8 pkgs.makeSetupHook {
9   name = "something-hook";
10   propagatedBuildInputs = [ pkgs.commandsomething ];
11   depsTargetTargetPropagated = [ pkgs.libsomething ];
12 } ./script.sh;
13 ```
15 ### setup hook that depends on the hello package and runs hello and @shell@ is substituted with path to bash {#sec-pkgs.makeSetupHook-usage-example}
17 ```nix
18 pkgs.makeSetupHook
19   {
20     name = "run-hello-hook";
21     # Put dependencies here if they have hooks or necessary dependencies propagated
22     # otherwise prefer direct paths to executables.
23     propagatedBuildInputs = [
24       pkgs.hello
25       pkgs.cowsay
26     ];
27     substitutions = {
28       shell = "${pkgs.bash}/bin/bash";
29       cowsay = "${pkgs.cowsay}/bin/cowsay";
30     };
31   }
32   (
33     writeScript "run-hello-hook.sh" ''
34       #!@shell@
35       # the direct path to the executable has to be here because
36       # this will be run when the file is sourced
37       # at which point '$PATH' has not yet been populated with inputs
38       @cowsay@ cow
40       _printHelloHook() {
41         hello
42       }
43       preConfigureHooks+=(_printHelloHook)
44     ''
45   );
46 ```
48 ## Attributes {#sec-pkgs.makeSetupHook-attributes}
50 * `name` Set the name of the hook.
51 * `propagatedBuildInputs` Runtime dependencies (such as binaries) of the hook.
52 * `depsTargetTargetPropagated` Non-binary dependencies.
53 * `meta`
54 * `passthru`
55 * `substitutions` Variables for `substituteAll`