trivial-builders.nix: Add input argument `passthru` to makeSetupHook

One significant use case is adding `passthru.tests` to setup-hooks,
and help increase test coverage for mission-critical setup-hooks.

As `meta`, `passthru` doesn't go into the build script directly.
However, passing an empty set to `passthru` breaks nixpkgs-review
and OfBorg tests, so pass it only when specified.

+13 -4
+2 -3
pkgs/build-support/setup-hooks/postgresql-test-hook/default.nix
··· 1 1 { callPackage, makeSetupHook }: 2 2 3 - (makeSetupHook { 3 + makeSetupHook { 4 4 name = "postgresql-test-hook"; 5 - } ./postgresql-test-hook.sh).overrideAttrs (o: { 6 5 passthru.tests = { 7 6 simple = callPackage ./test.nix { }; 8 7 }; 9 - }) 8 + } ./postgresql-test-hook.sh
+11 -1
pkgs/build-support/trivial-builders.nix
··· 523 523 * substitutions = { bash = "${pkgs.bash}/bin/bash"; }; 524 524 * meta.platforms = lib.platforms.linux; 525 525 * } ./myscript.sh; 526 + * 527 + * # setup hook with a package test 528 + * myhellohookTested = makeSetupHook { 529 + * deps = [ hello ]; 530 + * substitutions = { bash = "${pkgs.bash}/bin/bash"; }; 531 + * meta.platforms = lib.platforms.linux; 532 + * passthru.tests.greeting = callPackage ./test { }; 533 + * } ./myscript.sh; 526 534 */ 527 - makeSetupHook = { name ? "hook", deps ? [], substitutions ? {}, meta ? {} }: script: 535 + makeSetupHook = { name ? "hook", deps ? [], substitutions ? {}, meta ? {}, passthru ? null }: script: 528 536 runCommand name 529 537 (substitutions // { 530 538 inherit meta; 531 539 strictDeps = true; 540 + } // lib.optionalAttrs (passthru != null) { 541 + inherit passthru; 532 542 }) 533 543 ('' 534 544 mkdir -p $out/nix-support