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: wallpaper refactor #102

Closed
wants to merge 119 commits into from

Conversation

SomeGuyNamedMay
Copy link
Contributor

@SomeGuyNamedMay SomeGuyNamedMay commented May 31, 2023

Checklist

  • Module support
  • Check function for types that actually restricts the type
  • Add documentation
  • Add testing

Potential Additions

  • Move more configuration into the custom types such as polarity
  • Additional constructors for things such as generating a wallpapers like penrose tiling's and the like
  • Add a utility function for documenting constructors

Reference

The following depend or should be improved based on this PR:

stylix/palette.nix Outdated Show resolved Hide resolved
stylix/palette.nix Outdated Show resolved Hide resolved
@SomeGuyNamedMay
Copy link
Contributor Author

running into this weird error when building docs
error.txt

@SomeGuyNamedMay
Copy link
Contributor Author

ready for review when you've got time.

@SomeGuyNamedMay
Copy link
Contributor Author

@danth i think this is ready whenever you have time

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.

The MacOS tests should pass once you pull in 9197996 from the master branch.

lib/constructors.nix Outdated Show resolved Hide resolved
lib/types.nix Outdated Show resolved Hide resolved
lib/types.nix Outdated Show resolved Hide resolved
lib/utils.nix Show resolved Hide resolved
modules/sway/hm.nix Outdated Show resolved Hide resolved
modules/sway/hm.nix Outdated Show resolved Hide resolved
modules/sway/hm.nix Outdated Show resolved Hide resolved
@danth
Copy link
Owner

danth commented Jul 2, 2023

We need to update the configuration page on the website to use the new constructors

@SomeGuyNamedMay
Copy link
Contributor Author

do we want to run checks on that wallpaper types that ensures there contents are of the correct types?

@danth
Copy link
Owner

danth commented Jul 3, 2023

That would be good if possible

modules/wlroots/hm.nix Outdated Show resolved Hide resolved
modules/xorg/command.nix Outdated Show resolved Hide resolved
Copy link
Owner

Choose a reason for hiding this comment

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

Converting these to functions (like toHex, toInt, toPolarity) will make our lib folder only depend on pkgs and the upstream lib, without reading anything from config. I'm hoping that will allow it to be passed as a module argument without causing infinite recursion.

Comment on lines +35 to +41
solid = color: pkgs.runCommand "${color}-pixel.png" { } "${pkgs.imagemagick}/bin/convert xc:#${color} png32:$out";
pixel = color:
pkgs.runCommand "${color}-pixel.png"
{
color = config.stylix.colors.withHashtag.${color};
} "${pkgs.imagemagick}/bin/convert xc:$color png32:$out";
};
Copy link
Owner

Choose a reason for hiding this comment

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

Duplicated function.

@Sntx626
Copy link
Contributor

Sntx626 commented Dec 26, 2023

What's the state of this PR (draft)?

I'd be willing to help by rewriting and deduplicating the functions in lib/utils.nix.
Is there something else I can/should work on?

@danth
Copy link
Owner

danth commented Dec 29, 2023

@Sntx626 The main reason this isn't merged yet is because I'd like to remove the need to write out config.lib.stylix before every function, and just have it imported as { stylix, ... }. I tried to implement that a while back, but it led to infinite recursion.

The things you mentioned should help towards that.

It would also be useful to have more testing to make sure this doesn't break existing configs, or at least gives a helpful error message.

@trueNAHO
Copy link
Collaborator

trueNAHO commented Jan 12, 2024

The main reason this isn't merged yet is because I'd like to remove the need to write out config.lib.stylix before every function, and just have it imported as { stylix, ... }. I tried to implement that a while back, but it led to infinite recursion.

Considering that several internal feature PRs are waiting for this PR to land, it might be better to refactor config.lib.stylix with { stylix, ... } at a later time in a followup PR.

It would also be useful to have more testing to make sure this doesn't break existing configs, or at least gives a helpful error message.

However, considering the enormous rewrite, this should definitely happen before merging this PR.

Personally, this PR and its direct dependants might be one of the most drastic improvements to this project so far. Thanks for all the work so far!

For reference, the following PRs and issues depend on this PR:

For reference, the following PRs and issues should be improved based on this PR:

Feel free to add any PRs or issues I missed and to update the description of this PR to properly link the PRs and issues.

@trueNAHO trueNAHO marked this pull request as draft February 9, 2024 21:30
@trueNAHO trueNAHO changed the title Wallpaper refactor (WIP) treewide: wallpaper refactor Feb 9, 2024
Copy link
Collaborator

Choose a reason for hiding this comment

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

As mentioned in #251 (comment), the "black box" type introduced in 7a080cb is a genius type conversion abstraction.

However, I have my performance doubts about providing conversion functions instead of converted values. Specifically, does calling a conversion function multiple times convert multiple times or only once? Would static attribute sets not provide vastly better performance by caching their result? Additionally, the immutably converted data prevents any kind of conversion inconsistencies.

Copy link
Contributor

Choose a reason for hiding this comment

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

This is a valid concern.

However I think we should first measure the real-world impact of using the black box type and see if it is as bad as you think it could be. Or if there are other areas we should improve on first.

I also don't know enough about nix, but it could cache the result of the function and basically need to evaluate it only once. The optimization we seek might not even lay in this codebase.

Just an example of what would improve build times more:
I'm overriding all the colors myself. But stylix still generates a color palette from the bg image. I don't know if there's a way to turn that off, however running the genetic algorithm takes a lot of times. Which is not needed in my case afaik.

@danth danth mentioned this pull request Mar 4, 2024
11 tasks
Copy link
Contributor

@Sntx626 Sntx626 left a comment

Choose a reason for hiding this comment

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

While functional, there's still room for improvement.

popupsOpacity-float = builtins.toString config.stylix.opacity.popups;

backgroundPolarity =
polarityFrom = colors:
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently the function takes the color attr set.
This makes it relatively simple to call the function.

However this argument is not type checked. This will result in misleading errors at best and is documented nowhere atm. (except for this comment...)

Should we take red, green and blue as arguments instead?

lib/utils.nix Outdated Show resolved Hide resolved
@@ -2,33 +2,28 @@

{
config.lib.stylix = {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should probably create a library independent of config and tell the user how to extend their lib with ours.

This way we can finally be free of the config argument.

Copy link
Owner

Choose a reason for hiding this comment

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

A completely separate library (stylix / stylixLib or something) may be easier than trying to extend the existing lib.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think a separate library is probably a better idea, extending lib doesnt seem to be worth the effort

.gitignore Outdated Show resolved Hide resolved
Remove the local gitignore file because it is already upstream.

Follows: danth#291
@trueNAHO
Copy link
Collaborator

trueNAHO commented Nov 7, 2024

Closing this stale PR in favor of the proposal in #477 (comment), now tracked in the Roadmap. Thanks to everyone for the all valuable groundwork!

@trueNAHO trueNAHO closed this Nov 7, 2024
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.

stylix: support slideshows and animated wallpapers
7 participants