diff options
author | Robert Hensing <roberth@users.noreply.github.com> | 2022-09-19 11:30:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-19 11:30:37 +0100 |
commit | 8deb17a36ea920ba71d7f3d62052f2aeb2da9fdd (patch) | |
tree | 456799be4750e3144bd8d8dc584cba4db83a3562 /pkgs/build-support | |
parent | 00035c629553f363f20e650ce431213d2e584667 (diff) | |
parent | c078d552fe1e5c35931997c24c8e9b6cf48e3c7b (diff) | |
download | nixlib-8deb17a36ea920ba71d7f3d62052f2aeb2da9fdd.tar nixlib-8deb17a36ea920ba71d7f3d62052f2aeb2da9fdd.tar.gz nixlib-8deb17a36ea920ba71d7f3d62052f2aeb2da9fdd.tar.bz2 nixlib-8deb17a36ea920ba71d7f3d62052f2aeb2da9fdd.tar.lz nixlib-8deb17a36ea920ba71d7f3d62052f2aeb2da9fdd.tar.xz nixlib-8deb17a36ea920ba71d7f3d62052f2aeb2da9fdd.tar.zst nixlib-8deb17a36ea920ba71d7f3d62052f2aeb2da9fdd.zip |
Merge pull request #186323 from ShamrockLee/make-setuphook-passthru
trivial-builders.nix: Add input argument `passthru` to makeSetupHook
Diffstat (limited to 'pkgs/build-support')
4 files changed, 30 insertions, 8 deletions
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 9f52a05f61ca..c9b03b75cd03 100644 --- a/pkgs/build-support/setup-hooks/make-binary-wrapper/default.nix +++ b/pkgs/build-support/setup-hooks/make-binary-wrapper/default.nix @@ -16,12 +16,14 @@ makeSetupHook { substitutions = { cc = "${cc}/bin/${cc.targetPrefix}cc ${lib.escapeShellArgs (map (s: "-fsanitize=${s}") sanitizers)}"; + }; + passthru = { # Extract the function call used to create a binary wrapper from its embedded docstring - passthru.extractCmd = writeShellScript "extract-binary-wrapper-cmd" '' + extractCmd = writeShellScript "extract-binary-wrapper-cmd" '' strings -dw "$1" | sed -n '/^makeCWrapper/,/^$/ p' ''; - passthru.tests = tests.makeBinaryWrapper; + tests = tests.makeBinaryWrapper; }; } ./make-binary-wrapper.sh diff --git a/pkgs/build-support/setup-hooks/postgresql-test-hook/default.nix b/pkgs/build-support/setup-hooks/postgresql-test-hook/default.nix index d0031c93c10c..e9e77b0bbe6f 100644 --- a/pkgs/build-support/setup-hooks/postgresql-test-hook/default.nix +++ b/pkgs/build-support/setup-hooks/postgresql-test-hook/default.nix @@ -1,9 +1,8 @@ { callPackage, makeSetupHook }: -(makeSetupHook { +makeSetupHook { name = "postgresql-test-hook"; -} ./postgresql-test-hook.sh).overrideAttrs (o: { passthru.tests = { simple = callPackage ./test.nix { }; }; -}) +} ./postgresql-test-hook.sh 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 d7699b2557fc..5ef613838856 100644 --- a/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix +++ b/pkgs/build-support/setup-hooks/wrap-gapps-hook/default.nix @@ -13,6 +13,7 @@ }: makeSetupHook { + name = "wrap-gapps-hook"; deps = lib.optionals (!stdenv.isDarwin) [ # It is highly probable that a program will use GSettings, # at minimum through GTK file chooser dialogue. @@ -36,8 +37,8 @@ makeSetupHook { # We use the wrapProgram function. makeWrapper ]; - substitutions = { - passthru.tests = let + passthru = { + tests = let sample-project = ./tests/sample-project; testLib = callPackage ./tests/lib.nix { }; diff --git a/pkgs/build-support/trivial-builders.nix b/pkgs/build-support/trivial-builders.nix index e73cb9c5decb..a8c291b82324 100644 --- a/pkgs/build-support/trivial-builders.nix +++ b/pkgs/build-support/trivial-builders.nix @@ -1,5 +1,12 @@ { lib, stdenv, stdenvNoCC, lndir, runtimeShell, shellcheck }: +let + inherit (lib) + optionalAttrs + warn + ; +in + rec { /* Run the shell command `buildCommand' to produce a store path named @@ -525,12 +532,25 @@ rec { * substitutions = { bash = "${pkgs.bash}/bin/bash"; }; * meta.platforms = lib.platforms.linux; * } ./myscript.sh; + * + * # setup hook with a package test + * myhellohookTested = makeSetupHook { + * deps = [ hello ]; + * substitutions = { bash = "${pkgs.bash}/bin/bash"; }; + * meta.platforms = lib.platforms.linux; + * passthru.tests.greeting = callPackage ./test { }; + * } ./myscript.sh; */ - makeSetupHook = { name ? "hook", deps ? [], substitutions ? {}, meta ? {} }: script: + makeSetupHook = { name ? "hook", deps ? [], substitutions ? {}, meta ? {}, passthru ? {} }: script: runCommand name (substitutions // { inherit meta; 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 |