diff --git a/tests/default.nix b/tests/default.nix index ed959647ff..471f169dbd 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -43,6 +43,7 @@ in no-flake = callTest ./no-flake.nix { }; lib-tests = callTest ./lib-tests.nix { }; maintainers = callTest ./maintainers.nix { }; + nixpkgs-module = callTest ./nixpkgs-module.nix { }; plugins-by-name = callTest ./plugins-by-name.nix { }; generated = callTest ./generated.nix { }; package-options = callTest ./package-options.nix { }; diff --git a/tests/main.nix b/tests/main.nix index 65efe95330..3b26069865 100644 --- a/tests/main.nix +++ b/tests/main.nix @@ -8,7 +8,6 @@ pkgs, pkgsUnfree, self, - system, }: let fetchTests = callTest ./fetch-tests.nix { }; @@ -19,14 +18,12 @@ let file: name: module: mkTestDerivationFromNixvimModule { inherit name; + # Use a single common instance of nixpkgs, with allowUnfree + # Having a single shared instance should speed up tests a little module = { _file = file; imports = [ module ]; - _module.args = { - # Give tests access to the flake - inherit self system; - inherit (self) inputs; - }; + nixpkgs.pkgs = pkgsUnfree; }; pkgs = pkgsUnfree; }; diff --git a/tests/test-sources/modules/nixpkgs.nix b/tests/nixpkgs-module.nix similarity index 62% rename from tests/test-sources/modules/nixpkgs.nix rename to tests/nixpkgs-module.nix index 6efce76a93..20e3bed1a3 100644 --- a/tests/test-sources/modules/nixpkgs.nix +++ b/tests/nixpkgs-module.nix @@ -1,10 +1,40 @@ { + pkgs, + lib, + linkFarmFromDrvs, + self, + stdenv, +}: +let + + defaultPkgs = pkgs; + + testModule = + name: module: + let + configuration = lib.nixvim.modules.evalNixvim { + modules = lib.toList module ++ [ + { + test = { + inherit name; + buildNixvim = false; + runNvim = false; + }; + } + ]; + }; + in + configuration.config.build.test; + +in +linkFarmFromDrvs "nixpkgs-module-test" [ + # TODO: expect not setting `nixpkgs.pkgs` to throw - overlays = + (testModule "nixpkgs-overlays" ( { pkgs, ... }: { - test.runNvim = false; + nixpkgs.pkgs = defaultPkgs; nixpkgs.overlays = [ (final: prev: { @@ -20,21 +50,15 @@ ''; } ]; - }; + } + )) # Test that overlays from both `nixpkgs.pkgs` _and_ `nixpkgs.overlays` are applied - stacked_overlays = - { - inputs, - system, - pkgs, - ... - }: + (testModule "nixpkgs-stacked-overlay" ( + { pkgs, ... }: { - test.runNvim = false; - - nixpkgs.pkgs = import inputs.nixpkgs { - inherit system; + nixpkgs.pkgs = import self.inputs.nixpkgs { + inherit (stdenv.hostPlatform) system; overlays = [ (final: prev: { foobar = "foobar"; @@ -70,5 +94,7 @@ ''; } ]; - }; -} + } + )) + +]