stylix icon indicating copy to clipboard operation
stylix copied to clipboard

gtksourceview: init module

Open brckd opened this issue 9 months ago • 10 comments

Adds the gtksourceview target. This is used to configure GNOME Text Editor^1, among others. The gnome-text-editor target is made mostly obsolete by this. It only works on Home Manager though.

Moves the theme template from the gedit module, because GTKSourceView is the more generic target.

I haven't tested this yet!

brckd avatar Mar 06 '25 00:03 brckd

@danth I think you might be interested in testing this!

brckd avatar Mar 07 '25 08:03 brckd

This documentation page suggests to me that a package containing share/gnome/gtksourceview-{2.0,3.0}/styles/stylix.xml might appear on the search path, which would get this working at the NixOS level too. If not, it contains a Python script to find out exactly what the search path is.

danth avatar Mar 07 '25 21:03 danth

This works in my config!

There are some differences between the highlighting in GNOME Text Editor compared to VSCode, which could be caused by differences in our templates or differences in the editors themselves, however that's not relevant to this PR. The good thing is that it's now using the correct user level theme.

Once NixOS is supported, we should remove the gnome-text-editor module completely and just use lib.mkRenamedOptionModule to handle its enable option.

Do you want to work on NixOS now, or merge this and leave it for later?

danth avatar Mar 07 '25 21:03 danth

There are some differences between the highlighting in GNOME Text Editor compared to VSCode, which could be caused by differences in our templates or differences in the editors themselves, however that's not relevant to this PR.

We could adapt both themes to the base16 style guide in a future PR!

Once NixOS is supported, we should remove the gnome-text-editor module completely and just use lib.mkRenamedOptionModule to handle its enable option.

Do you want to work on NixOS now, or merge this and leave it for later?

Now that you mention it's possible, I'd rather work on the NixOS implementation first to enable a seamless transition from the gnome-text-editor module.

Not sure if we should actually remove the old module though, because some might have disabled it when its overlay caused issues. If we just remove the module, targets.gnome-text-editor.enable = false would result in an error, which might be confusing to some.

brckd avatar Mar 08 '25 07:03 brckd

One of lib.mkRenamedOptionModule, lib.mkRemovedOptionModule or lib.mkChangedOptionModule would handle the removed option gracefully. I think lib.mkChangedOptionModule offers customisation so we could set a more helpful message.

danth avatar Mar 08 '25 12:03 danth

@danth I added a NixOS implementation by overriding various gtksourceview packages. But now all other packages depending on gtksourceview will be rebuilt. I think this is quite a high cost for something that's already available as a Home Manager module.

The Stylix manual also says:

Many applications cannot be configured system wide, so Stylix will also need Home Manager to be able to change their settings within your home directory.

Realistically, most Stylix users also use Home Manager anyways. For this reason I'll disable the NixOS module by default.

brckd avatar Mar 11 '25 17:03 brckd

For some reason, the theme is no longer present in the GNOME Text Editor.

brckd avatar Mar 11 '25 17:03 brckd

OK, apparently this is the updated documentation for gtksourceview-5:

${PREFIX}/share/gtksourceview-5/ (where ${PREFIX} can be /usr/ or /usr/local/ if you have installed from source)

I copied the theme to gtksourceview-5 and gtksourceview-2.0. I also added it to gtksourceview-4, all though I couldn't find any documentation for this version.

The theme works again!

brckd avatar Mar 11 '25 18:03 brckd

@danth I added a NixOS implementation by overriding various gtksourceview packages. But now all other packages depending on gtksourceview will be rebuilt. I think this is quite a high cost for something that's already available as a Home Manager module.

The Stylix manual also says:

Many applications cannot be configured system wide, so Stylix will also need Home Manager to be able to change their settings within your home directory.

Realistically, most Stylix users also use Home Manager anyways. For this reason I'll disable the NixOS module by default.

Is it not possible to enable the module when the Stylix Home Manager module is not used? For reference, commit 2c20aed3b39a ("qt: autoenable hm module only on NixOS (#942)") uses osConfig as a workaround for detecting this.

trueNAHO avatar Mar 13 '25 07:03 trueNAHO

Sure, that would be possible! However this wouldn't be able to detect standalone Home Manager.

brckd avatar Mar 13 '25 14:03 brckd

What is the status of this PR? At this point, I assume there are quiet many merge conflicts.

trueNAHO avatar Jul 04 '25 16:07 trueNAHO

I honestly can't remember because it's been so long. I'll try to tackle my backlog next week, but I can't promise anything. After that I will be working on a personal project for a year and I'm not sure how available I'll be during that time.

brckd avatar Jul 04 '25 20:07 brckd

I rebased this onto master and removed some checks to simplify things for now. I enabled the overlay by default because there aren't many apps that depend on gtksourceview, so the rebuild wouldn't be too expensive.

I removed the warning for gnome-text-editor that it depends on gtksourceview, because gtksourceview is enabled by default anyways. There should probably be a more streamlined way to declare dependencies.

brckd avatar Jul 05 '25 12:07 brckd

As per https://github.com/nix-community/stylix/pull/958#issuecomment-3037193959 I can only provide maintenance on a best-efford basis. These modules should be fine though, since they aren't too complex.

brckd avatar Jul 05 '25 13:07 brckd

The maintainers file should comment that it's merged with nixpkgs maintainers.

brckd avatar Jul 05 '25 13:07 brckd

Seems to work! image

brckd avatar Jul 05 '25 18:07 brckd

GTKSourceView isn't an app, but multiple apps depend on it. There is already a testbed for the GNOME Text Editor.

brckd avatar Jul 07 '25 19:07 brckd

Resolves #954

brckd avatar Jul 10 '25 09:07 brckd

Successfully created backport PR for release-25.05:

  • #1679

stylix-automation[bot] avatar Jul 12 '25 23:07 stylix-automation[bot]