stylix icon indicating copy to clipboard operation
stylix copied to clipboard

stylix: add an enable option

Open jalil-salame opened this issue 7 months ago • 6 comments

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.

jalil-salame avatar Jan 15 '24 22:01 jalil-salame

Setting stylix.autoEnable to false should disable all targets, so no styling gets applied. Does this work for you?

danth avatar Jan 18 '24 10:01 danth

I will check, I don't remember if I tried it (I think I did though).

jalil-salame avatar Jan 18 '24 11:01 jalil-salame

Setting stylix.autoEnable to false 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.

jalil-salame avatar Jan 19 '24 16:01 jalil-salame

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.

xokdvium avatar Jan 25 '24 19:01 xokdvium

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

trueNAHO avatar Feb 01 '24 12:02 trueNAHO

related: #200

KiaraGrouwstra avatar Feb 10 '24 20:02 KiaraGrouwstra

Closed by https://github.com/danth/stylix/pull/244.

trueNAHO avatar Jun 10 '24 10:06 trueNAHO