Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: sec-pkgs.makeSetupHook-usage-example unclear #320047

Closed
3 tasks done
MathiasSven opened this issue Jun 15, 2024 · 1 comment · Fixed by #320107
Closed
3 tasks done

Documentation: sec-pkgs.makeSetupHook-usage-example unclear #320047

MathiasSven opened this issue Jun 15, 2024 · 1 comment · Fixed by #320107

Comments

@MathiasSven
Copy link
Contributor

Problem

The makeSetupHook-usage-example in the nixpkgs manual has this example:

```nix
pkgs.makeSetupHook {
name = "run-hello-hook";
propagatedBuildInputs = [ pkgs.hello ];
substitutions = { shell = "${pkgs.bash}/bin/bash"; };
passthru.tests.greeting = callPackage ./test { };
meta.platforms = lib.platforms.linux;
} (writeScript "run-hello-hook.sh" ''
#!@shell@
hello
'')
```

But it isn't clear how this is supposed to be used. propagatedBuildInputs suggests that the hook is self-contained in its dependency, but this example fails to build:

{ pkgs ? import <nixpkgs> { } }:

let
  inherit (pkgs) writeScript;
  myHook = pkgs.makeSetupHook {
      name = "run-hello-hook";
      propagatedBuildInputs = [ pkgs.hello ];
      substitutions = { shell = "${pkgs.bash}/bin/bash"; };
  } (writeScript "run-hello-hook.sh" ''
      #!@shell@
      hello
  '');
in
  pkgs.stdenv.mkDerivation {
    name = "foobar-test";
    dontUnpack = true;
    nativeBuildInputs = [ myHook ];
    dontBuild = true;
    installPhase = ''
      echo "foobar" > $out
    '';
  }

With hello: command not found

@Artturin

Proposal

Give a minimal example usage of it.

Checklist


Add a 👍 reaction to issues you find important.

@Artturin
Copy link
Member

#320107

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants