From 221056c59ffab1e513fcf8ccb1079a8d44848fa9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Na=C3=AFm=20Favier?= Date: Fri, 2 Jun 2023 13:14:53 +0200 Subject: [PATCH] tests: fix `getOutput` on stubs Setting `outputSpecified` prevents `getOutput` from descending into outputs, which don't have an overridden `outPath`. Additionally, use `__spliced` to permit derivations to use the dummy as an input. --- .../modules/programs/autojump/default-settings.nix | 1 + tests/modules/services/git-sync/basic.nix | 2 +- tests/stubs.nix | 14 ++++++++++++-- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/tests/modules/programs/autojump/default-settings.nix b/tests/modules/programs/autojump/default-settings.nix index 2cca7de88..e7d40bb37 100644 --- a/tests/modules/programs/autojump/default-settings.nix +++ b/tests/modules/programs/autojump/default-settings.nix @@ -8,6 +8,7 @@ with lib; test.stubs.autojump = { buildScript = "mkdir -p $out/bin; touch $out/bin/autojump"; + outPath = null; }; nmt.script = '' diff --git a/tests/modules/services/git-sync/basic.nix b/tests/modules/services/git-sync/basic.nix index d4115641e..a82e9a4b1 100644 --- a/tests/modules/services/git-sync/basic.nix +++ b/tests/modules/services/git-sync/basic.nix @@ -24,7 +24,7 @@ WantedBy=default.target [Service] - Environment=PATH=/nix/store/00000000000000000000000000000000-openssh/bin:/nix/store/00000000000000000000000000000000-git/bin + Environment=PATH=@openssh@/bin:/nix/store/00000000000000000000000000000000-git/bin Environment=GIT_SYNC_DIRECTORY=/a/path Environment=GIT_SYNC_COMMAND=@git-sync@/bin/git-sync Environment=GIT_SYNC_REPOSITORY=git+ssh://user@example.com:/~user/path/to/repo.git diff --git a/tests/stubs.nix b/tests/stubs.nix index dacafeb7d..2d324c2c1 100644 --- a/tests/stubs.nix +++ b/tests/stubs.nix @@ -41,8 +41,18 @@ let dummyPackage else pkgs.runCommandLocal name { pname = name; } buildScript; - in pkg // optionalAttrs (outPath != null) { inherit outPath; } - // optionalAttrs (version != null) { inherit version; }; + in pkg // optionalAttrs (outPath != null) { + inherit outPath; + + # Prevent getOutput from descending into outputs + outputSpecified = true; + + # Allow the original package to be used in derivation inputs + __spliced = { + buildHost = pkg; + hostTarget = pkg; + }; + } // optionalAttrs (version != null) { inherit version; }; in { options.test.stubs = mkOption {