diff --git a/doc/builders/special.xml b/doc/builders/special.xml index 525eb71abfe7..c97113481981 100644 --- a/doc/builders/special.xml +++ b/doc/builders/special.xml @@ -6,6 +6,7 @@ This chapter describes several special builders. + diff --git a/doc/builders/special/makesetuphook.section.md b/doc/builders/special/makesetuphook.section.md new file mode 100644 index 000000000000..90d75c5491cf --- /dev/null +++ b/doc/builders/special/makesetuphook.section.md @@ -0,0 +1,37 @@ +# pkgs.makeSetupHook {#sec-pkgs.makeSetupHook} + +`pkgs.makeSetupHook` is a builder that produces hooks that go in to `nativeBuildInputs` + +## Usage {#sec-pkgs.makeSetupHook-usage} + +```nix +pkgs.makeSetupHook { + name = "something-hook"; + propagatedBuildInputs = [ pkgs.commandsomething ]; + depsTargetTargetPropagated = [ pkgs.libsomething ]; +} ./script.sh +``` + +#### setup hook that depends on the hello package and runs hello and @shell@ is substituted with path to bash + +```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 +'') +``` + +## Attributes + +* `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` diff --git a/pkgs/applications/editors/vim/plugins/vim-utils.nix b/pkgs/applications/editors/vim/plugins/vim-utils.nix index 4235aa5e929e..5c7f6f64a7c3 100644 --- a/pkgs/applications/editors/vim/plugins/vim-utils.nix +++ b/pkgs/applications/editors/vim/plugins/vim-utils.nix @@ -363,7 +363,7 @@ rec { vimGenDocHook = callPackage ({ vim }: makeSetupHook { name = "vim-gen-doc-hook"; - deps = [ vim ]; + propagatedBuildInputs = [ vim ]; substitutions = { vimBinary = "${vim}/bin/vim"; inherit rtpPath; @@ -373,7 +373,7 @@ rec { vimCommandCheckHook = callPackage ({ neovim-unwrapped }: makeSetupHook { name = "vim-command-check-hook"; - deps = [ neovim-unwrapped ]; + propagatedBuildInputs = [ neovim-unwrapped ]; substitutions = { vimBinary = "${neovim-unwrapped}/bin/nvim"; inherit rtpPath; @@ -383,7 +383,7 @@ rec { neovimRequireCheckHook = callPackage ({ neovim-unwrapped }: makeSetupHook { name = "neovim-require-check-hook"; - deps = [ neovim-unwrapped ]; + propagatedBuildInputs = [ neovim-unwrapped ]; substitutions = { nvimBinary = "${neovim-unwrapped}/bin/nvim"; inherit rtpPath; diff --git a/pkgs/build-support/dotnet/build-dotnet-module/hooks/default.nix b/pkgs/build-support/dotnet/build-dotnet-module/hooks/default.nix index bce3d799fbb1..a72f0291a872 100644 --- a/pkgs/build-support/dotnet/build-dotnet-module/hooks/default.nix +++ b/pkgs/build-support/dotnet/build-dotnet-module/hooks/default.nix @@ -20,7 +20,7 @@ in dotnetConfigureHook = callPackage ({ }: makeSetupHook { name = "dotnet-configure-hook"; - deps = [ dotnet-sdk nuget-source ]; + propagatedBuildInputs = [ dotnet-sdk nuget-source ]; substitutions = { nugetSource = nuget-source; inherit runtimeId; @@ -30,7 +30,7 @@ in dotnetBuildHook = callPackage ({ }: makeSetupHook { name = "dotnet-build-hook"; - deps = [ dotnet-sdk ]; + propagatedBuildInputs = [ dotnet-sdk ]; substitutions = { inherit buildType runtimeId; }; @@ -39,7 +39,7 @@ in dotnetCheckHook = callPackage ({ }: makeSetupHook { name = "dotnet-check-hook"; - deps = [ dotnet-test-sdk ]; + propagatedBuildInputs = [ dotnet-test-sdk ]; substitutions = { inherit buildType libraryPath; disabledTests = lib.optionalString (disabledTests != []) @@ -54,7 +54,7 @@ in dotnetInstallHook = callPackage ({ }: makeSetupHook { name = "dotnet-install-hook"; - deps = [ dotnet-sdk ]; + propagatedBuildInputs = [ dotnet-sdk ]; substitutions = { inherit buildType runtimeId; }; @@ -63,7 +63,7 @@ in dotnetFixupHook = callPackage ({ }: makeSetupHook { name = "dotnet-fixup-hook"; - deps = [ dotnet-runtime ]; + propagatedBuildInputs = [ dotnet-runtime ]; substitutions = { dotnetRuntime = dotnet-runtime; runtimeDeps = libraryPath; diff --git a/pkgs/build-support/node/build-npm-package/hooks/default.nix b/pkgs/build-support/node/build-npm-package/hooks/default.nix index 65ac661cea51..e5c93f1f7784 100644 --- a/pkgs/build-support/node/build-npm-package/hooks/default.nix +++ b/pkgs/build-support/node/build-npm-package/hooks/default.nix @@ -26,7 +26,7 @@ npmInstallHook = makeSetupHook { name = "npm-install-hook"; - deps = [ buildPackages.makeWrapper ]; + propagatedBuildInputs = [ buildPackages.makeWrapper ]; substitutions = { hostNode = "${nodejs}/bin/node"; jq = "${buildPackages.jq}/bin/jq"; diff --git a/pkgs/build-support/rust/hooks/default.nix b/pkgs/build-support/rust/hooks/default.nix index 9989e582d2e9..b4034120103e 100644 --- a/pkgs/build-support/rust/hooks/default.nix +++ b/pkgs/build-support/rust/hooks/default.nix @@ -31,7 +31,7 @@ in { cargoBuildHook = callPackage ({ }: makeSetupHook { name = "cargo-build-hook.sh"; - deps = [ cargo ]; + propagatedBuildInputs = [ cargo ]; substitutions = { inherit ccForBuild ccForHost cxxForBuild cxxForHost rustBuildPlatform rustTargetPlatform rustTargetPlatformSpec; @@ -41,7 +41,7 @@ in { cargoCheckHook = callPackage ({ }: makeSetupHook { name = "cargo-check-hook.sh"; - deps = [ cargo ]; + propagatedBuildInputs = [ cargo ]; substitutions = { inherit rustTargetPlatformSpec; }; @@ -50,7 +50,7 @@ in { cargoInstallHook = callPackage ({ }: makeSetupHook { name = "cargo-install-hook.sh"; - deps = [ ]; + propagatedBuildInputs = [ ]; substitutions = { inherit shortTarget; }; @@ -59,7 +59,7 @@ in { cargoNextestHook = callPackage ({ }: makeSetupHook { name = "cargo-nextest-hook.sh"; - deps = [ cargo cargo-nextest ]; + propagatedBuildInputs = [ cargo cargo-nextest ]; substitutions = { inherit rustTargetPlatformSpec; }; @@ -68,7 +68,7 @@ in { cargoSetupHook = callPackage ({ }: makeSetupHook { name = "cargo-setup-hook.sh"; - deps = [ ]; + propagatedBuildInputs = [ ]; substitutions = { defaultConfig = ../fetchcargo-default-config.toml; @@ -117,7 +117,7 @@ in { maturinBuildHook = callPackage ({ }: makeSetupHook { name = "maturin-build-hook.sh"; - deps = [ cargo maturin rustc ]; + propagatedBuildInputs = [ cargo maturin rustc ]; substitutions = { inherit ccForBuild ccForHost cxxForBuild cxxForHost rustBuildPlatform rustTargetPlatform rustTargetPlatformSpec; diff --git a/pkgs/build-support/setup-hooks/make-binary-wrapper/default.nix b/pkgs/build-support/setup-hooks/make-binary-wrapper/default.nix index c81a253b0de8..17b97b1082e9 100644 --- a/pkgs/build-support/setup-hooks/make-binary-wrapper/default.nix +++ b/pkgs/build-support/setup-hooks/make-binary-wrapper/default.nix @@ -11,8 +11,7 @@ makeSetupHook { name = "make-binary-wrapper-hook"; - - deps = [ dieHook ] + propagatedBuildInputs = [ dieHook ] # https://github.com/NixOS/nixpkgs/issues/148189 ++ lib.optional (stdenv.isDarwin && stdenv.isAarch64) cc; diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix b/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix index 5ef613838856..99633a3c7c9a 100644 --- a/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix +++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix @@ -9,12 +9,15 @@ , dconf , callPackage , wrapGAppsHook -, writeTextFile +, targetPackages }: makeSetupHook { name = "wrap-gapps-hook"; - deps = lib.optionals (!stdenv.isDarwin) [ + propagatedBuildInputs = [ + # We use the wrapProgram function. + makeWrapper + ] ++ lib.optionals (!stdenv.isDarwin) [ # It is highly probable that a program will use GSettings, # at minimum through GTK file chooser dialogue. # Let’s add a GIO module for “dconf” GSettings backend @@ -23,19 +26,22 @@ makeSetupHook { # Unfortunately, it also requires the user to have dconf # D-Bus service enabled globally (e.g. through a NixOS module). dconf.lib + ] ++ lib.optionals isGraphical [ # TODO: remove this, packages should depend on GTK explicitly. gtk3 + librsvg + ]; + + # depsTargetTargetPropagated will essentially be buildInputs when wrapGAppsHook is placed into nativeBuildInputs + # the librsvg above should be removed but kept to not break anything that implicitly depended on its binaries + depsTargetTargetPropagated = assert (lib.assertMsg (!targetPackages ? raw) "wrapGAppsHook must be in nativeBuildInputs"); lib.optionals isGraphical [ # librsvg provides a module for gdk-pixbuf to allow rendering # SVG icons. Most icon themes are SVG-based and so are some # graphics in GTK (e.g. cross for closing window in window title bar) # so it is pretty much required for applications using GTK. librsvg - ] ++ [ - - # We use the wrapProgram function. - makeWrapper ]; passthru = { tests = let @@ -65,6 +71,15 @@ makeSetupHook { '' ); + basic-contains-gdk-pixbuf = let + tested = basic; + in testLib.runTest "basic-contains-gdk-pixbuf" ( + testLib.skip stdenv.isDarwin '' + ${expectSomeLineContainingYInFileXToMentionZ "${tested}/bin/foo" "GDK_PIXBUF_MODULE_FILE" "${lib.getLib librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"} + ${expectSomeLineContainingYInFileXToMentionZ "${tested}/libexec/bar" "GDK_PIXBUF_MODULE_FILE" "${lib.getLib librsvg}/lib/gdk-pixbuf-2.0/2.10.0/loaders.cache"} + '' + ); + # Simple derivation containing a gobject-introspection typelib. typelib-Mahjong = stdenv.mkDerivation { name = "typelib-Mahjong"; diff --git a/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/lib.nix b/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/lib.nix index 42866c3419dd..59fa9de24f9d 100644 --- a/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/lib.nix +++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook/tests/lib.nix @@ -1,7 +1,7 @@ { lib, runCommand }: rec { - runTest = name: body: runCommand name { } '' + runTest = name: body: runCommand name { strictDeps = true; } '' set -o errexit ${body} touch $out diff --git a/pkgs/build-support/trivial-builders.nix b/pkgs/build-support/trivial-builders.nix index 7318d13f6bab..413ed65852f5 100644 --- a/pkgs/build-support/trivial-builders.nix +++ b/pkgs/build-support/trivial-builders.nix @@ -593,45 +593,28 @@ rec { in linkFarm name (map mkEntryFromDrv drvs); - /* - Make a package that just contains a setup hook with the given contents. - This setup hook will be invoked by any package that includes this package - as a buildInput. Optionally takes a list of substitutions that should be - applied to the resulting script. - - Examples: - # setup hook that depends on the hello package and runs ./myscript.sh - myhellohook = makeSetupHook { deps = [ hello ]; } ./myscript.sh; - - # writes a Linux-exclusive setup hook where @bash@ myscript.sh is substituted for the - # bash interpreter. - myhellohookSub = makeSetupHook { - name = "myscript-hook"; - deps = [ hello ]; - substitutions = { bash = "${pkgs.bash}/bin/bash"; }; - meta.platforms = lib.platforms.linux; - } ./myscript.sh; - - # setup hook with a package test - myhellohookTested = makeSetupHook { - name = "myscript-hook"; - deps = [ hello ]; - substitutions = { bash = "${pkgs.bash}/bin/bash"; }; - meta.platforms = lib.platforms.linux; - passthru.tests.greeting = callPackage ./test { }; - } ./myscript.sh; - */ + # docs in doc/builders/special/makesetuphook.section.md makeSetupHook = { name ? lib.warn "calling makeSetupHook without passing a name is deprecated." "hook" - , deps ? [] - , substitutions ? {} - , meta ? {} - , passthru ? {} + , deps ? [ ] + # hooks go in nativeBuildInput so these will be nativeBuildInput + , propagatedBuildInputs ? [ ] + # these will be buildInputs + , depsTargetTargetPropagated ? [ ] + , meta ? { } + , passthru ? { } + , substitutions ? { } }: script: runCommand name (substitutions // { inherit meta; + inherit depsTargetTargetPropagated; + propagatedBuildInputs = + # remove list conditionals before 23.11 + lib.warnIf (!lib.isList deps) "'deps' argument to makeSetupHook must be a list. content of deps: ${toString deps}" + (lib.warnIf (deps != [ ]) "'deps' argument to makeSetupHook is deprecated and will be removed in release 23.11., Please use propagatedBuildInputs instead. content of deps: ${toString deps}" + propagatedBuildInputs ++ (if lib.isList deps then deps else [ deps ])); strictDeps = true; # TODO 2023-01, no backport: simplify to inherit passthru; passthru = passthru @@ -642,8 +625,7 @@ rec { ('' mkdir -p $out/nix-support cp ${script} $out/nix-support/setup-hook - '' + lib.optionalString (deps != []) '' - printWords ${toString deps} > $out/nix-support/propagated-build-inputs + recordPropagatedDependencies '' + lib.optionalString (substitutions != {}) '' substituteAll ${script} $out/nix-support/setup-hook ''); diff --git a/pkgs/development/interpreters/lua-5/hooks/default.nix b/pkgs/development/interpreters/lua-5/hooks/default.nix index fc92c59bb910..6c303f770dec 100644 --- a/pkgs/development/interpreters/lua-5/hooks/default.nix +++ b/pkgs/development/interpreters/lua-5/hooks/default.nix @@ -27,7 +27,7 @@ in { luarocksCheckHook = callPackage ({ luarocks }: makeSetupHook { name = "luarocks-check-hook"; - deps = [ luarocks ]; + propagatedBuildInputs = [ luarocks ]; } ./luarocks-check-hook.sh) {}; # luarocks installs data in a non-overridable location. Until a proper luarocks patch, @@ -35,6 +35,6 @@ in { luarocksMoveDataFolder = callPackage ({ }: makeSetupHook { name = "luarocks-move-rock"; - deps = [ ]; + propagatedBuildInputs = [ ]; } ./luarocks-move-data.sh) {}; } diff --git a/pkgs/development/interpreters/lua-5/wrap-lua.nix b/pkgs/development/interpreters/lua-5/wrap-lua.nix index c9ef151bea3c..43ececd1e794 100644 --- a/pkgs/development/interpreters/lua-5/wrap-lua.nix +++ b/pkgs/development/interpreters/lua-5/wrap-lua.nix @@ -8,7 +8,7 @@ # imported as wrapLua in lua-packages.nix and passed to build-lua-derivation to be used as buildInput makeSetupHook { name = "wrap-lua-hook"; - deps = makeWrapper; + propagatedBuildInputs = [ makeWrapper ]; substitutions.executable = lua.interpreter; substitutions.lua = lua; substitutions.LuaPathSearchPaths = lib.escapeShellArgs lua.LuaPathSearchPaths; diff --git a/pkgs/development/interpreters/octave/wrap-octave.nix b/pkgs/development/interpreters/octave/wrap-octave.nix index 1e4616136a1b..2317a479f0e2 100644 --- a/pkgs/development/interpreters/octave/wrap-octave.nix +++ b/pkgs/development/interpreters/octave/wrap-octave.nix @@ -10,7 +10,7 @@ # Each of the substitutions is available in the wrap.sh script as @thingSubstituted@ makeSetupHook { name = "${octave.name}-pkgs-setup-hook"; - deps = makeWrapper; + propagatedBuildInputs = [ makeWrapper ]; substitutions.executable = octave.interpreter; substitutions.octave = octave; } ./wrap.sh diff --git a/pkgs/development/interpreters/python/hooks/default.nix b/pkgs/development/interpreters/python/hooks/default.nix index 08dc3ea61ab7..001e477b9185 100644 --- a/pkgs/development/interpreters/python/hooks/default.nix +++ b/pkgs/development/interpreters/python/hooks/default.nix @@ -11,7 +11,7 @@ in { condaInstallHook = callPackage ({ makePythonHook, gnutar, lbzip2 }: makePythonHook { name = "conda-install-hook"; - deps = [ gnutar lbzip2 ]; + propagatedBuildInputs = [ gnutar lbzip2 ]; substitutions = { inherit pythonSitePackages; }; @@ -20,19 +20,19 @@ in { condaUnpackHook = callPackage ({ makePythonHook }: makePythonHook { name = "conda-unpack-hook"; - deps = []; + propagatedBuildInputs = []; } ./conda-unpack-hook.sh) {}; eggBuildHook = callPackage ({ makePythonHook }: makePythonHook { name = "egg-build-hook.sh"; - deps = [ ]; + propagatedBuildInputs = [ ]; } ./egg-build-hook.sh) {}; eggInstallHook = callPackage ({ makePythonHook, setuptools }: makePythonHook { name = "egg-install-hook.sh"; - deps = [ setuptools ]; + propagatedBuildInputs = [ setuptools ]; substitutions = { inherit pythonInterpreter pythonSitePackages; }; @@ -41,13 +41,13 @@ in { eggUnpackHook = callPackage ({ makePythonHook, }: makePythonHook { name = "egg-unpack-hook.sh"; - deps = [ ]; + propagatedBuildInputs = [ ]; } ./egg-unpack-hook.sh) {}; flitBuildHook = callPackage ({ makePythonHook, flit }: makePythonHook { name = "flit-build-hook"; - deps = [ flit ]; + propagatedBuildInputs = [ flit ]; substitutions = { inherit pythonInterpreter; }; @@ -56,7 +56,7 @@ in { pipBuildHook = callPackage ({ makePythonHook, pip, wheel }: makePythonHook { name = "pip-build-hook.sh"; - deps = [ pip wheel ]; + propagatedBuildInputs = [ pip wheel ]; substitutions = { inherit pythonInterpreter pythonSitePackages; }; @@ -65,7 +65,7 @@ in { pipInstallHook = callPackage ({ makePythonHook, pip }: makePythonHook { name = "pip-install-hook"; - deps = [ pip ]; + propagatedBuildInputs = [ pip ]; substitutions = { inherit pythonInterpreter pythonSitePackages; }; @@ -74,7 +74,7 @@ in { pytestCheckHook = callPackage ({ makePythonHook, pytest }: makePythonHook { name = "pytest-check-hook"; - deps = [ pytest ]; + propagatedBuildInputs = [ pytest ]; substitutions = { inherit pythonCheckInterpreter; }; @@ -123,7 +123,7 @@ in { pythonRelaxDepsHook = callPackage ({ makePythonHook, wheel }: makePythonHook { name = "python-relax-deps-hook"; - deps = [ wheel ]; + propagatedBuildInputs = [ wheel ]; substitutions = { inherit pythonInterpreter; }; @@ -145,7 +145,7 @@ in { setuptoolsBuildHook = callPackage ({ makePythonHook, setuptools, wheel }: makePythonHook { name = "setuptools-setup-hook"; - deps = [ setuptools wheel ]; + propagatedBuildInputs = [ setuptools wheel ]; substitutions = { inherit pythonInterpreter pythonSitePackages setuppy; }; @@ -154,7 +154,7 @@ in { setuptoolsCheckHook = callPackage ({ makePythonHook, setuptools }: makePythonHook { name = "setuptools-check-hook"; - deps = [ setuptools ]; + propagatedBuildInputs = [ setuptools ]; substitutions = { inherit pythonCheckInterpreter setuppy; }; @@ -171,7 +171,7 @@ in { venvShellHook = disabledIf (!isPy3k) (callPackage ({ makePythonHook, ensureNewerSourcesForZipFilesHook }: makePythonHook { name = "venv-shell-hook"; - deps = [ ensureNewerSourcesForZipFilesHook ]; + propagatedBuildInputs = [ ensureNewerSourcesForZipFilesHook ]; substitutions = { inherit pythonInterpreter; }; @@ -180,7 +180,7 @@ in { wheelUnpackHook = callPackage ({ makePythonHook, wheel }: makePythonHook { name = "wheel-unpack-hook.sh"; - deps = [ wheel ]; + propagatedBuildInputs = [ wheel ]; } ./wheel-unpack-hook.sh) {}; wrapPython = callPackage ../wrap-python.nix { @@ -190,6 +190,6 @@ in { sphinxHook = callPackage ({ makePythonHook, sphinx, installShellFiles }: makePythonHook { name = "python${python.pythonVersion}-sphinx-hook"; - deps = [ sphinx installShellFiles ]; + propagatedBuildInputs = [ sphinx installShellFiles ]; } ./sphinx-hook.sh) {}; } diff --git a/pkgs/development/interpreters/python/wrap-python.nix b/pkgs/development/interpreters/python/wrap-python.nix index 83da013bfd2d..c67a8e088514 100644 --- a/pkgs/development/interpreters/python/wrap-python.nix +++ b/pkgs/development/interpreters/python/wrap-python.nix @@ -5,7 +5,7 @@ makePythonHook { name = "wrap-python-hook"; - deps = makeWrapper; + propagatedBuildInputs = [ makeWrapper ]; substitutions.sitePackages = python.sitePackages; substitutions.executable = python.interpreter; substitutions.python = python.pythonForBuild; diff --git a/pkgs/development/interpreters/tcl/generic.nix b/pkgs/development/interpreters/tcl/generic.nix index 6351a08c1c07..6ce6e35189bf 100644 --- a/pkgs/development/interpreters/tcl/generic.nix +++ b/pkgs/development/interpreters/tcl/generic.nix @@ -53,7 +53,7 @@ let libdir = "lib/${libPrefix}"; tclPackageHook = callPackage ({ buildPackages }: makeSetupHook { name = "tcl-package-hook"; - deps = [ buildPackages.makeWrapper ]; + propagatedBuildInputs = [ buildPackages.makeWrapper ]; } ./tcl-package-hook.sh) {}; }; }; diff --git a/pkgs/development/libraries/qt-5/5.15/default.nix b/pkgs/development/libraries/qt-5/5.15/default.nix index 7d876d884b37..31de73b25edc 100644 --- a/pkgs/development/libraries/qt-5/5.15/default.nix +++ b/pkgs/development/libraries/qt-5/5.15/default.nix @@ -211,7 +211,7 @@ let qmake = makeSetupHook { name = "qmake-hook"; - deps = [ self.qtbase.dev ]; + propagatedBuildInputs = [ self.qtbase.dev ]; substitutions = { inherit debug; fix_qmake_libtool = ../hooks/fix-qmake-libtool.sh; @@ -220,7 +220,7 @@ let wrapQtAppsHook = makeSetupHook { name = "wrap-qt5-apps-hook"; - deps = [ self.qtbase.dev buildPackages.makeWrapper ] + propagatedBuildInputs = [ self.qtbase.dev buildPackages.makeWrapper ] ++ lib.optional stdenv.isLinux self.qtwayland.dev; } ../hooks/wrap-qt-apps-hook.sh; }; diff --git a/pkgs/development/libraries/qt-6/default.nix b/pkgs/development/libraries/qt-6/default.nix index b09521e34e3c..2577806b5c43 100644 --- a/pkgs/development/libraries/qt-6/default.nix +++ b/pkgs/development/libraries/qt-6/default.nix @@ -141,12 +141,12 @@ let wrapQtAppsHook = makeSetupHook { name = "wrap-qt6-apps-hook"; - deps = [ buildPackages.makeWrapper ]; + propagatedBuildInputs = [ buildPackages.makeWrapper ]; } ./hooks/wrap-qt-apps-hook.sh; qmake = makeSetupHook { name = "qmake6-hook"; - deps = [ self.qtbase.dev ]; + propagatedBuildInputs = [ self.qtbase.dev ]; substitutions = { inherit debug; fix_qmake_libtool = ./hooks/fix-qmake-libtool.sh; diff --git a/pkgs/development/tools/poetry2nix/poetry2nix/hooks/default.nix b/pkgs/development/tools/poetry2nix/poetry2nix/hooks/default.nix index a503ea594fb4..513d17fbbc2f 100644 --- a/pkgs/development/tools/poetry2nix/poetry2nix/hooks/default.nix +++ b/pkgs/development/tools/poetry2nix/poetry2nix/hooks/default.nix @@ -18,7 +18,7 @@ let makeSetupHook { name = "remove-path-dependencies.sh"; - deps = [ ]; + propagatedBuildInputs = [ ]; substitutions = { # NOTE: We have to use a non-overlayed Python here because otherwise we run into an infinite recursion # because building of tomlkit and its dependencies also use these hooks. @@ -50,7 +50,7 @@ in makeSetupHook { name = "pip-build-hook.sh"; - deps = [ pip wheel ]; + propagatedBuildInputs = [ pip wheel ]; substitutions = { inherit pythonInterpreter pythonSitePackages; }; @@ -64,7 +64,7 @@ in makeSetupHook { name = "fixup-hook.sh"; - deps = [ ]; + propagatedBuildInputs = [ ]; substitutions = { inherit pythonSitePackages; filenames = builtins.concatStringsSep " " [ @@ -84,7 +84,7 @@ in makeSetupHook { name = "wheel-unpack-hook.sh"; - deps = [ ]; + propagatedBuildInputs = [ ]; } ./wheel-unpack-hook.sh ) { }; diff --git a/pkgs/servers/x11/xorg/overrides.nix b/pkgs/servers/x11/xorg/overrides.nix index 565e8c188b76..1b4b5e000b78 100644 --- a/pkgs/servers/x11/xorg/overrides.nix +++ b/pkgs/servers/x11/xorg/overrides.nix @@ -26,7 +26,7 @@ self: super: { wrapWithXFileSearchPathHook = callPackage ({ makeBinaryWrapper, makeSetupHook, writeScript }: makeSetupHook { name = "wrapWithXFileSearchPathHook"; - deps = [ makeBinaryWrapper ]; + propagatedBuildInputs = [ makeBinaryWrapper ]; } (writeScript "wrapWithXFileSearchPathHook.sh" '' wrapWithXFileSearchPath() { paths=( diff --git a/pkgs/stdenv/generic/setup.sh b/pkgs/stdenv/generic/setup.sh index 6ea44a641cef..1a637bf13fdd 100644 --- a/pkgs/stdenv/generic/setup.sh +++ b/pkgs/stdenv/generic/setup.sh @@ -995,6 +995,39 @@ stripHash() { } +recordPropagatedDependencies() { + # Propagate dependencies into the development output. + declare -ra flatVars=( + # Build + depsBuildBuildPropagated + propagatedNativeBuildInputs + depsBuildTargetPropagated + # Host + depsHostHostPropagated + propagatedBuildInputs + # Target + depsTargetTargetPropagated + ) + declare -ra flatFiles=( + "${propagatedBuildDepFiles[@]}" + "${propagatedHostDepFiles[@]}" + "${propagatedTargetDepFiles[@]}" + ) + + local propagatedInputsIndex + for propagatedInputsIndex in "${!flatVars[@]}"; do + local propagatedInputsSlice="${flatVars[$propagatedInputsIndex]}[@]" + local propagatedInputsFile="${flatFiles[$propagatedInputsIndex]}" + + [[ "${!propagatedInputsSlice}" ]] || continue + + mkdir -p "${!outputDev}/nix-support" + # shellcheck disable=SC2086 + printWords ${!propagatedInputsSlice} > "${!outputDev}/nix-support/$propagatedInputsFile" + done +} + + unpackCmdHooks+=(_defaultUnpack) _defaultUnpack() { local fn="$1" @@ -1379,36 +1412,8 @@ fixupPhase() { done - # Propagate dependencies & setup hook into the development output. - declare -ra flatVars=( - # Build - depsBuildBuildPropagated - propagatedNativeBuildInputs - depsBuildTargetPropagated - # Host - depsHostHostPropagated - propagatedBuildInputs - # Target - depsTargetTargetPropagated - ) - declare -ra flatFiles=( - "${propagatedBuildDepFiles[@]}" - "${propagatedHostDepFiles[@]}" - "${propagatedTargetDepFiles[@]}" - ) - - local propagatedInputsIndex - for propagatedInputsIndex in "${!flatVars[@]}"; do - local propagatedInputsSlice="${flatVars[$propagatedInputsIndex]}[@]" - local propagatedInputsFile="${flatFiles[$propagatedInputsIndex]}" - - [[ "${!propagatedInputsSlice}" ]] || continue - - mkdir -p "${!outputDev}/nix-support" - # shellcheck disable=SC2086 - printWords ${!propagatedInputsSlice} > "${!outputDev}/nix-support/$propagatedInputsFile" - done - + # record propagated dependencies & setup hook into the development output. + recordPropagatedDependencies if [ -n "${setupHook:-}" ]; then mkdir -p "${!outputDev}/nix-support" diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 34130446731d..b0f0bd890dd2 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -160,14 +160,14 @@ with pkgs; ### BUILD SUPPORT auditBlasHook = makeSetupHook - { name = "auto-blas-hook"; deps = [ blas lapack ]; } + { name = "auto-blas-hook"; propagatedBuildInputs = [ blas lapack ]; } ../build-support/setup-hooks/audit-blas.sh; autoreconfHook = callPackage ( { makeSetupHook, autoconf, automake, gettext, libtool }: makeSetupHook { name = "autoreconf-hook"; - deps = [ autoconf automake gettext libtool ]; + propagatedBuildInputs = [ autoconf automake gettext libtool ]; } ../build-support/setup-hooks/autoreconf.sh ) { }; @@ -184,7 +184,7 @@ with pkgs; autoPatchelfHook = makeSetupHook { name = "auto-patchelf-hook"; - deps = [ bintools ]; + propagatedBuildInputs = [ bintools ]; substitutions = { pythonInterpreter = "${python3.withPackages (ps: [ ps.pyelftools ])}/bin/python"; autoPatchelfScript = ../build-support/setup-hooks/auto-patchelf.py; @@ -356,7 +356,7 @@ with pkgs; gogUnpackHook = makeSetupHook { name = "gog-unpack-hook"; - deps = [ innoextract file-rename ]; } + propagatedBuildInputs = [ innoextract file-rename ]; } ../build-support/setup-hooks/gog-unpack.sh; buildEnv = callPackage ../build-support/buildenv { }; # not actually a package @@ -1014,7 +1014,7 @@ with pkgs; makeShellWrapper = makeSetupHook { name = "make-shell-wrapper-hook"; - deps = [ dieHook ]; + propagatedBuildInputs = [ dieHook ]; substitutions = { # targetPackages.runtimeShell only exists when pkgs == targetPackages (when targetPackages is not __raw) shell = if targetPackages ? runtimeShell then targetPackages.runtimeShell else throw "makeWrapper/makeShellWrapper must be in nativeBuildInputs"; @@ -1067,7 +1067,7 @@ with pkgs; shortenPerlShebang = makeSetupHook { name = "shorten-perl-shebang-hook"; - deps = [ dieHook ]; + propagatedBuildInputs = [ dieHook ]; } ../build-support/setup-hooks/shorten-perl-shebang.sh; singularity-tools = callPackage ../build-support/singularity-tools { }; @@ -1119,7 +1119,7 @@ with pkgs; desktopToDarwinBundle = makeSetupHook { name = "desktop-to-darwin-bundle-hook"; - deps = [ writeDarwinBundle librsvg imagemagick python3Packages.icnsutil ]; + propagatedBuildInputs = [ writeDarwinBundle librsvg imagemagick python3Packages.icnsutil ]; } ../build-support/setup-hooks/desktop-to-darwin-bundle.sh; keepBuildTree = makeSetupHook { @@ -1132,7 +1132,7 @@ with pkgs; makeGCOVReport = makeSetupHook { name = "make-gcov-report-hook"; - deps = [ lcov enableGCOVInstrumentation ]; + propagatedBuildInputs = [ lcov enableGCOVInstrumentation ]; } ../build-support/setup-hooks/make-coverage-analysis-report.sh; makeHardcodeGsettingsPatch = callPackage ../build-support/make-hardcode-gsettings-patch { }; @@ -1167,7 +1167,7 @@ with pkgs; iconConvTools = callPackage ../build-support/icon-conv-tools {}; validatePkgConfig = makeSetupHook - { name = "validate-pkg-config"; deps = [ findutils pkg-config ]; } + { name = "validate-pkg-config"; propagatedBuildInputs = [ findutils pkg-config ]; } ../build-support/setup-hooks/validate-pkg-config.sh; patchPpdFilesHook = callPackage ../build-support/setup-hooks/patch-ppd-files {}; @@ -18793,13 +18793,13 @@ with pkgs; xcbuild = xcodebuild; xcbuildHook = makeSetupHook { name = "xcbuild-hook"; - deps = [ xcbuild ]; + propagatedBuildInputs = [ xcbuild ]; } ../development/tools/xcbuild/setup-hook.sh ; # xcbuild with llvm 6 xcbuild6Hook = makeSetupHook { name = "xcbuild6-hook"; - deps = [ xcodebuild6 ]; + propagatedBuildInputs = [ xcodebuild6 ]; } ../development/tools/xcbuild/setup-hook.sh ; xcpretty = callPackage ../development/tools/xcpretty { }; @@ -22075,7 +22075,7 @@ with pkgs; memorymapping = callPackage ../development/libraries/memorymapping { }; memorymappingHook = makeSetupHook { name = "memorymapping-hook"; - deps = [ memorymapping ]; + propagatedBuildInputs = [ memorymapping ]; } ../development/libraries/memorymapping/setup-hook.sh; memray = callPackage ../development/tools/memray { }; @@ -22083,7 +22083,7 @@ with pkgs; memstream = callPackage ../development/libraries/memstream { }; memstreamHook = makeSetupHook { name = "memstream-hook"; - deps = [ memstream ]; + propagatedBuildInputs = [ memstream ]; } ../development/libraries/memstream/setup-hook.sh; menu-cache = callPackage ../development/libraries/menu-cache { }; diff --git a/pkgs/top-level/cuda-packages.nix b/pkgs/top-level/cuda-packages.nix index c57e486406e1..2044d74cab79 100644 --- a/pkgs/top-level/cuda-packages.nix +++ b/pkgs/top-level/cuda-packages.nix @@ -50,7 +50,7 @@ let autoAddOpenGLRunpathHook = final.callPackage ( { makeSetupHook, addOpenGLRunpath }: makeSetupHook { name = "auto-add-opengl-runpath-hook"; - deps = [ + propagatedBuildInputs = [ addOpenGLRunpath ]; } ../development/compilers/cudatoolkit/auto-add-opengl-runpath-hook.sh diff --git a/pkgs/top-level/darwin-packages.nix b/pkgs/top-level/darwin-packages.nix index b067f5cbbc1e..4ee606ae5e76 100644 --- a/pkgs/top-level/darwin-packages.nix +++ b/pkgs/top-level/darwin-packages.nix @@ -121,7 +121,7 @@ impure-cmds // appleSourcePackages // chooseLibs // { checkReexportsHook = pkgs.makeSetupHook { name = "darwin-check-reexports-hook"; - deps = [ pkgs.darwin.print-reexports ]; + propagatedBuildInputs = [ pkgs.darwin.print-reexports ]; } ../os-specific/darwin/print-reexports/setup-hook.sh; sigtool = callPackage ../os-specific/darwin/sigtool { }; @@ -142,7 +142,7 @@ impure-cmds // appleSourcePackages // chooseLibs // { autoSignDarwinBinariesHook = pkgs.makeSetupHook { name = "auto-sign-darwin-binaries-hook"; - deps = [ self.signingUtils ]; + propagatedBuildInputs = [ self.signingUtils ]; } ../os-specific/darwin/signing-utils/auto-sign-hook.sh; maloader = callPackage ../os-specific/darwin/maloader {