query
On this page

makeSetupHook

pkgs.makeSetupHook

Docs pulled from | This Revision | about 2 hours ago


See https://nixos.org/manual/nixpkgs/unstable/#sec-pkgs.makeSetupHook


Noogle detected

Implementation

The following is the current implementation of this function.

makeSetupHook =
    {
      name ? lib.warn "calling makeSetupHook without passing a name is deprecated." "hook",
      # hooks go in nativeBuildInputs so these will be nativeBuildInputs
      propagatedBuildInputs ? [ ],
      # these will be buildInputs
      depsTargetTargetPropagated ? [ ],
      meta ? { },
      passthru ? { },
      substitutions ? { },
    }:
    script:
    runCommand name
      (
        substitutions
        // {
          # TODO(@Artturin:) substitutions should be inside the env attrset
          # but users are likely passing non-substitution arguments through substitutions
          # turn off __structuredAttrs to unbreak substituteAll
          __structuredAttrs = false;
          inherit meta;
          inherit depsTargetTargetPropagated;
          inherit propagatedBuildInputs;
          strictDeps = true;
          # TODO 2023-01, no backport: simplify to inherit passthru;
          passthru =
            passthru
            // optionalAttrs (substitutions ? passthru) (
              warn "makeSetupHook (name = ${lib.strings.escapeNixString name}): `substitutions.passthru` is deprecated. Please set `passthru` directly." substitutions.passthru
            );
        }
      )
      (
        ''
          mkdir -p $out/nix-support
          cp ${script} $out/nix-support/setup-hook
          recordPropagatedDependencies
        ''
        + lib.optionalString (substitutions != { }) ''
          substituteAll ${script} $out/nix-support/setup-hook
        ''
      );