query
On this page

makeSetupHook

pkgs.makeSetupHook

Docs pulled from | This Revision | 18 minutes ago


Nixpkgs manual

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 ? [ ],
      propagatedNativeBuildInputs ? [ ],
      # these will be buildInputs
      depsTargetTargetPropagated ? [ ],
      meta ? { },
      passthru ? { },
      substitutions ? { },
    }@args:
    script:
    runCommand name
      (
        substitutions
        // {
          # Make the position of the derivation accurate.
          # Since not having `name` is deprecated, this should be fairly accurate.
          pos = lib.unsafeGetAttrPos "name" args;
          # 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;
          pname = name;
          version = lib.trivial.release + "pre-git";
          inherit meta;
          inherit depsTargetTargetPropagated;
          inherit propagatedBuildInputs;
          inherit propagatedNativeBuildInputs;
          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
        ''
      );