2017-01-17 00:47:03 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.gtk;
|
|
|
|
cfg2 = config.gtk.gtk2;
|
|
|
|
cfg3 = config.gtk.gtk3;
|
|
|
|
|
2017-09-21 13:18:33 +02:00
|
|
|
toGtk3Ini = generators.toINI {
|
2017-01-17 00:47:03 +01:00
|
|
|
mkKeyValue = key: value:
|
|
|
|
let
|
2020-05-25 00:46:58 +02:00
|
|
|
value' = if isBool value then
|
|
|
|
(if value then "true" else "false")
|
|
|
|
else
|
|
|
|
toString value;
|
|
|
|
in "${key}=${value'}";
|
2017-01-17 00:47:03 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
formatGtk2Option = n: v:
|
|
|
|
let
|
2020-05-25 00:46:58 +02:00
|
|
|
v' = if isBool v then
|
|
|
|
(if v then "true" else "false")
|
|
|
|
else if isString v then
|
|
|
|
''"${v}"''
|
|
|
|
else
|
|
|
|
toString v;
|
|
|
|
in "${n} = ${v'}";
|
2017-01-17 00:47:03 +01:00
|
|
|
|
2017-11-08 01:17:46 +01:00
|
|
|
themeType = types.submodule {
|
|
|
|
options = {
|
|
|
|
package = mkOption {
|
|
|
|
type = types.nullOr types.package;
|
|
|
|
default = null;
|
|
|
|
example = literalExample "pkgs.gnome3.gnome_themes_standard";
|
|
|
|
description = ''
|
|
|
|
Package providing the theme. This package will be installed
|
|
|
|
to your profile. If <literal>null</literal> then the theme
|
|
|
|
is assumed to already be available in your profile.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "Adwaita";
|
|
|
|
description = "The name of the theme within the package.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-05-25 00:46:58 +02:00
|
|
|
in {
|
2017-09-26 23:40:31 +02:00
|
|
|
meta.maintainers = [ maintainers.rycee ];
|
|
|
|
|
2018-12-24 12:05:28 +01:00
|
|
|
imports = [
|
2020-05-25 00:46:58 +02:00
|
|
|
(mkRemovedOptionModule [ "gtk" "gtk3" "waylandSupport" ] ''
|
2018-12-24 12:05:28 +01:00
|
|
|
This options is not longer needed and can be removed.
|
|
|
|
'')
|
|
|
|
];
|
|
|
|
|
2017-01-17 00:47:03 +01:00
|
|
|
options = {
|
|
|
|
gtk = {
|
|
|
|
enable = mkEnableOption "GTK 2/3 configuration";
|
|
|
|
|
2017-11-08 01:17:46 +01:00
|
|
|
font = mkOption {
|
2020-02-23 11:11:12 +01:00
|
|
|
type = types.nullOr hm.types.fontType;
|
2017-01-17 00:47:03 +01:00
|
|
|
default = null;
|
|
|
|
description = ''
|
|
|
|
The font to use in GTK+ 2/3 applications.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2017-11-08 01:17:46 +01:00
|
|
|
iconTheme = mkOption {
|
|
|
|
type = types.nullOr themeType;
|
2017-01-17 00:47:03 +01:00
|
|
|
default = null;
|
2017-11-08 01:17:46 +01:00
|
|
|
description = "The icon theme to use.";
|
2017-01-17 00:47:03 +01:00
|
|
|
};
|
|
|
|
|
2017-11-08 01:17:46 +01:00
|
|
|
theme = mkOption {
|
|
|
|
type = types.nullOr themeType;
|
2017-01-17 00:47:03 +01:00
|
|
|
default = null;
|
2017-11-08 01:17:46 +01:00
|
|
|
description = "The GTK+2/3 theme to use.";
|
2017-01-17 00:47:03 +01:00
|
|
|
};
|
|
|
|
|
2018-12-24 12:07:26 +01:00
|
|
|
gtk2 = {
|
|
|
|
extraConfig = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
example = "gtk-can-change-accels = 1";
|
|
|
|
description = ''
|
|
|
|
Extra configuration lines to add verbatim to
|
|
|
|
<filename>~/.gtkrc-2.0</filename>.
|
|
|
|
'';
|
2017-01-17 00:47:03 +01:00
|
|
|
};
|
2021-04-30 08:56:01 +02:00
|
|
|
|
|
|
|
configLocation = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = "${config.home.homeDirectory}/.gtkrc-2.0";
|
|
|
|
defaultText =
|
|
|
|
literalExample ''"''${config.home.homeDirectory}/.gtkrc-2.0"'';
|
|
|
|
example =
|
|
|
|
literalExample ''"''${config.xdg.configHome}/gtk-2.0/gtkrc"'';
|
|
|
|
description = ''
|
|
|
|
The location to put the GTK configuration file.
|
|
|
|
'';
|
|
|
|
};
|
2017-01-17 00:47:03 +01:00
|
|
|
};
|
|
|
|
|
2018-12-24 12:07:26 +01:00
|
|
|
gtk3 = {
|
2020-04-04 22:27:16 +02:00
|
|
|
bookmarks = mkOption {
|
|
|
|
type = types.listOf types.str;
|
|
|
|
default = [ ];
|
|
|
|
example = [ "file:///home/jane/Documents" ];
|
|
|
|
description = "Bookmarks in the sidebar of the GTK file browser";
|
|
|
|
};
|
|
|
|
|
2018-12-24 12:07:26 +01:00
|
|
|
extraConfig = mkOption {
|
2019-03-31 12:57:08 +02:00
|
|
|
type = with types; attrsOf (either bool (either int str));
|
2020-05-25 00:46:58 +02:00
|
|
|
default = { };
|
|
|
|
example = {
|
|
|
|
gtk-cursor-blink = false;
|
|
|
|
gtk-recent-files-limit = 20;
|
|
|
|
};
|
2018-12-24 12:07:26 +01:00
|
|
|
description = ''
|
|
|
|
Extra configuration options to add to
|
|
|
|
<filename>~/.config/gtk-3.0/settings.ini</filename>.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
extraCss = mkOption {
|
|
|
|
type = types.lines;
|
|
|
|
default = "";
|
|
|
|
description = ''
|
|
|
|
Extra configuration lines to add verbatim to
|
|
|
|
<filename>~/.config/gtk-3.0/gtk.css</filename>.
|
|
|
|
'';
|
|
|
|
};
|
2017-01-17 00:47:03 +01:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2020-05-25 00:46:58 +02:00
|
|
|
config = mkIf cfg.enable (let
|
2021-04-07 16:18:09 +02:00
|
|
|
ini = optionalAttrs (cfg.font != null) {
|
|
|
|
gtk-font-name = let
|
|
|
|
fontSize =
|
|
|
|
optionalString (cfg.font.size != null) " ${toString cfg.font.size}";
|
|
|
|
in "${cfg.font.name}" + fontSize;
|
|
|
|
} // optionalAttrs (cfg.theme != null) { gtk-theme-name = cfg.theme.name; }
|
2020-05-25 00:46:58 +02:00
|
|
|
// optionalAttrs (cfg.iconTheme != null) {
|
|
|
|
gtk-icon-theme-name = cfg.iconTheme.name;
|
|
|
|
};
|
|
|
|
|
2021-04-10 03:45:14 +02:00
|
|
|
dconfIni = optionalAttrs (cfg.font != null) {
|
|
|
|
font-name = let
|
|
|
|
fontSize =
|
|
|
|
optionalString (cfg.font.size != null) " ${toString cfg.font.size}";
|
|
|
|
in "${cfg.font.name}" + fontSize;
|
|
|
|
} // optionalAttrs (cfg.theme != null) { gtk-theme = cfg.theme.name; }
|
2020-05-25 00:46:58 +02:00
|
|
|
// optionalAttrs (cfg.iconTheme != null) {
|
|
|
|
icon-theme = cfg.iconTheme.name;
|
|
|
|
};
|
|
|
|
|
|
|
|
optionalPackage = opt:
|
|
|
|
optional (opt != null && opt.package != null) opt.package;
|
|
|
|
in {
|
|
|
|
home.packages = optionalPackage cfg.font ++ optionalPackage cfg.theme
|
|
|
|
++ optionalPackage cfg.iconTheme;
|
|
|
|
|
2021-04-30 08:56:01 +02:00
|
|
|
home.file.${cfg2.configLocation}.text =
|
2020-05-25 00:46:58 +02:00
|
|
|
concatStringsSep "\n" (mapAttrsToList formatGtk2Option ini) + "\n"
|
|
|
|
+ cfg2.extraConfig;
|
|
|
|
|
2021-04-30 08:56:01 +02:00
|
|
|
home.sessionVariables.GTK2_RC_FILES = cfg2.configLocation;
|
|
|
|
|
2020-05-25 00:46:58 +02:00
|
|
|
xdg.configFile."gtk-3.0/settings.ini".text =
|
|
|
|
toGtk3Ini { Settings = ini // cfg3.extraConfig; };
|
|
|
|
|
|
|
|
xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss;
|
|
|
|
|
|
|
|
xdg.configFile."gtk-3.0/bookmarks" = mkIf (cfg3.bookmarks != [ ]) {
|
|
|
|
text = concatStringsSep "\n" cfg3.bookmarks;
|
|
|
|
};
|
2020-04-04 22:27:16 +02:00
|
|
|
|
2020-05-25 00:46:58 +02:00
|
|
|
dconf.settings."org/gnome/desktop/interface" = dconfIni;
|
|
|
|
});
|
2017-01-17 00:47:03 +01:00
|
|
|
}
|