Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ philosophy.
Try a live demo of this dark theme by running:

```console
nix run github:nix-community/stylix#testbed:gnome:dark
nix run github:nix-community/stylix#testbed:gnome:full-dark
```

### KDE Plasma 5
Expand Down
20 changes: 10 additions & 10 deletions doc/src/testbeds.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,16 @@ github:nix-community/stylix
└───x86_64-linux
├───doc: package 'stylix-book'
├───palette-generator: package 'palette-generator'
├───"testbed:gnome:cursorless": package 'testbed-gnome-cursorless'
├───"testbed:gnome:dark": package 'testbed-gnome-dark'
├───"testbed:gnome:imageless": package 'testbed-gnome-imageless'
├───"testbed:gnome:light": package 'testbed-gnome-light'
├───"testbed:gnome:schemeless": package 'testbed-gnome-schemeless'
├───"testbed:kde:cursorless": package 'testbed-kde-cursorless'
├───"testbed:kde:dark": package 'testbed-kde-dark'
├───"testbed:kde:imageless": package 'testbed-kde-imageless'
├───"testbed:kde:light": package 'testbed-kde-light'
└───"testbed:kde:schemeless": package 'testbed-kde-schemeless'
├───"testbed:gnome:default": package 'testbed-gnome-default'
├───"testbed:gnome:disabled": package 'testbed-gnome-disabled'
├───"testbed:gnome:empty": package 'testbed-gnome-empty'
├───"testbed:gnome:full-dark": package 'testbed-gnome-full-dark'
├───"testbed:gnome:partial-light": package 'testbed-gnome-partial-light'
├───"testbed:kde:default": package 'testbed-kde-default'
├───"testbed:kde:disabled": package 'testbed-kde-disabled'
├───"testbed:kde:empty": package 'testbed-kde-empty'
├───"testbed:kde:full-dark": package 'testbed-kde-full-dark'
└───"testbed:kde:partial-light": package 'testbed-kde-partial-light'
```

(This has been edited down to only the relevant parts.)
Expand Down
17 changes: 0 additions & 17 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,6 @@
flake = false;
};

tinted-schemes = {
url = "github:tinted-theming/schemes";
flake = false;
};

tinted-tmux = {
url = "github:tinted-theming/tinted-tmux";
flake = false;
Expand Down
1 change: 0 additions & 1 deletion flake/dev/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@
# nur.follows = "";
# tinted-foot.follows = "";
# tinted-kitty.follows = "";
# tinted-schemes.follows = "";
# tinted-tmux.follows = "";
# tinted-zed.follows = "";
# };
Expand Down
32 changes: 15 additions & 17 deletions stylix/home-manager-integration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -208,22 +208,20 @@ in
};
};

config = lib.mkIf config.stylix.enable (
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we reverting 73b7d0f? this pretty clear goes against the spirit of 7682713

Copy link
Copy Markdown
Member Author

@trueNAHO trueNAHO Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we reverting 73b7d0f? this pretty clear goes against the spirit of 7682713

The new disabled testcase is failing. The following commit fixes that:

stylix/home-manager-integration: unconditionally enable

Unconditionally enable the Home Manager integration to avoid

    error: The option `virtualisation.vmVariant.home-manager.users.guest.stylix' does not exist. Definition values:

errors inside 'stylix.enable = false;' testbeds containing the following
declaration:

    home-manager.sharedModules = lib.singleton {
      stylix.targets.${target}.${option} = value;
    };

Ideally, the Home Manager integration merely provides the options, and
the actual modules should do the guarding.

-- fcde0a7 ("stylix/home-manager-integration: unconditionally enable")

When I implemented this fix and quickly glanced over the discussion from commit 73b7d0f, it seems the new test cases cover all problems that were originally mentioned.

I will test each of these cases locally in my standalone Home Manager setup to see if this also works in end-user setups. This is the main reason this PR is currently in draft mode. Also, the commit message from fcde0a7 ("stylix/home-manager-integration: unconditionally enable") is currently just for debugging purposes, and will be overhauled if its diff is good.

Copy link
Copy Markdown
Member Author

@trueNAHO trueNAHO Aug 20, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will test each of these cases locally in my standalone Home Manager setup to see if this also works in end-user setups.

AFAICT, this does not affect Stylix integration with standalone Home Manager. The NixOS and Home Manager integration is covered by the new test cases, while the standalone NixOS integration seems untested.

This is the main reason this PR is currently in draft mode.

I am optimistically marking this PR as ready for review again.

quickly glanced over the discussion from commit 73b7d0f, it seems the new test cases cover all problems that were originally mentioned.

It seems whatever was the issue in that discussion, seems to have resolved itself in the meantime, as indicated by the new theme coverage:

Theme image base16Scheme
disabled false false
default false true
partial-light true false
full-dark true true

Copy link
Copy Markdown

@ThinkChaos ThinkChaos Dec 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Weighing in here as a random stylix user: in general enable options don't change what you're allowed to write in the config, they only change whether that configuration applies to the resulting system.
Here, guarding the import behind an enable goes against that since it makes the HM options existence conditional on enable, which forces users to hide all their HM config behind stylix.enable. That shouldn't be needed and is bad/unconventional UX. And mkIf is not even enough since the options don't exist, you need optionalAttrs or similar, to completely hide the config values from the module system.
So I also believe reverting 73b7d0f is the right choice, and I arrived to it independently in #2089.

I'd ideally like to see this unblocked and cherry-picked before the rest of the MR cause it's the only custom change I have for Stylix, and I'd rather just use upstream cause it's easier to update compared to rebasing my fork.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also I'd recommend adding a comment in the code to explain this, cause it might seem surprising at first compared to other modules.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in general enable options don't change what you're allowed to write in the config, they only change whether that configuration applies to the resulting system.

If you mean whether options should always be available, this is not generally the case and is AFAIK an undocumented convention: #2078.

I'd ideally like to see this unblocked and cherry-picked before the rest of the MR

As previously mentioned, the final [PATCH 3/3] stylix/testbeds/themes: overhaul testbed themes for broader coverage patch is exactly what increases correctness confidence:

quickly glanced over the discussion from commit 73b7d0f, it seems the new test cases cover all problems that were originally mentioned.

It seems whatever was the issue in that discussion, seems to have resolved itself in the meantime, as indicated by the new theme coverage:

Theme image base16Scheme
disabled false false
default false true
partial-light true false
full-dark true true

Without it, we merely assume this works. I am in favor of merging this only with the new test coverage.

Also I'd recommend adding a comment in the code to explain this, cause it might seem surprising at first compared to other modules.

I assume you are comparing the /stylix/home-manager-integration.nix core code to /modules/<MODULE>/{hm,nixos}.nix modules. IMHO, the core code should always just work, meaning the previous workaround commit 73b7d0f ("stylix: guard home-manager-integration config (#1494)") was the confusing exception and the new behaviour is the expected one:

Ideally, the Home Manager integration merely provides the options, and
the actual modules should do the guarding.

-- fcde0a7 ("stylix/home-manager-integration: unconditionally enable")

I think adding such a comment would be actively confusing because it re-states the norm.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you mean whether options should always be available, this is not generally the case and is AFAIK an undocumented convention: #2078.

Yes it's an undocumented convention, but it holds true across the entire Nix ecosystem AFAIK.

I think adding such a comment would be actively confusing because it re-states the norm.

It's about communicating with others since this has apparently caused enough confusion with multiple iterations.
I'm happy with whatever you prefer.

Anyways I agree with you in general, I just wanted to give additional input on the original comment, confirming the revert is the right move (IMO ofc) :)

lib.optionalAttrs (options ? home-manager) (
lib.mkMerge [
(lib.mkIf config.stylix.homeManagerIntegration.autoImport {
home-manager.sharedModules =
[
config.stylix.homeManagerIntegration.module
]
++ lib.optionals config.stylix.homeManagerIntegration.followSystem copyModules;
})
(lib.mkIf config.home-manager.useGlobalPkgs {
home-manager.sharedModules = lib.singleton {
config.stylix.overlays.enable = false;
};
})
]
)
config = lib.optionalAttrs (options ? home-manager) (
lib.mkMerge [
(lib.mkIf config.stylix.homeManagerIntegration.autoImport {
home-manager.sharedModules =
[
config.stylix.homeManagerIntegration.module
]
++ lib.optionals config.stylix.homeManagerIntegration.followSystem copyModules;
})
(lib.mkIf config.home-manager.useGlobalPkgs {
home-manager.sharedModules = lib.singleton {
config.stylix.overlays.enable = false;
};
})
]
);
}
30 changes: 0 additions & 30 deletions stylix/testbed/images.nix

This file was deleted.

13 changes: 0 additions & 13 deletions stylix/testbed/themes/cursorless.nix

This file was deleted.

18 changes: 0 additions & 18 deletions stylix/testbed/themes/dark.nix

This file was deleted.

8 changes: 8 additions & 0 deletions stylix/testbed/themes/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Test the default Stylix configuration.
{ pkgs, ... }:
{
stylix = {
base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-macchiato.yaml";
enable = true;
};
}
2 changes: 2 additions & 0 deletions stylix/testbed/themes/disabled.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Test Stylix being disabled.
{ stylix.enable = false; }
Comment thread
trueNAHO marked this conversation as resolved.
38 changes: 38 additions & 0 deletions stylix/testbed/themes/empty.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Test Stylix being enabled with all its features disabled.
{
config,
lib,
pkgs,
...
}:
{
stylix = {
enable = true;
icons.enable = false;
overlays.enable = false;

# TODO: Disable the color functionality by replacing the mandatory
# stylix.base16Scheme declaration with 'stylix.colors.enable = false;' once
# this option is implemented.
base16Scheme = "${pkgs.base16-schemes}/share/themes/mellow-purple.yaml";

# TODO: Properly disable the cursor functionality by replacing the
# stylix.cursor declaration with 'stylix.cursor.enable = false;' once this
# option is implemented.
cursor = null;

# TODO: Disable the font functionality with 'stylix.fonts.enable = false;'
# once this option is implemented.

# TODO: Properly disable the image functionality by replacing the
# stylix.image declaration with 'stylix.image.enable = false;' once this
# option is implemented. The stylix.image.enable namespace is subject to
# change.
image = null;

# TODO: Properly disable the opacity functionality by replacing the
# stylix.opacity declaration with 'stylix.opacity.enable = false;' once this
# option is implemented.
opacity = lib.genAttrs (builtins.attrNames config.stylix.opacity) (_: 1.0);
};
}
113 changes: 113 additions & 0 deletions stylix/testbed/themes/full-dark.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Test a complete Stylix configuration with a dark theme, image, and all options
# set to non-default values.
{
config,
lib,
pkgs,
...
}:
{
stylix = {
enable = true;

# TODO: Declare different dark and light themes after resolving [1].
#
# [1]: https://github.com/nix-community/stylix/issues/1855
icons = {
Comment thread
0xda157 marked this conversation as resolved.
dark = "Adwaita";
enable = true;
light = "Adwaita";
Comment on lines +17 to +19
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we using the light icons for dark?

Suggested change
dark = "Adwaita";
enable = true;
light = "Adwaita";
dark = "Adwaita Dark";
enable = true;
light = "Adwaita";

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why are we using the light icons for dark?

As implied by the theme name and its file header, full-dark declares all available Stylix options to reasonable non-default values, while partial-light intentionally does not declare all available Stylix options in order to test modularity. The dark and light polarity tests are merged with the "full" and "partial" test cases to reduce the total number of themes. In other words, full-dark declares stylix.icons.light despite being stylix.polarity = "dark"; to test whether this redundant declared value causes any problems.

Suggested change
dark = "Adwaita";
enable = true;
light = "Adwaita";
dark = "Adwaita Dark";
enable = true;
light = "Adwaita";

Does "Adwaita Dark" work? I see no such reference:

$ nix build --no-link --print-out-paths nixpkgs#adwaita-icon-theme | xargs rg --ignore-case 'Adwaita|Dark|Light'
/nix/store/phcncb0xzj0y2bcx7zd171b32cfqblz2-adwaita-icon-theme-47.0/share/icons/Adwaita/index.theme
2:Name=Adwaita

/nix/store/phcncb0xzj0y2bcx7zd171b32cfqblz2-adwaita-icon-theme-47.0/share/pkgconfig/adwaita-icon-theme.pc
2:Name: adwaita-icon-theme

package = pkgs.adwaita-icon-theme;
};
Comment on lines +16 to +21
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could someone verify whether this works?


overlays.enable = true;
polarity = "dark";

override =
{
author = "Stylix";
scheme = "Catppuccin Macchiato and Mocha";
slug = "catppuccin-macchiato-and-mocha";
}
// lib.importJSON (
pkgs.runCommand "catppuccin-macchiato-and-mocha.json"
{
nativeBuildInputs = [ pkgs.yq-go ];
src = "${pkgs.base16-schemes}/share/themes/catppuccin-mocha.yaml";
}
''
yq \
--output-format json \
'
.palette |
with_entries(select(.key | test("^base0(1|3|5|7|9|B|D|F)$")))
' \
<"$src" \
>"$out"
''
);

# TODO: Explicitly enable the color functionality with 'stylix.colors.enable
# = true;' once this option is implemented.
base16Scheme = "${pkgs.base16-schemes}/share/themes/catppuccin-macchiato.yaml";

cursor = {
name = "Bibata-Modern-Amber";
package = pkgs.bibata-cursors;
size = 25;
};

fonts = {
# TODO: Since this declaration is the default stylix.fonts.emoji value,
# the default value or this declaration should be changed.
emoji = {
name = "Noto Color Emoji";
package = pkgs.noto-fonts-color-emoji;
};

monospace = {
name = "Fira Code";
package = pkgs.fira-code;
};

sansSerif = {
name = "Noto Sans";
package = pkgs.noto-fonts;
};

serif = {
name = "Noto Serif";
package = pkgs.noto-fonts;
};

sizes = lib.genAttrs (builtins.attrNames config.stylix.fonts.sizes) (_: 14);
};

# Test path containing special characters.
image =
let
file = "${
lib.pipe "-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcdefghijklmnopqrstuvwxyz" [
lib.stringToCharacters
(builtins.concatStringsSep " ")
]
}.jpg";
in
"${
pkgs.runCommandLocal "image-path-containing-special-characters"
{
src = pkgs.fetchurl {
hash = "sha256-Dm/0nKiTFOzNtSiARnVg7zM0J1o+EuIdUQ3OAuasM58=";
name = "image.jpg";
url = "https://unsplash.com/photos/ZqLeQDjY6fY/download";
};
}
''
mkdir "$out"
cp "$src" "$out"/${lib.escapeShellArg file}
''
}/${file}";

opacity = lib.genAttrs (builtins.attrNames config.stylix.opacity) (_: 0.8);
};
}
16 changes: 0 additions & 16 deletions stylix/testbed/themes/imageless.nix

This file was deleted.

18 changes: 0 additions & 18 deletions stylix/testbed/themes/light.nix

This file was deleted.

Loading