stylix: support multiple testbeds per module (#858)
Support multiple testbeds per module with /modules/<MODULE>/testbeds/<TESTBED>.nix, while validating various invariants.
This commit is contained in:
parent
e86de61bb8
commit
211a8440e7
26 changed files with 52 additions and 28 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 31 KiB After Width: | Height: | Size: 31 KiB |
|
|
@ -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.
|
||||
|
||||

|
||||

|
||||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue