stylix
stylix copied to clipboard
stylix: add an enable option
Problem
I'm trying to share a configuration with a server and a laptop so I want to disable stylix on the server.
Conditionally imported modules are a problem (almost always cause infinite recursion): https://discourse.nixos.org/t/conditional-module-imports/34863/2.
Some of the stylix config is required (ie. stylix.image
), but stylix cannot be disabled (with ie. stylix.enable = false
) so that this is not included.
Suggested solution
Add a stylix.enable
option and fill the codebase with lib.mkIf config.stylix.enable ...
Out of tree workaround:
# config.nix
{ stylixModule }: { config, pkgs, lib, ...}: {
imports = lib.optional (stylixModule != null) stylixModule;
# ...
}
# flake.nix
nixosConfigurations.stylix = lib.nixosSystem {
inherit system pkgs;
modules = [ (import ./config.nix { stylixModule = stylix.nixosModules.stylix; } ) ];
# ...
};
nixosConfigurations.noStylix = lib.nixosSystem {
inherit system pkgs;
modules = [ (import ./config.nix { stylixModule = null; } ) ];
# ...
};
I would be willing to give this a try if there is interest.
Setting stylix.autoEnable
to false
should disable all targets, so no styling gets applied. Does this work for you?
I will check, I don't remember if I tried it (I think I did though).
Setting
stylix.autoEnable
tofalse
should disable all targets, so no styling gets applied. Does this work for you?
It still requires the stylix.image
to be present so that it can generate the palette.
Maybe the patch is easier than I thought then, I'll give it a try.
I would love to have such a feature as well. It's a pain to have to wrangle with imports because it's impossible to get stylix not to set a ton of options like fonts, which are set unconditionally. This makes it really hard to reuse modules for systems with low amounts of disk space.
This goes a against the module philosophy where you don't pay for what you don't use. I think there should be a global enable
flag which guards all stylix specific features.
It's a pain to have to wrangle with imports because it's impossible to get stylix not to set a ton of options like fonts, which are set unconditionally.
Related: https://github.com/nix-community/home-manager/pull/2732
related: #200
Closed by https://github.com/danth/stylix/pull/244.