diff options
author | Shamrock Lee <44064051+ShamrockLee@users.noreply.github.com> | 2022-08-12 16:29:37 +0800 |
---|---|---|
committer | Shamrock Lee <44064051+ShamrockLee@users.noreply.github.com> | 2022-08-13 04:20:12 +0800 |
commit | ba895a7da8f86c6f924fc96026d8f1cb1ea2af1e (patch) | |
tree | 7b52f68ddd1df0ea7a6e583337a4b845e834efd9 /pkgs | |
parent | c4a0efdd5a728e20791b8d8d2f26f90ac228ee8d (diff) |
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.
Diffstat (limited to 'pkgs')
-rw-r--r-- | pkgs/build-support/setup-hooks/postgresql-test-hook/default.nix | 5 | ||||
-rw-r--r-- | pkgs/build-support/trivial-builders.nix | 12 |
2 files changed, 13 insertions, 4 deletions
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 d0031c93c10cb..e9e77b0bbe6f8 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/trivial-builders.nix b/pkgs/build-support/trivial-builders.nix index c889b3865f658..f74d686b69244 100644 --- a/pkgs/build-support/trivial-builders.nix +++ b/pkgs/build-support/trivial-builders.nix @@ -523,12 +523,22 @@ 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 ? null }: script: runCommand name (substitutions // { inherit meta; strictDeps = true; + } // lib.optionalAttrs (passthru != null) { + inherit passthru; }) ('' mkdir -p $out/nix-support |