From 69bdd6de50df2082901d94dbf70ecb762d8b636c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Na=C3=AFm=20Favier?= Date: Fri, 9 Jun 2023 00:59:06 +0200 Subject: [PATCH] tests/stubs: inherit default versions from pkgs (#4069) * tests/stubs: inherit default versions from pkgs * tests/browserpass: temporarily disable on darwin The package currently fails to evaluate on darwin due to a nixpkgs problem: https://github.com/NixOS/nixpkgs/pull/236258#issuecomment-1583450593 --- tests/default.nix | 2 +- tests/stubs.nix | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/tests/default.nix b/tests/default.nix index 49b2dcea..6eab6179 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -64,7 +64,6 @@ import nmt { ./modules/programs/bat ./modules/programs/bottom ./modules/programs/broot - ./modules/programs/browserpass ./modules/programs/btop ./modules/programs/dircolors ./modules/programs/direnv @@ -157,6 +156,7 @@ import nmt { ./modules/programs/autorandr ./modules/programs/beets # One test relies on services.mpd ./modules/programs/borgmatic + ./modules/programs/browserpass # TODO re-enable on Darwin when https://github.com/NixOS/nixpkgs/pull/236258#issuecomment-1583450593 is fixed ./modules/programs/firefox ./modules/programs/foot ./modules/programs/fuzzel diff --git a/tests/stubs.nix b/tests/stubs.nix index 2d324c2c..5dee8e43 100644 --- a/tests/stubs.nix +++ b/tests/stubs.nix @@ -15,12 +15,13 @@ let outPath = mkOption { type = types.nullOr types.str; default = "@${name}@"; - defaultText = "@\${name}@"; + defaultText = literalExpression ''"@''${name}@"''; }; version = mkOption { type = types.nullOr types.str; default = null; + defaultText = literalExpression "pkgs.\${name}.version or null"; }; buildScript = mkOption { @@ -65,7 +66,12 @@ in { config = { lib.test.mkStubPackage = mkStubPackage; - nixpkgs.overlays = mkIf (config.test.stubs != { }) - [ (self: super: mapAttrs (n: mkStubPackage) config.test.stubs) ]; + nixpkgs.overlays = mkIf (config.test.stubs != { }) [ + (self: super: + mapAttrs (n: v: + mkStubPackage (v // optionalAttrs (v.version == null) { + version = super.${n}.version or null; + })) config.test.stubs) + ]; }; }