From 12fea5c39e97933f8cd413d0280f1bf3f4cc9b58 Mon Sep 17 00:00:00 2001 From: Shihaam Abdul Rahman Date: Wed, 23 Sep 2026 00:29:45 +0500 Subject: [PATCH] dark theme --- home/shihaam.nix | 1 + home/theme.nix | 61 ++++++++++++++++++++++++++++++++++ hosts/la2410/configuration.nix | 8 +++++ 3 files changed, 70 insertions(+) create mode 100644 home/theme.nix diff --git a/home/shihaam.nix b/home/shihaam.nix index a63a504..a2bc75a 100644 --- a/home/shihaam.nix +++ b/home/shihaam.nix @@ -10,6 +10,7 @@ ./nano.nix ./obs.nix ./sway.nix + ./theme.nix ]; home.username = "shihaam"; diff --git a/home/theme.nix b/home/theme.nix new file mode 100644 index 0000000..716dfea --- /dev/null +++ b/home/theme.nix @@ -0,0 +1,61 @@ +# Dark theme for GTK and Qt apps. +# +# There is no desktop environment on this machine to hand apps a theme, so +# every toolkit has to be told separately: +# +# GTK2 ~/.gtkrc-2.0 + GTK2_RC_FILES -- adw-gtk3 has no GTK2 variant, so +# old apps get Adwaita-dark from gnome-themes-extra instead. +# GTK3 gtk-3.0/settings.ini (gtk-theme-name + prefer-dark). +# GTK4 libadwaita apps ignore gtk-theme-name; they follow the +# color-scheme=prefer-dark that the gtk3 module also writes into +# dconf, which is why programs.dconf.enable is on system-side. +# Electron/ Chromium, Brave, Firefox and friends ask the settings portal for +# browsers color-scheme, and xdg-desktop-portal-gtk answers from that same +# dconf key. +# Qt5/Qt6 qt5ct/qt6ct, because nixpkgs builds qtbase without the qgtk3 +# platform theme (withGtk3 = false), so QT_QPA_PLATFORMTHEME=gtk3 +# would silently do nothing. +{ pkgs, ... }: + +{ + gtk = { + enable = true; + colorScheme = "dark"; + + theme = { + name = "adw-gtk3-dark"; + package = pkgs.adw-gtk3; + }; + + iconTheme = { + name = "Adwaita"; + package = pkgs.adwaita-icon-theme; + }; + + gtk2.theme = { + name = "Adwaita-dark"; + package = pkgs.gnome-themes-extra; + }; + }; + + qt = { + enable = true; + platformTheme.name = "qtct"; + + # Pulls adwaita-qt{,6} in without setting QT_STYLE_OVERRIDE -- that + # variable makes qt5ct/qt6ct skip their own config entirely. + style.package = [ pkgs.adwaita-qt pkgs.adwaita-qt6 ]; + + qt5ctSettings.Appearance = { + style = "Adwaita-Dark"; + icon_theme = "Adwaita"; + standard_dialogs = "xdgdesktopportal"; + }; + + qt6ctSettings.Appearance = { + style = "Adwaita-Dark"; + icon_theme = "Adwaita"; + standard_dialogs = "xdgdesktopportal"; + }; + }; +} diff --git a/hosts/la2410/configuration.nix b/hosts/la2410/configuration.nix index cc02d96..40d7496 100644 --- a/hosts/la2410/configuration.nix +++ b/hosts/la2410/configuration.nix @@ -250,9 +250,17 @@ security.doas.extraRules = [ default = [ "wlr" "gtk" ]; "org.freedesktop.impl.portal.ScreenCast" = [ "wlr" ]; "org.freedesktop.impl.portal.Screenshot" = [ "wlr" ]; + # How browsers and Electron apps learn the dark preference; wlr has no + # Settings implementation, so it has to be pinned to gtk explicitly. + "org.freedesktop.impl.portal.Settings" = [ "gtk" ]; }; }; + # GTK4/libadwaita apps and the settings portal read the dark preference out + # of dconf (see home/theme.nix), which needs a real dconf backend -- there is + # no desktop environment here to enable one. + programs.dconf.enable = true; + programs.waybar.enable = true; programs.xfconf.enable = true;