diff --git a/README.md b/README.md index 9f9dff07..8be89a42 100644 --- a/README.md +++ b/README.md @@ -54,8 +54,8 @@ Photos by [Clay Banks](https://unsplash.com/photos/three-bicycles-parked-in-fron and [Derrick Cooper](https://unsplash.com/photos/brown-road-in-forest-during-daytime-L505cPnmIds). Try a live demo of this theme by running -`nix run github:danth/stylix#testbed-gnome-light` or -`nix run github:danth/stylix#testbed-gnome-dark`. +`nix run github:danth/stylix#testbed-gnome-default-light` or +`nix run github:danth/stylix#testbed-gnome-default-dark`. ### KDE Plasma 5 diff --git a/docs/src/testbed-gnome-dark.png b/docs/src/testbed-gnome-default-dark.png similarity index 100% rename from docs/src/testbed-gnome-dark.png rename to docs/src/testbed-gnome-default-dark.png diff --git a/docs/src/testbeds.md b/docs/src/testbeds.md index d362ec48..959b22b5 100644 --- a/docs/src/testbeds.md +++ b/docs/src/testbeds.md @@ -17,11 +17,10 @@ otherwise. ## Creation -New testbeds are defined by creating a file called `testbed.nix` within the -folder for the corresponding target. This file will automatically be loaded -as a NixOS module, with options such as `stylix.image` already defined. -The module should include any options necessary to install the target and -any supporting software - for example, a window manager. +Testbeds are defined at `/modules/«module»/testbeds/«testbed».nix` and are are +automatically loaded as a NixOS module with options such as `stylix.image` +already defined. The testbed should include any options necessary to install the +target and any supporting software - for example, a window manager. If the target can only be used through Home Manager, you can write a Home Manager module within the NixOS module using the following format: @@ -53,19 +52,19 @@ github:danth/stylix └───x86_64-linux ├───docs: package 'stylix-book' ├───palette-generator: package 'palette-generator' - ├───testbed-gnome-dark: package 'testbed-gnome-dark' - ├───testbed-gnome-light: package 'testbed-gnome-light' - ├───testbed-kde-dark: package 'testbed-kde-dark' - └───testbed-kde-light: package 'testbed-kde-light' + ├───testbed-gnome-default-dark: package 'testbed-gnome-default-dark' + ├───testbed-gnome-default-light: package 'testbed-gnome-default-light' + ├───testbed-kde-default-dark: package 'testbed-kde-default-dark' + └───testbed-kde-default-light: package 'testbed-kde-default-light' ``` (This has been edited down to only the relevant parts.) To start a testbed, each of which is named in the format -`testbed-«target»-«polarity»`, run the following command: +`testbed-«module»-«testbed»-«polarity»`, run the following command: ```console -user@host:~$ nix run .#testbed-«target»-«polarity» +user@host:~$ nix run .#testbed-«module»-«testbed»-«polarity» ``` Any package with a name not fitting the given format is not a testbed, @@ -75,7 +74,7 @@ Once the virtual machine starts, a window should open, similar to the screenshot below. The contents of the virtual machine will vary depending on the target you selected earlier. -![GDM login screen with a dark background color and showing a guest user](testbed-gnome-dark.png) +![GDM login screen with a dark background color and showing a guest user](testbed-gnome-default-dark.png) If the testbed includes a login screen, the guest user should log in automatically when selected. Depending on the software used, you may still be diff --git a/modules/alacritty/testbed.nix b/modules/alacritty/testbeds/default.nix similarity index 100% rename from modules/alacritty/testbed.nix rename to modules/alacritty/testbeds/default.nix diff --git a/modules/cavalier/testbed.nix b/modules/cavalier/testbeds/default.nix similarity index 100% rename from modules/cavalier/testbed.nix rename to modules/cavalier/testbeds/default.nix diff --git a/modules/chromium/testbed.nix b/modules/chromium/testbeds/default.nix similarity index 100% rename from modules/chromium/testbed.nix rename to modules/chromium/testbeds/default.nix diff --git a/modules/emacs/testbed.nix b/modules/emacs/testbeds/default.nix similarity index 100% rename from modules/emacs/testbed.nix rename to modules/emacs/testbeds/default.nix diff --git a/modules/firefox/testbed.nix b/modules/firefox/testbeds/default.nix similarity index 100% rename from modules/firefox/testbed.nix rename to modules/firefox/testbeds/default.nix diff --git a/modules/foot/testbed.nix b/modules/foot/testbeds/default.nix similarity index 100% rename from modules/foot/testbed.nix rename to modules/foot/testbeds/default.nix diff --git a/modules/gedit/testbed.nix b/modules/gedit/testbeds/default.nix similarity index 100% rename from modules/gedit/testbed.nix rename to modules/gedit/testbeds/default.nix diff --git a/modules/ghostty/testbed.nix b/modules/ghostty/testbeds/default.nix similarity index 100% rename from modules/ghostty/testbed.nix rename to modules/ghostty/testbeds/default.nix diff --git a/modules/glance/testbed.nix b/modules/glance/testbeds/default.nix similarity index 100% rename from modules/glance/testbed.nix rename to modules/glance/testbeds/default.nix diff --git a/modules/gnome-text-editor/testbed.nix b/modules/gnome-text-editor/testbeds/default.nix similarity index 100% rename from modules/gnome-text-editor/testbed.nix rename to modules/gnome-text-editor/testbeds/default.nix diff --git a/modules/gnome/testbed.nix b/modules/gnome/testbeds/default.nix similarity index 100% rename from modules/gnome/testbed.nix rename to modules/gnome/testbeds/default.nix diff --git a/modules/halloy/testbed.nix b/modules/halloy/testbeds/default.nix similarity index 100% rename from modules/halloy/testbed.nix rename to modules/halloy/testbeds/default.nix diff --git a/modules/hyprland/testbed.nix b/modules/hyprland/testbeds/default.nix similarity index 100% rename from modules/hyprland/testbed.nix rename to modules/hyprland/testbeds/default.nix diff --git a/modules/kde/testbed.nix b/modules/kde/testbeds/default.nix similarity index 100% rename from modules/kde/testbed.nix rename to modules/kde/testbeds/default.nix diff --git a/modules/kitty/testbed.nix b/modules/kitty/testbeds/default.nix similarity index 100% rename from modules/kitty/testbed.nix rename to modules/kitty/testbeds/default.nix diff --git a/modules/qutebrowser/testbed.nix b/modules/qutebrowser/testbeds/default.nix similarity index 100% rename from modules/qutebrowser/testbed.nix rename to modules/qutebrowser/testbeds/default.nix diff --git a/modules/vencord/testbed.nix b/modules/vencord/testbeds/default.nix similarity index 100% rename from modules/vencord/testbed.nix rename to modules/vencord/testbeds/default.nix diff --git a/modules/vesktop/testbed.nix b/modules/vesktop/testbeds/default.nix similarity index 100% rename from modules/vesktop/testbed.nix rename to modules/vesktop/testbeds/default.nix diff --git a/modules/vscode/testbed.nix b/modules/vscode/testbeds/default.nix similarity index 100% rename from modules/vscode/testbed.nix rename to modules/vscode/testbeds/default.nix diff --git a/modules/wezterm/testbed.nix b/modules/wezterm/testbeds/default.nix similarity index 100% rename from modules/wezterm/testbed.nix rename to modules/wezterm/testbeds/default.nix diff --git a/modules/yazi/testbed.nix b/modules/yazi/testbeds/default.nix similarity index 100% rename from modules/yazi/testbed.nix rename to modules/yazi/testbeds/default.nix diff --git a/modules/zathura/testbed.nix b/modules/zathura/testbeds/default.nix similarity index 100% rename from modules/zathura/testbed.nix rename to modules/zathura/testbeds/default.nix diff --git a/stylix/testbed.nix b/stylix/testbed.nix index d518233d..8a38574d 100644 --- a/stylix/testbed.nix +++ b/stylix/testbed.nix @@ -90,23 +90,48 @@ let }; }; - autoload = builtins.concatLists ( - lib.mapAttrsToList ( - name: _: - let - testbed = { - inherit name; - module = "${inputs.self}/modules/${name}/testbed.nix"; - }; - in - lib.optional (builtins.pathExists testbed.module) testbed - ) (builtins.readDir "${inputs.self}/modules") - ); + autoload = + let + directory = "testbeds"; + modules = "${inputs.self}/modules"; + in + lib.flatten ( + lib.mapAttrsToList ( + module: _: + let + testbeds = "${modules}/${module}/${directory}"; + in + lib.mapAttrsToList ( + testbed: type: + if type != "regular" then + builtins.throw "${testbed} must be regular: ${type}" + + else if !lib.hasSuffix ".nix" testbed then + builtins.throw "testbed must be a Nix file: ${testbeds}/${testbed}" + + else if testbed == ".nix" then + builtins.throw "testbed must have a name: ${testbed}" + + # To prevent ambiguity with the final derivation's hyphen field + # separator, testbed names should not contain hyphens. + else if lib.hasInfix "-" testbed then + builtins.throw "testbed name must not contain hyphens (-): ${testbed}" + + else + { + inherit module; + + name = lib.removeSuffix ".nix" testbed; + path = "${testbeds}/${testbed}"; + } + ) (lib.optionalAttrs (builtins.pathExists testbeds) (builtins.readDir testbeds)) + ) (builtins.readDir modules) + ); makeTestbed = testbed: stylix: let - name = "testbed-${testbed.name}-${stylix.polarity}"; + name = "testbed-${testbed.module}-${testbed.name}-${stylix.polarity}"; system = lib.nixosSystem { inherit (pkgs) system; @@ -116,7 +141,7 @@ let applicationModule inputs.self.nixosModules.stylix inputs.home-manager.nixosModules.home-manager - testbed.module + testbed.path { inherit stylix;