Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stylix: improve stylix.mkEnableTarget behaviour #400

Open
1 of 2 tasks
trueNAHO opened this issue May 27, 2024 · 8 comments
Open
1 of 2 tasks

stylix: improve stylix.mkEnableTarget behaviour #400

trueNAHO opened this issue May 27, 2024 · 8 comments
Labels
C-tracking-issue Category: A tracking issue technical debt Things which should be cleaned up or improved

Comments

@trueNAHO
Copy link
Collaborator

trueNAHO commented May 27, 2024

About

This is a tracking issue for enabling all Stylix targets by default with stylix.autoEnable, and simplifying the stylix.mkEnableTarget documentation. This behaviour is desired based on the following reasoning:

stylix/stylix/target.nix

Lines 17 to 24 in 00a11ba

# If the module only touches options under its target (programs.target.*)
# then this can simply be `true`, as those options are already gated by the
# upstream enable option.
#
# Otherwise, use `config` to check whether the target is enabled.
#
# If some manual setup is required, or the module leads to the target
# being installed if it wasn't already, set this to `false`.

Currently, some targets are enabled based on unscalable checks. For example, feh manually tries a non-exhaustive list of window managers, although the window manager dependency seems wrong in this case:

options.stylix.targets.feh.enable =
config.lib.stylix.mkEnableTarget
"the desktop background using Feh"
(with config.xsession.windowManager; bspwm.enable
|| herbstluftwm.enable
|| i3.enable
|| spectrwm.enable
|| xmonad.enable);

Due to some targets not being enabled by default with stylix.mkEnableTarget, the documentation incorrectly generates Default: false in some cases with #399. Resolving this involves manually extending docs/settings.nix or enabling all targets by default with stylix.mkEnableTarget.

Steps

@trueNAHO trueNAHO added technical debt Things which should be cleaned up or improved C-tracking-issue Category: A tracking issue labels May 27, 2024
@danth
Copy link
Owner

danth commented May 28, 2024

The feh module checks for certain window managers since these are known to not come with their own wallpaper program, and are based on X rather than Wayland, so feh is a suitable all-round solution to install for these cases.

I'm not completely sure what the goal of this issue is. Are you suggesting the argument to mkEnableTarget should always be a constant true or false?

@trueNAHO
Copy link
Collaborator Author

The feh module checks for certain window managers since these are known to not come with their own wallpaper program, and are based on X rather than Wayland, so feh is a suitable all-round solution to install for these cases.

Makes sense. However, with XWayland being a thing, it would make sense to enable it also on Wayland. For example, I use feh on Hyprland, which runs on Wayland.

I'm not completely sure what the goal of this issue is.

Essentially, the goal is to resolve the following issue:

Due to some targets not being enabled by default with stylix.mkEnableTarget, the documentation incorrectly generates Default: false in some cases with #399.

Are you suggesting the argument to mkEnableTarget should always be a constant true or false?

Actually, I don't have a concrete suggestion yet. I only noticed the inconsistency, but have not investigated it any further yet.

@danth
Copy link
Owner

danth commented May 31, 2024

See this comment for my suggestions.

trueNAHO added a commit to trueNAHO/stylix that referenced this issue Jun 1, 2024
Simplify the 'stylix.mkEnableTarget' documentation.

The following issue is to be resolved in
danth#400:

> Due to some targets not being enabled by default with
> 'stylix.mkEnableTarget', the documentation incorrectly generates
> 'Default: false' in some cases
danth pushed a commit that referenced this issue Jun 1, 2024
Simplify the 'stylix.mkEnableTarget' documentation.

The following issue is to be resolved in
#400:

> Due to some targets not being enabled by default with
> 'stylix.mkEnableTarget', the documentation incorrectly generates
> 'Default: false' in some cases
@danth
Copy link
Owner

danth commented Jun 12, 2024

What's the status of this now that #244 has been merged?

@trueNAHO
Copy link
Collaborator Author

I'm not completely sure what the goal of this issue is.

Essentially, the goal is to resolve the following issue:

Due to some targets not being enabled by default with stylix.mkEnableTarget, the documentation incorrectly generates Default: false in some cases with #399.

What's the status of this now that #244 has been merged?

For example, #244 changes the stylix.targets.feh.enable documentation from

Default: false

to

Default: same as stylix.autoEnable

which resolves the initial main issue.

However, what should we do about the following related issue:

Currently, some targets are enabled based on unscalable checks. For example, feh manually tries a non-exhaustive list of window managers, although the window manager dependency seems wrong in this case:

options.stylix.targets.feh.enable =
config.lib.stylix.mkEnableTarget
"the desktop background using Feh"
(with config.xsession.windowManager; bspwm.enable
|| herbstluftwm.enable
|| i3.enable
|| spectrwm.enable
|| xmonad.enable);

The feh module checks for certain window managers since these are known to not come with their own wallpaper program, and are based on X rather than Wayland, so feh is a suitable all-round solution to install for these cases.

Makes sense. However, with XWayland being a thing, it would make sense to enable it also on Wayland. For example, I use feh on Hyprland, which runs on Wayland.

@danth
Copy link
Owner

danth commented Jun 14, 2024

Perhaps we should split the feh module into individual targets for each of the window managers involved?

Similar to how the GNOME module uses GNOME's built in wallpaper setting, Hyprland uses/will use hyprpaper, etc

@trueNAHO
Copy link
Collaborator Author

trueNAHO commented Jun 16, 2024

Perhaps we should split the feh module into individual targets for each of the window managers involved?

Similar to how the GNOME module uses GNOME's built in wallpaper setting, Hyprland uses/will use hyprpaper, etc

Yes, inverting the dependency chain sounds like a good idea, as it leverages Locality of Behaviour (LoB).

Additionally, it simplifies theming feh itself in the future, as its Window Manager functionality is unnecessary for that.

Consequently, I suggest adapting all config guards not adhering to the lib.mkIf (config.stylix.enable && config.stylix.targets.<TARGET>.enable) pattern.

Here is a complete list of all such guards on a7fbda1:

  • lib.mkIf config.stylix.enable

  • lib.mkIf config.stylix.targets.<TARGET>.enable

  • External Module Dependency: lib.mkIf (config.stylix.enable && config.stylix.targets.<TARGET>.enable && ...)

    • config.xsession.initExtra =
      lib.mkIf (
      config.stylix.enable
      && config.stylix.targets.feh.enable
      && (
      with config.xsession.windowManager;
      bspwm.enable
      || herbstluftwm.enable
      || i3.enable
      || spectrwm.enable
      || xmonad.enable
      )
      )
    • config.services.xserver.displayManager.sessionCommands =
      lib.mkIf (
      config.stylix.enable
      && config.stylix.targets.feh.enable
      && (
      with config.services.xserver.windowManager;
      xmonad.enable
      || i3.enable
      )
      )
  • lib.mkIf (config.stylix.enable && config.stylix.targets.<TARGET>.enable && config.programs.<TARGET>.enable)

  • lib.mkIf (config.stylix.enable && config.stylix.targets.<TARGET>.enable && pkgs.stdenv.hostPlatform.isLinux)

  • External Input Support: lib.optionalAttrs (options.services ? <TARGET>) (lib.mkIf (config.stylix.enable && config.stylix.targets.<TARGET>.enable)

The External Input Support pattern is required to support external modules and is only included for completeness reasons.

Is it possible to extend the lib.mkIf (config.stylix.enable && config.stylix.targets.<TARGET>.enable && pkgs.stdenv.hostPlatform.isLinux) pattern to support non-Linux systems?

The remaining listed patterns should be adapted to the lib.mkIf (config.stylix.enable && config.stylix.targets.<TARGET>.enable) pattern to avoid inconsistencies with modules being unable to be toggled. Unlike #419, this change first uniforms module guards across all Stylix modules. IMHO, #419 should be applied only after this change.

@danth
Copy link
Owner

danth commented Jun 16, 2024

The first two categories you listed look like they were just missed when I used sed to apply the change across all modules:

  • k9s doesn't match the pattern [a-z\-]+
  • The others use a cfg alias hence don't match

Is it possible to extend the lib.mkIf (config.stylix.enable && config.stylix.targets.<TARGET>.enable && pkgs.stdenv.hostPlatform.isLinux) pattern to support non-Linux systems?

For KDE, this exists since we check whether KDE is installed at runtime rather than using its enable option (KDE would be enabled in a NixOS config, but we're using a Home Manager module). When running Home Manager on MacOS, it's impossible for KDE to be installed hence we skip the check. I believe there may also be an error involved due to some of the dependencies not being available on MacOS.

For Swaylock, it may be possible to remove the guard since Home Manager should only use the settings when Swaylock is enabled. I haven't tested this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-tracking-issue Category: A tracking issue technical debt Things which should be cleaned up or improved
Projects
None yet
Development

No branches or pull requests

2 participants