2023-03-04 12:14:45 +00:00
|
|
|
# pkgs.makeSetupHook {#sec-pkgs.makeSetupHook}
|
|
|
|
|
2023-11-16 04:20:00 +00:00
|
|
|
`pkgs.makeSetupHook` is a build helper that produces hooks that go in to `nativeBuildInputs`
|
2023-03-04 12:14:45 +00:00
|
|
|
|
|
|
|
## Usage {#sec-pkgs.makeSetupHook-usage}
|
|
|
|
|
|
|
|
```nix
|
|
|
|
pkgs.makeSetupHook {
|
|
|
|
name = "something-hook";
|
|
|
|
propagatedBuildInputs = [ pkgs.commandsomething ];
|
|
|
|
depsTargetTargetPropagated = [ pkgs.libsomething ];
|
2024-06-24 18:47:55 +00:00
|
|
|
} ./script.sh;
|
2023-03-04 12:14:45 +00:00
|
|
|
```
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
### setup hook that depends on the hello package and runs hello and @shell@ is substituted with path to bash {#sec-pkgs.makeSetupHook-usage-example}
|
2023-03-04 12:14:45 +00:00
|
|
|
|
|
|
|
```nix
|
2024-06-24 18:47:55 +00:00
|
|
|
pkgs.makeSetupHook
|
|
|
|
{
|
2023-03-04 12:14:45 +00:00
|
|
|
name = "run-hello-hook";
|
2024-06-24 18:47:55 +00:00
|
|
|
# Put dependencies here if they have hooks or necessary dependencies propagated
|
|
|
|
# otherwise prefer direct paths to executables.
|
|
|
|
propagatedBuildInputs = [
|
|
|
|
pkgs.hello
|
|
|
|
pkgs.cowsay
|
|
|
|
];
|
|
|
|
substitutions = {
|
|
|
|
shell = "${pkgs.bash}/bin/bash";
|
|
|
|
cowsay = "${pkgs.cowsay}/bin/cowsay";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
(
|
|
|
|
writeScript "run-hello-hook.sh" ''
|
|
|
|
#!@shell@
|
|
|
|
# the direct path to the executable has to be here because
|
|
|
|
# this will be run when the file is sourced
|
|
|
|
# at which point '$PATH' has not yet been populated with inputs
|
|
|
|
@cowsay@ cow
|
|
|
|
|
|
|
|
_printHelloHook() {
|
|
|
|
hello
|
|
|
|
}
|
|
|
|
preConfigureHooks+=(_printHelloHook)
|
|
|
|
''
|
|
|
|
);
|
2023-03-04 12:14:45 +00:00
|
|
|
```
|
|
|
|
|
2023-03-30 22:05:00 +00:00
|
|
|
## Attributes {#sec-pkgs.makeSetupHook-attributes}
|
2023-03-04 12:14:45 +00:00
|
|
|
|
|
|
|
* `name` Set the name of the hook.
|
|
|
|
* `propagatedBuildInputs` Runtime dependencies (such as binaries) of the hook.
|
|
|
|
* `depsTargetTargetPropagated` Non-binary dependencies.
|
|
|
|
* `meta`
|
|
|
|
* `passthru`
|
|
|
|
* `substitutions` Variables for `substituteAll`
|