stylix: parametrize and change testbed field separator (#887)

Parametrize and change the testbed field separator to the colon (':')
character to avoid ambiguity with module names containing hyphens ('-'),
and allow testbed names to contain hyphens.

Fixes: 211a8440e7 ("stylix: support multiple testbeds per module (#858)")
This commit is contained in:
NAHO 2025-02-23 19:17:59 +01:00 committed by GitHub
parent 689fd55ff2
commit f121a142ab
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 18 additions and 12 deletions

View file

@ -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). and [Derrick Cooper](https://unsplash.com/photos/brown-road-in-forest-during-daytime-L505cPnmIds).
Try a live demo of this theme by running Try a live demo of this theme by running
`nix run github:danth/stylix#testbed-gnome-default-light` or `nix run github:danth/stylix#testbed:gnome:default:light` or
`nix run github:danth/stylix#testbed-gnome-default-dark`. `nix run github:danth/stylix#testbed:gnome:default:dark`.
### KDE Plasma 5 ### KDE Plasma 5

View file

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

Before After
Before After

View file

@ -52,19 +52,19 @@ github:danth/stylix
└───x86_64-linux └───x86_64-linux
├───docs: package 'stylix-book' ├───docs: package 'stylix-book'
├───palette-generator: package 'palette-generator' ├───palette-generator: package 'palette-generator'
├───testbed-gnome-default-dark: package 'testbed-gnome-default-dark' ├───testbed:gnome:default:dark: package 'testbed:gnome:default:dark'
├───testbed-gnome-default-light: package 'testbed-gnome-default-light' ├───testbed:gnome:default:light: package 'testbed:gnome:default:light'
├───testbed-kde-default-dark: package 'testbed-kde-default-dark' ├───testbed:kde:default:dark: package 'testbed:kde:default:dark'
└───testbed-kde-default-light: package 'testbed-kde-default-light' └───testbed:kde:default:light: package 'testbed:kde:default:light'
``` ```
(This has been edited down to only the relevant parts.) (This has been edited down to only the relevant parts.)
To start a testbed, each of which is named in the format To start a testbed, each of which is named in the format
`testbed-«module»-«testbed»-«polarity»`, run the following command: `testbed:«module»:«testbed»:«polarity»`, run the following command:
```console ```console
user@host:~$ nix run .#testbed-«module»-«testbed»-«polarity» user@host:~$ nix run .#testbed:«module»:«testbed»:«polarity»
``` ```
Any package with a name not fitting the given format is not a testbed, Any package with a name not fitting the given format is not a testbed,
@ -74,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 below. The contents of the virtual machine will vary depending on the target you
selected earlier. selected earlier.
![GDM login screen with a dark background color and showing a guest user](testbed-gnome-default-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 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 automatically when selected. Depending on the software used, you may still be

View file

@ -6,6 +6,7 @@
}: }:
let let
testbedFieldSeparator = ":";
username = "guest"; username = "guest";
commonModule = commonModule =
@ -114,8 +115,8 @@ let
# To prevent ambiguity with the final derivation's hyphen field # To prevent ambiguity with the final derivation's hyphen field
# separator, testbed names should not contain hyphens. # separator, testbed names should not contain hyphens.
else if lib.hasInfix "-" testbed then else if lib.hasInfix testbedFieldSeparator testbed then
builtins.throw "testbed name must not contain hyphens (-): ${testbed}" builtins.throw "testbed name must not contain the '${testbedFieldSeparator}' testbed field separator: ${testbed}"
else else
{ {
@ -131,7 +132,12 @@ let
makeTestbed = makeTestbed =
testbed: stylix: testbed: stylix:
let let
name = "testbed-${testbed.module}-${testbed.name}-${stylix.polarity}"; name = builtins.concatStringsSep testbedFieldSeparator [
"testbed"
testbed.module
testbed.name
stylix.polarity
];
system = lib.nixosSystem { system = lib.nixosSystem {
inherit (pkgs) system; inherit (pkgs) system;