mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-05 16:41:04 +01:00
tests/gtk: refactor and organize
Signed-off-by: Austin Horstman <khaneliman12@gmail.com>
This commit is contained in:
parent
18ff4e1e11
commit
47443585fe
28 changed files with 175 additions and 113 deletions
|
|
@ -416,20 +416,9 @@ in
|
|||
})
|
||||
|
||||
# GTK4 Configuration
|
||||
(mkIf cfg4.enable (
|
||||
let
|
||||
gtk4Css =
|
||||
lib.optionalString (cfg4.theme != null && cfg4.theme.package != null) ''
|
||||
/**
|
||||
* GTK 4 reads the theme configured by gtk-theme-name, but ignores it.
|
||||
* It does however respect user CSS, so import the theme from here.
|
||||
**/
|
||||
@import url("file://${cfg4.theme.package}/share/themes/${cfg4.theme.name}/gtk-4.0/gtk.css");
|
||||
''
|
||||
+ cfg4.extraCss;
|
||||
in
|
||||
{
|
||||
xdg.configFile."gtk-4.0/settings.ini" = {
|
||||
(mkIf cfg4.enable {
|
||||
xdg.configFile = {
|
||||
"gtk-4.0/settings.ini" = {
|
||||
text = toIni {
|
||||
Settings =
|
||||
mkGtkSettings {
|
||||
|
|
@ -443,11 +432,21 @@ in
|
|||
// cfg4.extraConfig;
|
||||
};
|
||||
};
|
||||
xdg.configFile."gtk-4.0/gtk.css" = mkIf (gtk4Css != "") {
|
||||
text = gtk4Css;
|
||||
};
|
||||
}
|
||||
))
|
||||
"gtk-4.0/gtk.css" =
|
||||
mkIf (cfg4.extraCss != "" || (cfg4.theme != null && cfg4.theme.package != null))
|
||||
{
|
||||
text =
|
||||
lib.optionalString (cfg4.theme != null && cfg4.theme.package != null) ''
|
||||
/**
|
||||
* GTK 4 reads the theme configured by gtk-theme-name, but ignores it.
|
||||
* It does however respect user CSS, so import the theme from here.
|
||||
**/
|
||||
@import url("file://${cfg4.theme.package}/share/themes/${cfg4.theme.name}/gtk-4.0/gtk.css");
|
||||
''
|
||||
+ cfg4.extraCss;
|
||||
};
|
||||
};
|
||||
})
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,13 +4,14 @@
|
|||
gtk-selective-enable = ./gtk-selective-enable.nix;
|
||||
|
||||
# GTK2
|
||||
gtk2-basic-config = ./gtk2-basic-config.nix;
|
||||
gtk2-config-file-location = ./gtk2-config-file-location.nix;
|
||||
gtk2-basic-config = ./gtk2/gtk2-basic-config.nix;
|
||||
gtk2-config-file-location = ./gtk2/gtk2-config-file-location.nix;
|
||||
|
||||
# GTK3
|
||||
gtk3-basic-settings = ./gtk3-basic-settings.nix;
|
||||
gtk3-basic-settings = ./gtk3/gtk3-basic-settings.nix;
|
||||
|
||||
# GTK4
|
||||
gtk4-basic-settings = ./gtk4-basic-settings.nix;
|
||||
gtk4-theme-css-injection = ./gtk4-theme-css-injection.nix;
|
||||
gtk4-basic-settings = ./gtk4/gtk4-basic-settings.nix;
|
||||
gtk4-theme-css-injection = ./gtk4/gtk4-theme-css-injection.nix;
|
||||
gtk4-no-theme-css-injection = ./gtk4/gtk4-no-theme-css-injection.nix;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,6 @@
|
|||
gtk-cursor-theme-name = "Adwaita"
|
||||
gtk-cursor-theme-size = 24
|
||||
gtk-font-name = "Ubuntu 12"
|
||||
gtk-icon-theme-name = "Adwaita"
|
||||
gtk-theme-name = "Adwaita-dark"
|
||||
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
[Settings]
|
||||
gtk-cursor-theme-name=Adwaita
|
||||
gtk-cursor-theme-size=24
|
||||
gtk-font-name=Ubuntu 12
|
||||
gtk-icon-theme-name=Adwaita
|
||||
gtk-theme-name=Adwaita-dark
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
/**
|
||||
* GTK 4 reads the theme configured by gtk-theme-name, but ignores it.
|
||||
* It does however respect user CSS, so import the theme from here.
|
||||
**/
|
||||
@import url("file://@gnome-themes-extra@/share/themes/Adwaita-dark/gtk-4.0/gtk.css");
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
[Settings]
|
||||
gtk-cursor-theme-name=Adwaita
|
||||
gtk-cursor-theme-size=24
|
||||
gtk-font-name=Ubuntu 12
|
||||
gtk-icon-theme-name=Adwaita
|
||||
gtk-theme-name=Adwaita-dark
|
||||
|
|
@ -1,6 +1,5 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
# Test that global settings are inherited by all GTK versions
|
||||
gtk = {
|
||||
enable = true;
|
||||
font = {
|
||||
|
|
@ -25,33 +24,21 @@
|
|||
nmt.script = ''
|
||||
# Check GTK2 inherits global settings
|
||||
assertFileExists home-files/.gtkrc-2.0
|
||||
assertFileRegex home-files/.gtkrc-2.0 'gtk-theme-name = "Adwaita-dark"'
|
||||
assertFileRegex home-files/.gtkrc-2.0 'gtk-font-name = "Ubuntu 12"'
|
||||
assertFileRegex home-files/.gtkrc-2.0 'gtk-icon-theme-name = "Adwaita"'
|
||||
assertFileRegex home-files/.gtkrc-2.0 'gtk-cursor-theme-name = "Adwaita"'
|
||||
assertFileRegex home-files/.gtkrc-2.0 'gtk-cursor-theme-size = 24'
|
||||
assertFileContent home-files/.gtkrc-2.0 \
|
||||
${./gtk-global-inheritance-gtk2-expected.conf}
|
||||
|
||||
# Check GTK3 inherits global settings
|
||||
assertFileExists home-files/.config/gtk-3.0/settings.ini
|
||||
assertFileRegex home-files/.config/gtk-3.0/settings.ini 'gtk-theme-name=Adwaita-dark'
|
||||
assertFileRegex home-files/.config/gtk-3.0/settings.ini 'gtk-font-name=Ubuntu 12'
|
||||
assertFileRegex home-files/.config/gtk-3.0/settings.ini 'gtk-icon-theme-name=Adwaita'
|
||||
assertFileRegex home-files/.config/gtk-3.0/settings.ini 'gtk-cursor-theme-name=Adwaita'
|
||||
assertFileRegex home-files/.config/gtk-3.0/settings.ini 'gtk-cursor-theme-size=24'
|
||||
assertFileContent home-files/.config/gtk-3.0/settings.ini \
|
||||
${./gtk-global-inheritance-gtk3-expected.ini}
|
||||
|
||||
# Check GTK4 inherits global settings
|
||||
assertFileExists home-files/.config/gtk-4.0/settings.ini
|
||||
assertFileRegex home-files/.config/gtk-4.0/settings.ini 'gtk-theme-name=Adwaita-dark'
|
||||
assertFileRegex home-files/.config/gtk-4.0/settings.ini 'gtk-font-name=Ubuntu 12'
|
||||
assertFileRegex home-files/.config/gtk-4.0/settings.ini 'gtk-icon-theme-name=Adwaita'
|
||||
assertFileRegex home-files/.config/gtk-4.0/settings.ini 'gtk-cursor-theme-name=Adwaita'
|
||||
assertFileRegex home-files/.config/gtk-4.0/settings.ini 'gtk-cursor-theme-size=24'
|
||||
assertFileContent home-files/.config/gtk-4.0/settings.ini \
|
||||
${./gtk-global-inheritance-gtk4-expected.ini}
|
||||
|
||||
# Check GTK4 CSS with theme import
|
||||
assertFileExists home-files/.config/gtk-4.0/gtk.css
|
||||
assertFileRegex home-files/.config/gtk-4.0/gtk.css '@import url("file://.*/share/themes/Adwaita-dark/gtk-4.0/gtk.css")'
|
||||
|
||||
# Check packages are installed
|
||||
# Package installation verified by home-manager
|
||||
assertFileContent home-files/.config/gtk-4.0/gtk.css ${./gtk-global-inheritance-gtk4-css-expected.css}
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
gtk-cursor-theme-name = "Global-Cursor"
|
||||
gtk-font-name = "GTK2-Font 11"
|
||||
gtk-icon-theme-name = "Global-Icons"
|
||||
gtk-theme-name = "GTK2-Theme"
|
||||
gtk-can-change-accels = 1
|
||||
|
|
@ -0,0 +1 @@
|
|||
window { border: 1px solid red; }
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
[Settings]
|
||||
gtk-cursor-theme-name=GTK3-Cursor
|
||||
gtk-font-name=Global Font 11
|
||||
gtk-icon-theme-name=GTK3-Icons
|
||||
gtk-recent-files-limit=10
|
||||
gtk-theme-name=Global-Theme
|
||||
|
|
@ -0,0 +1 @@
|
|||
window { border: 2px solid blue; }
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
[Settings]
|
||||
gtk-cursor-theme-name=Global-Cursor
|
||||
gtk-font-name=GTK4-Font 11
|
||||
gtk-icon-theme-name=Global-Icons
|
||||
gtk-recent-files-limit=20
|
||||
gtk-theme-name=Global-Theme
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
{
|
||||
# Test that per-version settings override global defaults
|
||||
gtk = {
|
||||
enable = true;
|
||||
# Global defaults
|
||||
|
|
@ -35,26 +34,24 @@
|
|||
|
||||
nmt.script = ''
|
||||
# GTK2 should use overridden font/theme, global icons/cursor
|
||||
assertFileRegex home-files/.gtkrc-2.0 'gtk-font-name = "GTK2-Font 11"'
|
||||
assertFileRegex home-files/.gtkrc-2.0 'gtk-theme-name = "GTK2-Theme"'
|
||||
assertFileRegex home-files/.gtkrc-2.0 'gtk-icon-theme-name = "Global-Icons"'
|
||||
assertFileRegex home-files/.gtkrc-2.0 'gtk-cursor-theme-name = "Global-Cursor"'
|
||||
assertFileRegex home-files/.gtkrc-2.0 'gtk-can-change-accels = 1'
|
||||
assertFileExists home-files/.gtkrc-2.0
|
||||
assertFileContent home-files/.gtkrc-2.0 \
|
||||
${./gtk-per-version-override-gtk2-expected.conf}
|
||||
|
||||
# GTK3 should use global font/theme, overridden icons/cursor
|
||||
assertFileRegex home-files/.config/gtk-3.0/settings.ini 'gtk-font-name=Global Font 11'
|
||||
assertFileRegex home-files/.config/gtk-3.0/settings.ini 'gtk-theme-name=Global-Theme'
|
||||
assertFileRegex home-files/.config/gtk-3.0/settings.ini 'gtk-icon-theme-name=GTK3-Icons'
|
||||
assertFileRegex home-files/.config/gtk-3.0/settings.ini 'gtk-cursor-theme-name=GTK3-Cursor'
|
||||
assertFileRegex home-files/.config/gtk-3.0/settings.ini 'gtk-recent-files-limit=10'
|
||||
assertFileRegex home-files/.config/gtk-3.0/gtk.css 'window { border: 1px solid red; }'
|
||||
assertFileExists home-files/.config/gtk-3.0/settings.ini
|
||||
assertFileContent home-files/.config/gtk-3.0/settings.ini \
|
||||
${./gtk-per-version-override-gtk3-expected.ini}
|
||||
assertFileExists home-files/.config/gtk-3.0/gtk.css
|
||||
assertFileContent home-files/.config/gtk-3.0/gtk.css \
|
||||
${./gtk-per-version-override-gtk3-css-expected.css}
|
||||
|
||||
# GTK4 should use overridden font, global theme/icons/cursor
|
||||
assertFileRegex home-files/.config/gtk-4.0/settings.ini 'gtk-font-name=GTK4-Font 11'
|
||||
assertFileRegex home-files/.config/gtk-4.0/settings.ini 'gtk-theme-name=Global-Theme'
|
||||
assertFileRegex home-files/.config/gtk-4.0/settings.ini 'gtk-icon-theme-name=Global-Icons'
|
||||
assertFileRegex home-files/.config/gtk-4.0/settings.ini 'gtk-cursor-theme-name=Global-Cursor'
|
||||
assertFileRegex home-files/.config/gtk-4.0/settings.ini 'gtk-recent-files-limit=20'
|
||||
assertFileRegex home-files/.config/gtk-4.0/gtk.css 'window { border: 2px solid blue; }'
|
||||
assertFileExists home-files/.config/gtk-4.0/settings.ini
|
||||
assertFileContent home-files/.config/gtk-4.0/settings.ini \
|
||||
${./gtk-per-version-override-gtk4-expected.ini}
|
||||
assertFileExists home-files/.config/gtk-4.0/gtk.css
|
||||
assertFileContent home-files/.config/gtk-4.0/gtk.css \
|
||||
${./gtk-per-version-override-gtk4-css-expected.css}
|
||||
'';
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,2 @@
|
|||
[Settings]
|
||||
gtk-theme-name=Test-Theme
|
||||
|
|
@ -16,7 +16,8 @@
|
|||
|
||||
# GTK3 should be configured
|
||||
assertFileExists home-files/.config/gtk-3.0/settings.ini
|
||||
assertFileRegex home-files/.config/gtk-3.0/settings.ini 'gtk-theme-name=Test-Theme'
|
||||
assertFileContent home-files/.config/gtk-3.0/settings.ini \
|
||||
${./gtk-selective-enable-gtk3-expected.ini}
|
||||
|
||||
# GTK4 should not be configured
|
||||
assertPathNotExists home-files/.config/gtk-4.0/settings.ini
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
# Test GTK4 theme CSS injection with both theme and custom CSS
|
||||
gtk = {
|
||||
enable = true;
|
||||
|
||||
gtk4 = {
|
||||
theme = {
|
||||
name = "Adwaita-dark";
|
||||
package = pkgs.gnome-themes-extra;
|
||||
};
|
||||
extraCss = ''
|
||||
/* Custom user CSS */
|
||||
window {
|
||||
background-color: #2d2d2d;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 8px;
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
# GTK4 CSS should exist and contain both theme import and custom CSS
|
||||
assertFileExists home-files/.config/gtk-4.0/gtk.css
|
||||
|
||||
# Check for theme import comment and URL
|
||||
assertFileRegex home-files/.config/gtk-4.0/gtk.css '/\*\*'
|
||||
assertFileRegex home-files/.config/gtk-4.0/gtk.css 'GTK 4 reads the theme configured by gtk-theme-name, but ignores it'
|
||||
assertFileRegex home-files/.config/gtk-4.0/gtk.css '@import url("file://.*/share/themes/Adwaita-dark/gtk-4.0/gtk.css")'
|
||||
|
||||
# Check for custom CSS
|
||||
assertFileRegex home-files/.config/gtk-4.0/gtk.css 'Custom user CSS'
|
||||
assertFileRegex home-files/.config/gtk-4.0/gtk.css 'background-color: #2d2d2d'
|
||||
assertFileRegex home-files/.config/gtk-4.0/gtk.css 'border-radius: 8px'
|
||||
|
||||
# Verify the theme import comes before custom CSS
|
||||
css_content=$(cat home-files/.config/gtk-4.0/gtk.css)
|
||||
import_line=$(echo "$css_content" | grep -n "@import" | cut -d: -f1)
|
||||
custom_line=$(echo "$css_content" | grep -n "Custom user CSS" | cut -d: -f1)
|
||||
|
||||
if [ "$import_line" -ge "$custom_line" ]; then
|
||||
echo "Theme import should come before custom CSS"
|
||||
exit 1
|
||||
fi
|
||||
'';
|
||||
}
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
/**
|
||||
* GTK 4 reads the theme configured by gtk-theme-name, but ignores it.
|
||||
* It does however respect user CSS, so import the theme from here.
|
||||
**/
|
||||
@import url("file://@catppuccin-gtk@/share/themes/catppuccin-macchiato-blue-standard/gtk-4.0/gtk.css");
|
||||
|
|
@ -20,10 +20,11 @@
|
|||
in
|
||||
''
|
||||
assertFileExists ${gtk4Path}/settings.ini
|
||||
|
||||
assertFileContent ${gtk4Path}/settings.ini \
|
||||
${./gtk4-basic-settings-expected.ini}
|
||||
|
||||
assertFileExists ${gtk4Path}/gtk.css
|
||||
assertFileContent ${gtk4Path}/gtk.css \
|
||||
${./gtk4-basic-settings-expected.css}
|
||||
'';
|
||||
}
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
/* Custom user CSS */
|
||||
window {
|
||||
background-color: #2d2d2d;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 8px;
|
||||
}
|
||||
25
tests/modules/misc/gtk/gtk4/gtk4-no-theme-css-injection.nix
Normal file
25
tests/modules/misc/gtk/gtk4/gtk4-no-theme-css-injection.nix
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
# Test GTK4 theme CSS injection with both theme and custom CSS
|
||||
gtk = {
|
||||
enable = true;
|
||||
|
||||
gtk4 = {
|
||||
extraCss = ''
|
||||
/* Custom user CSS */
|
||||
window {
|
||||
background-color: #2d2d2d;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 8px;
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
# GTK4 CSS should exist and contain no theme import and only custom CSS
|
||||
assertFileExists home-files/.config/gtk-4.0/gtk.css
|
||||
assertFileContent home-files/.config/gtk-4.0/gtk.css ${./gtk4-no-theme-css-injection-expected.css}
|
||||
'';
|
||||
}
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
/**
|
||||
* GTK 4 reads the theme configured by gtk-theme-name, but ignores it.
|
||||
* It does however respect user CSS, so import the theme from here.
|
||||
**/
|
||||
@import url("file://@gnome-themes-extra@/share/themes/Adwaita-dark/gtk-4.0/gtk.css");
|
||||
/* Custom user CSS */
|
||||
window {
|
||||
background-color: #2d2d2d;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 8px;
|
||||
}
|
||||
30
tests/modules/misc/gtk/gtk4/gtk4-theme-css-injection.nix
Normal file
30
tests/modules/misc/gtk/gtk4/gtk4-theme-css-injection.nix
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
# Test GTK4 theme CSS injection with both theme and custom CSS
|
||||
gtk = {
|
||||
enable = true;
|
||||
|
||||
gtk4 = {
|
||||
theme = {
|
||||
name = "Adwaita-dark";
|
||||
package = pkgs.gnome-themes-extra;
|
||||
};
|
||||
extraCss = ''
|
||||
/* Custom user CSS */
|
||||
window {
|
||||
background-color: #2d2d2d;
|
||||
}
|
||||
|
||||
button {
|
||||
border-radius: 8px;
|
||||
}
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
# GTK4 CSS should exist and contain both theme import and custom CSS
|
||||
assertFileExists home-files/.config/gtk-4.0/gtk.css
|
||||
assertFileContent home-files/.config/gtk-4.0/gtk.css ${./gtk4-theme-css-injection-expected.css}
|
||||
'';
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue