From 5192a85f3224cd2ef49da53162c0138823afd4e9 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Thu, 16 Jan 2025 01:47:16 +0000 Subject: [PATCH] test/nixpkgs-module: use a fixed `runCommand` function Rather than getting `runCommand` from the pkgs instance under test, get the function from a fixed/consistent pkgs instance. --- modules/top-level/test.nix | 18 +++++++++++++++++- tests/nixpkgs-module.nix | 2 ++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/modules/top-level/test.nix b/modules/top-level/test.nix index fe47f87a..95dc945c 100644 --- a/modules/top-level/test.nix +++ b/modules/top-level/test.nix @@ -169,6 +169,22 @@ in ''; internal = true; }; + + # Primarily intended for internal use, allowing us to test `pkgs` while using a `runCommand` from a different nixpkgs instance. + runCommand = lib.mkOption { + type = + with lib.types; + addCheck unspecified builtins.isFunction + // { + description = "runCommand function"; + }; + description = '' + `runCommand` function used to construct `build.test`. + ''; + defaultText = lib.literalExpression "pkgs.runCommandLocal"; + default = pkgs.runCommandLocal; + internal = true; + }; }; options.build = { @@ -238,7 +254,7 @@ in build.test = assert lib.assertMsg (cfg.runNvim -> cfg.buildNixvim) "`test.runNvim` requires `test.buildNixvim`."; - pkgs.runCommandLocal cfg.name + cfg.runCommand cfg.name { nativeBuildInputs = lib.optionals cfg.buildNixvim [ config.build.packageUnchecked diff --git a/tests/nixpkgs-module.nix b/tests/nixpkgs-module.nix index 20e3bed1..db6556cd 100644 --- a/tests/nixpkgs-module.nix +++ b/tests/nixpkgs-module.nix @@ -4,6 +4,7 @@ linkFarmFromDrvs, self, stdenv, + runCommandLocal, }: let @@ -19,6 +20,7 @@ let inherit name; buildNixvim = false; runNvim = false; + runCommand = runCommandLocal; }; } ];