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

How to disable frequent rebuild of palette.json when image is not changed? #666

Open
kraftnix opened this issue Dec 7, 2024 · 3 comments

Comments

@kraftnix
Copy link

kraftnix commented Dec 7, 2024

Is there a way to not generate palette.json every single time if my stylix.image never changes?

It adds at least 20 seconds of build every single time I update flake inputs. This is a pain for iteration of configuration, and since I have stylix enabled on a few machines, it adds non-considerable "wasted" time to compute something identical every time.

@trueNAHO
Copy link
Collaborator

trueNAHO commented Dec 8, 2024

Is there a way to not generate palette.json every single time if my stylix.image never changes?

@danth might be more helpful here, since I am not very familiar with this part of the code base:

stylix/stylix/palette.nix

Lines 119 to 125 in e309d64

# Making palette.json part of the system closure will protect it from
# garbage collection, so future configurations can be evaluated without
# having to generate the palette again. The generator is not kept, only
# the palette which came from it, so this uses very little disk space.
# The extra indirection should prevent the palette generator from running
# when the theme is manually specified. generated.json is necessary in
# the presence of overrides.

It adds at least 20 seconds of build every single time I update flake inputs. This is a pain for iteration of configuration, and since I have stylix enabled on a few machines, it adds non-considerable "wasted" time to compute something identical every time.

Implementing the Vim highlight groups may involve rewriting the palette-generator. In that case, we may consider improving its run time performance.

@kraftnix
Copy link
Author

kraftnix commented Dec 9, 2024

I managed to binary search the problem, which relates to using stylix across multiple flakes.

I have a shared repository with some wrapper modules that set up my desktop machines, which I use across multiple private flakes.

It sets stylix.image to a file within the shared flake, if a consuming flake doesn't set it's own stylix.image but instead relies upon the default from the shared flake, every time the input is updated the palette.json is rebuilt because the path to stylix.image changes because the option type coerces a package to a string.

image = lib.mkOption {
type = with lib.types; coercedTo package toString path;
description = ''
Wallpaper image.
This is set as the background of your desktop environment, if possible,
and used to generate a colour scheme if you don't set one manually.
'';
};

The solution is setting stylix.image in each consuming flake.

@danth
Copy link
Owner

danth commented Dec 10, 2024

I'm aware that as of efb734f the output of the palette generator is no longer directly part of the system closure, despite what it says in the comment. This is because the colors loaded via an import-from-derivation and substituted into palette.json.mustache, so the original palette.json which was output by the palette generator may be garbage collected.

Reverting this change would force the palette generator to always run, even if a manual scheme is configured, because it would be pulled into the configuration.

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

No branches or pull requests

3 participants