gtksourceview: init module (#958)

Link: https://github.com/nix-community/stylix/pull/958

Reviewed-by: Daniel Thwaites <danth@danth.me>
Reviewed-by: awwpotato <awwpotato@voidq.com>
Co-authored-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
Reviewed-by: NAHO <90870942+trueNAHO@users.noreply.github.com>
This commit is contained in:
bricked 2025-07-12 23:50:03 +00:00 committed by GitHub
parent 0da583a359
commit 05752c77ac
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 81 additions and 30 deletions

View file

@ -8,7 +8,7 @@ mkTarget {
{
xdg.dataFile = {
"gedit/styles/stylix.xml".source = colors {
template = ./template.xml.mustache;
template = ../gtksourceview/template.xml.mustache;
extension = ".xml";
};
};

View file

@ -1,5 +1,6 @@
{ lib, ... }:
{
name = "GNOME Text Editor";
homepage = "https://gitlab.gnome.org/GNOME/gnome-text-editor";
maintainers = [ ];
maintainers = [ lib.maintainers.bricked ];
}

View file

@ -1,28 +0,0 @@
{
lib,
config,
...
}:
let
style = config.lib.stylix.colors {
template = ../gedit/template.xml.mustache;
extension = ".xml";
};
in
{
overlay =
_: prev:
lib.optionalAttrs
(
config.stylix.enable && config.stylix.targets.gnome-text-editor.enable or false
)
{
gnome-text-editor = prev.gnome-text-editor.overrideAttrs (oldAttrs: {
postFixup = ''
${oldAttrs.postFixup or ""}
mkdir -p $out/share/gtksourceview-5/styles
cp ${style} $out/share/gtksourceview-5/styles/stylix.xml
'';
});
};
}

View file

@ -0,0 +1,28 @@
{ mkTarget, lib, ... }:
mkTarget {
name = "gtksourceview";
humanName = "GTKSourceView";
configElements =
{ colors, ... }:
{
xdg.dataFile = builtins.listToAttrs (
map
(
version:
lib.nameValuePair "gtksourceview-${version}/styles/stylix.xml" {
source = colors {
template = ./template.xml.mustache;
extension = ".xml";
};
}
)
[
"2.0"
"3.0"
"4"
"5"
]
);
};
}

View file

@ -0,0 +1,5 @@
{ lib, ... }:
{
maintainers = [ lib.maintainers.bricked ];
name = "GTKSourceView";
}

View file

@ -0,0 +1,8 @@
{ mkTarget, ... }:
mkTarget {
name = "gtksourceview";
humanName = "GTKSourceView";
# Used to enable overlay.
}

View file

@ -0,0 +1,37 @@
{ config, lib, ... }:
let
inherit (lib) optionalAttrs;
inherit (config.lib.stylix) colors;
style = colors {
template = ./template.xml.mustache;
extension = ".xml";
};
attrsOverride = version: oldAttrs: {
postFixup = ''
${oldAttrs.postFixup or ""}
styles_dir="$out/share/gtksourceview-${version}/styles"
mkdir --parents "$styles_dir"
cp ${style} "$styles_dir/stylix.xml"
'';
};
in
{
overlay =
_final: prev:
optionalAttrs
(
config.stylix.enable
&& config.stylix.targets ? gtksourceview
&& config.stylix.targets.gtksourceview.enable
)
{
gnome2.gtksourceview = prev.gnome2.gtksourceview.overrideAttrs (
attrsOverride "2.0"
);
gtksourceview = prev.gtksourceview.overrideAttrs (attrsOverride "3.0");
gtksourceview4 = prev.gtksourceview4.overrideAttrs (attrsOverride "4");
gtksourceview5 = prev.gtksourceview5.overrideAttrs (attrsOverride "5");
};
}