Files
nix/hosts/common/configs/user/gui/gtk/default.nix
Nikolaos Karaolidis 98ce774210 Reorganize imports
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
2024-12-21 23:32:29 +02:00

109 lines
2.7 KiB
Nix

{
user ? throw "user argument is required",
home ? throw "home argument is required",
}:
{
config,
lib,
pkgs,
...
}:
let
hmConfig = config.home-manager.users.${user};
in
{
# FIXME: https://github.com/lassekongo83/adw-gtk3/issues/267
nixpkgs.overlays = [
(final: prev: {
adw-gtk3 = prev.adw-gtk3.overrideAttrs (oldAttrs: rec {
pname = "adw-gtk3";
version = "5.3";
src = pkgs.fetchFromGitHub {
owner = "lassekongo83";
repo = pname;
rev = "v${version}";
sha256 = "sha256-DpJLX9PJX1Q8dDOx7YOXQzgNECsKp5uGiCVTX6iSlbI=";
};
});
})
];
home-manager.users.${user} = {
gtk = {
enable = true;
theme = {
package = pkgs.adw-gtk3;
name = "adw-gtk3-dark";
};
font = {
name = builtins.head hmConfig.theme.font.sansSerif.names;
package = builtins.head hmConfig.theme.font.sansSerif.packages;
inherit (hmConfig.theme.font) size;
};
iconTheme = {
name = builtins.head hmConfig.theme.icon.names;
package = builtins.head hmConfig.theme.icon.packages;
};
gtk2.configLocation = "${home}/.config/gtk-2.0/gtkrc";
gtk3.extraCss = "@import './theme.css';";
gtk4.extraCss = "@import './theme.css';";
};
home = {
pointerCursor.gtk.enable = true;
file =
{
".icons/default/index.theme".enable = false;
}
// builtins.listToAttrs (
builtins.map (name: {
name = ".icons/${name}";
value.enable = false;
}) (hmConfig.theme.icon.names ++ hmConfig.theme.cursor.names)
);
};
theme.template = {
"${home}/.config/gtk-3.0/theme.css".source = ./theme.css;
"${home}/.config/gtk-4.0/theme.css".source = ./theme.css;
};
theme.initExtraConfig = "${
lib.meta.getExe (
pkgs.writeShellApplication {
name = "theme-gtk";
runtimeInputs = with pkgs; [
dbus
dconf
];
text = ''
MODE=$(cat "${hmConfig.theme.configDir}/mode")
if [ "$MODE" = "light" ]; then
GTK_THEME="adw-gtk3"
else
GTK_THEME="adw-gtk3-dark"
fi
if [[ -v DBUS_SESSION_BUS_ADDRESS ]]; then
DCONF_DBUS_RUN_SESSION=""
else
DCONF_DBUS_RUN_SESSION="dbus-run-session --dbus-daemon=dbus-daemon"
fi
$DCONF_DBUS_RUN_SESSION bash -c "
dconf write /org/gnome/desktop/interface/gtk-theme \"'$GTK_THEME'\"
dconf write /org/gnome/desktop/interface/color-scheme \"'prefer-$MODE'\"
"
'';
}
)
} &";
};
}