From 77c78bd04e6a1f600d5ce94c869e11b44cee1b7d Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Tue, 21 Jan 2025 10:09:46 +0000 Subject: [PATCH] tests/platforms: move out of flake `wrappers` module These should be set up in a dedicated test file, owned by `tests/default.nix`. Also refactored to use `callTest`. --- flake/wrappers.nix | 33 ------------------- tests/default.nix | 1 + tests/{modules => platforms}/darwin.nix | 7 ++-- tests/platforms/default.nix | 21 ++++++++++++ .../hm-extra-files-byte-compiling.nix | 15 +++++---- tests/{modules => platforms}/hm.nix | 7 ++-- tests/{modules => platforms}/nixos.nix | 7 ++-- 7 files changed, 40 insertions(+), 51 deletions(-) rename tests/{modules => platforms}/darwin.nix (66%) create mode 100644 tests/platforms/default.nix rename tests/{modules => platforms}/hm-extra-files-byte-compiling.nix (92%) rename tests/{modules => platforms}/hm.nix (72%) rename tests/{modules => platforms}/nixos.nix (78%) diff --git a/flake/wrappers.nix b/flake/wrappers.nix index 084f5ce0..93f04d70 100644 --- a/flake/wrappers.nix +++ b/flake/wrappers.nix @@ -14,39 +14,6 @@ defaultSystem = system; }; }; - - checks = - { - home-manager-module = - (import ../tests/modules/hm.nix { - inherit pkgs; - inherit (inputs) home-manager; - nixvim = self; - }).activationPackage; - home-manager-extra-files-byte-compiling = - import ../tests/modules/hm-extra-files-byte-compiling.nix - { - inherit pkgs; - inherit (inputs) home-manager; - nixvim = self; - }; - } - // pkgs.lib.optionalAttrs (!pkgs.stdenv.isDarwin) { - nixos-module = - (import ../tests/modules/nixos.nix { - inherit system; - inherit (inputs) nixpkgs; - nixvim = self; - }).config.system.build.toplevel; - } - // pkgs.lib.optionalAttrs pkgs.stdenv.isDarwin { - darwin-module = - (import ../tests/modules/darwin.nix { - inherit system; - inherit (inputs) nix-darwin; - nixvim = self; - }).system; - }; }; flake = { diff --git a/tests/default.nix b/tests/default.nix index 4a5ccd31..15266faa 100644 --- a/tests/default.nix +++ b/tests/default.nix @@ -52,6 +52,7 @@ in # Individual tests can be run using: nix build .#docs.user-configs.tests. docs-user-configs = linkFarm "user-configs-tests" selfPackages.docs.user-configs.tests; } +// callTests ./platforms { } # Tests generated from ./test-sources # Grouped as a number of link-farms in the form { test-1, test-2, ... test-N } // callTests ./main.nix { } diff --git a/tests/modules/darwin.nix b/tests/platforms/darwin.nix similarity index 66% rename from tests/modules/darwin.nix rename to tests/platforms/darwin.nix index e3149f8b..dc66f308 100644 --- a/tests/modules/darwin.nix +++ b/tests/platforms/darwin.nix @@ -1,9 +1,8 @@ { - nixvim, + self, system, - nix-darwin, }: -nix-darwin.lib.darwinSystem { +self.inputs.nix-darwin.lib.darwinSystem { modules = [ { nixpkgs.hostPlatform = system; @@ -14,6 +13,6 @@ nix-darwin.lib.darwinSystem { system.stateVersion = 5; } - nixvim.nixDarwinModules.nixvim + self.nixDarwinModules.nixvim ]; } diff --git a/tests/platforms/default.nix b/tests/platforms/default.nix new file mode 100644 index 00000000..664319ba --- /dev/null +++ b/tests/platforms/default.nix @@ -0,0 +1,21 @@ +{ + callTest, + lib, + stdenv, +}: +let + inherit (stdenv.hostPlatform) + isLinux + isDarwin + ; +in +{ + home-manager-module = (callTest ./hm.nix { }).activationPackage; + home-manager-extra-files-byte-compiling = callTest ./hm-extra-files-byte-compiling.nix { }; +} +// lib.optionalAttrs isLinux { + nixos-module = (callTest ./nixos.nix { }).config.system.build.toplevel; +} +// lib.optionalAttrs isDarwin { + darwin-module = (callTest ./darwin.nix { }).system; +} diff --git a/tests/modules/hm-extra-files-byte-compiling.nix b/tests/platforms/hm-extra-files-byte-compiling.nix similarity index 92% rename from tests/modules/hm-extra-files-byte-compiling.nix rename to tests/platforms/hm-extra-files-byte-compiling.nix index 8f08f688..197069e4 100644 --- a/tests/modules/hm-extra-files-byte-compiling.nix +++ b/tests/platforms/hm-extra-files-byte-compiling.nix @@ -1,9 +1,12 @@ { - nixvim, + self, pkgs, - home-manager, }: let + inherit (self.inputs.home-manager.lib) + homeManagerConfiguration + ; + config = { home = { username = "nixvim"; @@ -32,22 +35,22 @@ let }; homeFilesByteCompilingEnabled = - (home-manager.lib.homeManagerConfiguration { + (homeManagerConfiguration { inherit pkgs; modules = [ - nixvim.homeManagerModules.nixvim + self.homeManagerModules.nixvim config { programs.nixvim.performance.byteCompileLua.configs = true; } ]; }).config.home-files; homeFilesByteCompilingDisabled = - (home-manager.lib.homeManagerConfiguration { + (homeManagerConfiguration { inherit pkgs; modules = [ - nixvim.homeManagerModules.nixvim + self.homeManagerModules.nixvim config { programs.nixvim.performance.byteCompileLua.configs = false; } ]; diff --git a/tests/modules/hm.nix b/tests/platforms/hm.nix similarity index 72% rename from tests/modules/hm.nix rename to tests/platforms/hm.nix index 7b1b15ea..db2bf2ba 100644 --- a/tests/modules/hm.nix +++ b/tests/platforms/hm.nix @@ -1,9 +1,8 @@ { - nixvim, + self, pkgs, - home-manager, }: -home-manager.lib.homeManagerConfiguration { +self.inputs.home-manager.lib.homeManagerConfiguration { inherit pkgs; modules = [ @@ -19,6 +18,6 @@ home-manager.lib.homeManagerConfiguration { programs.home-manager.enable = true; } - nixvim.homeManagerModules.nixvim + self.homeManagerModules.nixvim ]; } diff --git a/tests/modules/nixos.nix b/tests/platforms/nixos.nix similarity index 78% rename from tests/modules/nixos.nix rename to tests/platforms/nixos.nix index feda42fe..84bb92a2 100644 --- a/tests/modules/nixos.nix +++ b/tests/platforms/nixos.nix @@ -1,9 +1,8 @@ { - nixvim, - nixpkgs, + self, system, }: -nixpkgs.lib.nixosSystem { +self.inputs.nixpkgs.lib.nixosSystem { inherit system; modules = [ @@ -18,6 +17,6 @@ nixpkgs.lib.nixosSystem { enable = true; }; } - nixvim.nixosModules.nixvim + self.nixosModules.nixvim ]; }