From 245930d735a1fa391837d1fa648cfbfb9faf73f3 Mon Sep 17 00:00:00 2001 From: traxys Date: Sat, 6 Jan 2024 17:53:31 +0100 Subject: [PATCH] tests: Add a test for the nixos module (#907) --- flake-modules/tests.nix | 72 ++++++++++++++++++++++++----------------- tests/modules/nixos.nix | 21 ++++++++++++ 2 files changed, 64 insertions(+), 29 deletions(-) create mode 100644 tests/modules/nixos.nix diff --git a/flake-modules/tests.nix b/flake-modules/tests.nix index f9db3edf..1069efd1 100644 --- a/flake-modules/tests.nix +++ b/flake-modules/tests.nix @@ -6,39 +6,53 @@ perSystem = { pkgs, config, + system, makeNixvimWithModuleUnfree, makeNixvimWithModule, ... }: { - checks = { - tests = import ../tests { - inherit pkgs; - inherit (pkgs) lib; - makeNixvim = configuration: - makeNixvimWithModuleUnfree { - module = { - config = configuration; - }; - }; - }; - - extra-args-tests = import ../tests/extra-args.nix { - inherit pkgs; - inherit makeNixvimWithModule; - }; - - lib-tests = import ../tests/lib-tests.nix { - inherit pkgs; - inherit (pkgs) lib; - }; - - home-manager = - (import ../tests/modules/hm.nix { + checks = + { + tests = import ../tests { inherit pkgs; - inherit (inputs) home-manager; - nixvim = self; - }) - .activationPackage; - }; + inherit (pkgs) lib; + makeNixvim = configuration: + makeNixvimWithModuleUnfree { + module = { + config = configuration; + }; + }; + }; + + extra-args-tests = import ../tests/extra-args.nix { + inherit pkgs; + inherit makeNixvimWithModule; + }; + + lib-tests = import ../tests/lib-tests.nix { + inherit pkgs; + inherit (pkgs) lib; + }; + + home-manager-module = + (import ../tests/modules/hm.nix { + inherit pkgs; + inherit (inputs) home-manager; + nixvim = self; + }) + .activationPackage; + } + // pkgs.lib.optionalAttrs (!pkgs.stdenv.isDarwin) { + nixos-module = + (import ../tests/modules/nixos.nix { + inherit system; + inherit (inputs) nixpkgs; + nixvim = self; + }) + .config + .system + .build + .toplevel; + }; }; } diff --git a/tests/modules/nixos.nix b/tests/modules/nixos.nix new file mode 100644 index 00000000..f3b38656 --- /dev/null +++ b/tests/modules/nixos.nix @@ -0,0 +1,21 @@ +{ + nixvim, + nixpkgs, + system, +}: +nixpkgs.lib.nixosSystem { + inherit system; + + modules = [ + { + system.stateVersion = "23.11"; + boot.loader.systemd-boot.enable = true; + fileSystems."/" = {device = "/non/existent/device";}; + + programs.nixvim = { + enable = true; + }; + } + nixvim.nixosModules.nixvim + ]; +}