diff --git a/flake.nix b/flake.nix index c469d2ed..a11761ed 100644 --- a/flake.nix +++ b/flake.nix @@ -167,32 +167,6 @@ .options; }; in rec { - # This is omitted in `nix flake show`. - legacyPackages = { - # Run interactive tests with: - # - # nix run .#legacyPackages.x86_64-linux.nixosTests...driverInteractive - # - nixosTests = let - nixosTest = test: let - # Amenities for interactive tests - tools = {pkgs, ...}: { - environment.systemPackages = with pkgs; [vim tmux jq]; - # Use kmscon - # to provide a slightly nicer console. - # kmscon allows zooming with [Ctrl] + [+] and [Ctrl] + [-] - services.kmscon = { - enable = true; - autologinUser = "root"; - }; - }; - debugging.interactive.nodes = mapAttrs (_: _: tools) test.nodes; - in - pkgs.nixosTest (debugging // test); - in - mapAttrs (_: project: mapAttrs (_: nixosTest) project.nixos.tests) ngiProjects; - }; - packages = ngipkgs // { @@ -224,7 +198,7 @@ checksForProject = projectName: project: let checksForNixosTests = concatMapAttrs - (testName: test: {"projects/${projectName}/nixos/tests/${testName}" = pkgs.nixosTest test;}) + (testName: test: {"projects/${projectName}/nixos/tests/${testName}" = test;}) project.nixos.tests; checksForNixosExamples = diff --git a/projects/default.nix b/projects/default.nix index d9b6440a..74e5daf1 100644 --- a/projects/default.nix +++ b/projects/default.nix @@ -28,6 +28,22 @@ in concatMapAttrs names (readDir baseDirectory); + nixosTest = test: let + # Amenities for interactive tests + tools = {pkgs, ...}: { + environment.systemPackages = with pkgs; [vim tmux jq]; + # Use kmscon + # to provide a slightly nicer console. + # kmscon allows zooming with [Ctrl] + [+] and [Ctrl] + [-] + services.kmscon = { + enable = true; + autologinUser = "root"; + }; + }; + debugging.interactive.nodes = mapAttrs (_: _: tools) test.nodes; + in + pkgs.nixosTest (debugging // test); + hydrate = let empty-if-null = x: if x != null @@ -41,7 +57,19 @@ packages = empty-if-null (project.packages or {}); nixos.modules = empty-if-null (project.nixos.modules or {}); nixos.examples = empty-if-null (project.nixos.examples or {}); - nixos.tests = empty-if-null (project.nixos.tests or {}); + nixos.tests = + mapAttrs + ( + _: test: + if lib.isString test + then + (import test { + inherit pkgs; + inherit (pkgs) system; + }) + else nixosTest test + ) + (empty-if-null (project.nixos.tests or {})); }; in mapAttrs