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

treewide: make stylix.image optional #717

Open
wants to merge 14 commits into
base: master
Choose a base branch
from

Conversation

Flameopathic
Copy link
Contributor

@Flameopathic Flameopathic commented Jan 1, 2025

Closes: #200
Closes: #442

will make stylix.image optional, as long as stylix.base16Scheme is set

tasks

  • alter most modules using config.stylix.image
  • alter the option definition or set up a check to ensure that one of stylix.image or stylix.base16Scheme is set
  • add option to each module
  • alter the KDE module; would appreciate help from @danth who authored most of it, though if you don't have the time, i'm sure that i could figure it out eventually
  • use cfg where necessary
  • update docs
  • test

i wonder if, in some places, pixel.nix would be useful or better than setting nothing at all, though i'm not sure

@trueNAHO
Copy link
Collaborator

trueNAHO commented Jan 1, 2025

  • altered the KDE module; would appreciate help from danth who authored most of it, though if you don't have the time, i'm sure that i could figure it out eventually

This PR could be mostly generated with:

fd -e nix -X sed -i 's/config\.stylix\.image/lib.mkIf (\0 != null) \0'
  • altered the option definition or set up a check to ensure that one of stylix.image or stylix.base16Scheme is set

I suggest adding an assertions where the config.stylix.image type is defined.

i wonder if, in some places, pixel.nix would be useful or better than setting nothing at all, though i'm not sure

Consistently wrapping with lib.mkIf (config.stylix.image != null) config.stylix.image might be the best solution.

For reference, #442 might contain more practical information.

@Flameopathic
Copy link
Contributor Author

  • altered the KDE module; would appreciate help from danth who authored most of it, though if you don't have the time, i'm sure that i could figure it out eventually

This PR could be mostly generated with:

fd -e nix -X sed -i 's/config\.stylix\.image/lib.mkIf (\0 != null) \0'

i'll test it out doing just that, though it seems more complicated than the rest

  • altered the option definition or set up a check to ensure that one of stylix.image or stylix.base16Scheme is set

I suggest adding an assertions where the config.stylix.image type is defined.

good idea, done

i wonder if, in some places, pixel.nix would be useful or better than setting nothing at all, though i'm not sure

Consistently wrapping with lib.mkIf (config.stylix.image != null) config.stylix.image might be the best solution.

sounds good and makes sense; why do anything more complicated

For reference, #442 might contain more practical information.

ah, hadn't noticed it. are you interested in me adding the proposed wallpaper option for every module that uses config.stylix.image?

@Flameopathic Flameopathic force-pushed the optional-image branch 2 times, most recently from aa17ed3 to f7e7cbc Compare January 2, 2025 17:01
@trueNAHO
Copy link
Collaborator

trueNAHO commented Jan 2, 2025

For reference, #442 might contain more practical information.

[...] are you interested in me adding the proposed wallpaper option for every module that uses config.stylix.image?

Yes.

@Flameopathic
Copy link
Contributor Author

Flameopathic commented Jan 2, 2025

can't seem to get KDE themed, even with an image using the official release of stylix. is it known to be broken?

either way it may be best to, for the moment, disable KDE theming when there is no image, as #708 looks like it's about to change the module entirely

@Flameopathic Flameopathic force-pushed the optional-image branch 3 times, most recently from ce128e9 to 64a5bb9 Compare January 3, 2025 00:15
@Flameopathic
Copy link
Contributor Author

set up individual toggles. failing to set stylix.image and intentionally enabling one of the wallpapers (stylix.targets.<name>.wallpaper = true) will cause an error; i'd like to fix that with an assertion, but I don't see a way to do that without setting up an assertion for every one individually.

i still need help with KDE for reasons explained previously

testing of all other modules in progress

@lordkekz
Copy link
Contributor

lordkekz commented Jan 3, 2025

can't seem to get KDE themed, even with an image using the official release of stylix. is it known to be broken?

either way it may be best to, for the moment, disable KDE theming when there is no image, as #708 looks like it's about to change the module entirely

Yeah, KDE theme activation is currently broken for any setup where the activation isn't run inside a Plasma session.
I hope that #708 can get merged soon and you can rebase then to make your changes.

I think it'll be sufficient to just guard the if-block in the activator script and the magick-related commands in the themePackage builder with checks on whether the wallpaper is enabled.

@Flameopathic
Copy link
Contributor Author

Yeah, KDE theme activation is currently broken for any setup where the activation isn't run inside a Plasma session. I hope that #708 can get merged soon and you can rebase then to make your changes.

got it, thanks

I think it'll be sufficient to just guard the if-block in the activator script and the magick-related commands in the themePackage builder with checks on whether the wallpaper is enabled.

awesome, double thanks

@trueNAHO
Copy link
Collaborator

trueNAHO commented Jan 3, 2025

set up individual toggles. failing to set stylix.image and intentionally enabling one of the wallpapers (stylix.targets.<name>.wallpaper = true) will cause an error; i'd like to fix that with an assertion, but I don't see a way to do that without setting up an assertion for every one individually.

Can you elaborate? I assume the following should be the pattern:

{
  config,
  lib,
  ...
}: let
  target = "<TARGET>";
in {
  options.stylix.targets.${target} = {
    enable = config.lib.stylix.mkEnableTarget target true;

    # TODO: Define config.lib.stylix.mkEnableWallpaper with an appropriate
    # description.
    wallpaper = config.lib.stylix.mkEnableWallpaper target true;
  };

  config = let
    cfg = config.stylix.targets.${target};
  in
    lib.mkIf (config.stylix.enable && cfg.enable) {
      programs.${target} = {
        enable = true;

        wallpaper =
          lib.mkIf
          (cfg.wallpaper && config.stylix.image != null)
          config.stylix.image;
      };
    };
}

Extracting the hard-coded target = "<TARGET>"; variable in each module could be done in a seperate initial commit.

I could quickly do this in a separate PR, but getting my PRs merged takes quiet long since danth is rather slow to respond. However, keeping that commit in this PR will be rather annoying, since we need to resolve breaking changes with new modules introduced in master...

@Flameopathic
Copy link
Contributor Author

Can you elaborate? I assume the following should be the pattern:
...

I must have misunderstood what you wanted in #442, i just added an option to every module that uses the wallpaper.

@trueNAHO
Copy link
Collaborator

trueNAHO commented Jan 4, 2025

Can you elaborate? I assume the following should be the pattern:
...

I must have misunderstood what you wanted in #442, i just added an option to every module that uses the wallpaper.

Your approach looks good. Sorry for the confusion.

@trueNAHO
Copy link
Collaborator

trueNAHO commented Jan 4, 2025

Cross-post:

the stylix.targets.hyprland.hyprpaper.enable option should probably be renamed to stylix.targets.hyprland.wallpaper.enable in #717.

NAHO, "hyprland: avoid trivial stylix.targets.hyprpaper.enable collision"

@Flameopathic
Copy link
Contributor Author

Cross-post:

the stylix.targets.hyprland.hyprpaper.enable option should probably be renamed to stylix.targets.hyprland.wallpaper.enable in #717.
NAHO, "hyprland: avoid trivial stylix.targets.hyprpaper.enable collision"

implemented

@trueNAHO trueNAHO mentioned this pull request Jan 26, 2025
7 tasks
@Flameopathic Flameopathic reopened this Jan 26, 2025
@Flameopathic Flameopathic force-pushed the optional-image branch 3 times, most recently from 0ddea4a to 833cbbd Compare January 26, 2025 19:39
@Flameopathic
Copy link
Contributor Author

[...] the recent /modules/wayfire/hm.nix module is not utilizing the useWallpaper option.

should be fixed

Optionalizing the wallpaper functionality was surprisingly more involving than expected. Thanks a lot @Flameopathic for your continuous efforts in implementing the most requested Stylix feature.

I appreciate your active reviewing. I made many mistakes, so thank you for your patience!

Copy link
Collaborator

@trueNAHO trueNAHO left a comment

Choose a reason for hiding this comment

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

Optionalizing the wallpaper functionality was surprisingly more involving than expected. Thanks a lot [Flameopathic] for your continuous efforts in implementing the most requested Stylix feature.

I appreciate your active reviewing. I made many mistakes, so thank you for your patience!

Glad I could help :)

@Flameopathic Flameopathic force-pushed the optional-image branch 2 times, most recently from 1acbe2b to 8d5c5d1 Compare February 17, 2025 16:36
@danth
Copy link
Owner

danth commented Feb 17, 2025

Seems working based on the testbeds - is there anything specific you would like me to check?

Only things I noticed are:

  • The testbed names are quite long - perhaps we could simplify this by giving each configuration an arbitrary name rather than detailing all of the settings?
  • We are very close to the limit on the number of matrix jobs for GitHub Actions

However I think these could both be worked on after merging rather than delaying this PR.

@trueNAHO
Copy link
Collaborator

Seems working based on the testbeds - is there anything specific you would like me to check?

Nothing specific. An additional review on this major PR would not be bad.

Only things I noticed are:

  • The testbed names are quite long - perhaps we could simplify this by giving each configuration an arbitrary name rather than detailing all of the settings?
  • We are very close to the limit on the number of matrix jobs for GitHub Actions

However I think these could both be worked on after merging rather than delaying this PR.

Agreed.

Copy link
Owner

@danth danth left a comment

Choose a reason for hiding this comment

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

I've read through the code changes in detail: assume anything not commented on LGTM.

@trueNAHO
Copy link
Collaborator

I've read through the code changes in detail: assume anything not commented on LGTM.

Should we merge this PR as-is then?

@Flameopathic
Copy link
Contributor Author

i'm a little unclear on what @danth meant by

But I think for this PR it should just be left as is.

do you mean that no more changes are necessary and your conversations are moot or that we just shouldn't mess with adding useWallpaper for specific non-wallpaper targets in this PR

@Flameopathic
Copy link
Contributor Author

Flameopathic commented Feb 20, 2025

either way, i removed useWallpaper options from wallpaper-only modules and instead have the target enable options base on whether stylix.image is set

I'm not sure what's going on with the checks, though.

@danth
Copy link
Owner

danth commented Feb 20, 2025

i removed useWallpaper options from wallpaper-only modules and instead have the target enable options base on whether stylix.image is set

This is what I meant :)

I'm not sure what's going on with the checks, though.

This seems to be related to #861:

https://github.com/danth/stylix/actions/runs/13435736838/job/37537466901#step:3:279

Although I'm not sure why this is failing (or why the get-derivations job shows as success despite the error)

Copy link
Collaborator

@trueNAHO trueNAHO left a comment

Choose a reason for hiding this comment

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

Although I'm not sure why this is failing (or why the get-derivations job shows as success despite the error)

This should be resolved in #888.

Copy link
Collaborator

@trueNAHO trueNAHO left a comment

Choose a reason for hiding this comment

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

LGTM.

I would squash merge this PR with the following commit message:

treewide: optionalize stylix.image option

Optionalize the stylix.image option when stylix.base16Scheme is set,
making the following Stylix configurations valid:

    [
      // Now it possible to set 'stylix.image = null', if
      // stylix.base16Scheme is set.
      {
        base16Scheme = /* ... */;
      }

      // This configuration was already possible.
      {
        image = /* ... */;
      }

      // This configuration was already possible.
      {
        base16Scheme = /* ... */;
        image = /* ... */;
      }
    ]

Closes: https://github.com/danth/stylix/issues/200
Closes: https://github.com/danth/stylix/issues/442
Link: https://github.com/danth/stylix/pull/717

Co-authored-by: NAHO <[email protected]>
Reviewed-by: NAHO <[email protected]>
Tested-by: NAHO <[email protected]>
Reviewed-by: Daniel Thwaites <[email protected]>

@trueNAHO trueNAHO requested a review from danth February 21, 2025 19:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

treewide: optionalize wallpaper functionality stylix: wallpaper should be optional
5 participants