2017-01-16 23:47:03 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.gtk;
|
|
|
|
cfg2 = config.gtk.gtk2;
|
|
|
|
cfg3 = config.gtk.gtk3;
|
|
|
|
|
2017-09-21 11:18:33 +00:00
|
|
|
toGtk3Ini = generators.toINI {
|
2017-01-16 23:47:03 +00:00
|
|
|
mkKeyValue = key: value:
|
|
|
|
let
|
|
|
|
value' =
|
|
|
|
if isBool value then (if value then "true" else "false")
|
|
|
|
else toString value;
|
|
|
|
in
|
|
|
|
"${key}=${value'}";
|
|
|
|
};
|
|
|
|
|
|
|
|
formatGtk2Option = n: v:
|
|
|
|
let
|
|
|
|
v' =
|
|
|
|
if isBool v then (if v then "true" else "false")
|
|
|
|
else if isString v then "\"${v}\""
|
|
|
|
else toString v;
|
|
|
|
in
|
|
|
|
"${n} = ${v'}";
|
|
|
|
|
2017-11-08 00:17:46 +00:00
|
|
|
fontType = types.submodule {
|
|
|
|
options = {
|
|
|
|
package = mkOption {
|
|
|
|
type = types.nullOr types.package;
|
|
|
|
default = null;
|
|
|
|
example = literalExample "pkgs.dejavu_fonts";
|
|
|
|
description = ''
|
|
|
|
Package providing the font. This package will be installed
|
|
|
|
to your profile. If <literal>null</literal> then the font
|
|
|
|
is assumed to already be available in your profile.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
name = mkOption {
|
|
|
|
type = types.str;
|
|
|
|
example = "DejaVu Sans 8";
|
|
|
|
description = ''
|
|
|
|
The family name and size of the font within the package.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
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.";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-01-16 23:47:03 +00:00
|
|
|
in
|
|
|
|
|
|
|
|
{
|
2017-09-26 21:40:31 +00:00
|
|
|
meta.maintainers = [ maintainers.rycee ];
|
|
|
|
|
2018-12-24 11:05:28 +00:00
|
|
|
imports = [
|
|
|
|
(mkRemovedOptionModule ["gtk" "gtk3" "waylandSupport"] ''
|
|
|
|
This options is not longer needed and can be removed.
|
|
|
|
'')
|
|
|
|
];
|
|
|
|
|
2017-01-16 23:47:03 +00:00
|
|
|
options = {
|
|
|
|
gtk = {
|
|
|
|
enable = mkEnableOption "GTK 2/3 configuration";
|
|
|
|
|
2017-11-08 00:17:46 +00:00
|
|
|
font = mkOption {
|
|
|
|
type = types.nullOr fontType;
|
2017-01-16 23:47:03 +00:00
|
|
|
default = null;
|
|
|
|
description = ''
|
|
|
|
The font to use in GTK+ 2/3 applications.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2017-11-08 00:17:46 +00:00
|
|
|
iconTheme = mkOption {
|
|
|
|
type = types.nullOr themeType;
|
2017-01-16 23:47:03 +00:00
|
|
|
default = null;
|
2017-11-08 00:17:46 +00:00
|
|
|
description = "The icon theme to use.";
|
2017-01-16 23:47:03 +00:00
|
|
|
};
|
|
|
|
|
2017-11-08 00:17:46 +00:00
|
|
|
theme = mkOption {
|
|
|
|
type = types.nullOr themeType;
|
2017-01-16 23:47:03 +00:00
|
|
|
default = null;
|
2017-11-08 00:17:46 +00:00
|
|
|
description = "The GTK+2/3 theme to use.";
|
2017-01-16 23:47:03 +00:00
|
|
|
};
|
|
|
|
|
2018-12-24 11:07:26 +00: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-16 23:47:03 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-12-24 11:07:26 +00:00
|
|
|
gtk3 = {
|
|
|
|
extraConfig = mkOption {
|
2019-03-31 10:57:08 +00:00
|
|
|
type = with types; attrsOf (either bool (either int str));
|
2018-12-24 11:07:26 +00:00
|
|
|
default = {};
|
|
|
|
example = { gtk-cursor-blink = false; gtk-recent-files-limit = 20; };
|
|
|
|
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-16 23:47:03 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2017-01-17 17:16:45 +00:00
|
|
|
config = mkIf cfg.enable (
|
2017-01-16 23:47:03 +00:00
|
|
|
let
|
|
|
|
ini =
|
2017-11-24 21:25:36 +00:00
|
|
|
optionalAttrs (cfg.font != null)
|
2017-11-08 00:17:46 +00:00
|
|
|
{ gtk-font-name = cfg.font.name; }
|
2017-01-16 23:47:03 +00:00
|
|
|
//
|
2017-11-08 00:17:46 +00:00
|
|
|
optionalAttrs (cfg.theme != null)
|
|
|
|
{ gtk-theme-name = cfg.theme.name; }
|
2017-01-16 23:47:03 +00:00
|
|
|
//
|
2017-11-08 00:17:46 +00:00
|
|
|
optionalAttrs (cfg.iconTheme != null)
|
|
|
|
{ gtk-icon-theme-name = cfg.iconTheme.name; };
|
|
|
|
|
2018-09-22 16:30:13 +00:00
|
|
|
dconfIni =
|
|
|
|
optionalAttrs (cfg.font != null)
|
|
|
|
{ font-name = cfg.font.name; }
|
|
|
|
//
|
|
|
|
optionalAttrs (cfg.theme != null)
|
|
|
|
{ gtk-theme = cfg.theme.name; }
|
|
|
|
//
|
|
|
|
optionalAttrs (cfg.iconTheme != null)
|
|
|
|
{ icon-theme = cfg.iconTheme.name; };
|
|
|
|
|
2017-11-08 00:17:46 +00:00
|
|
|
optionalPackage = opt:
|
|
|
|
optional (opt != null && opt.package != null) opt.package;
|
2017-01-16 23:47:03 +00:00
|
|
|
in
|
|
|
|
{
|
2017-11-08 00:17:46 +00:00
|
|
|
home.packages =
|
|
|
|
optionalPackage cfg.font
|
|
|
|
++ optionalPackage cfg.theme
|
|
|
|
++ optionalPackage cfg.iconTheme;
|
|
|
|
|
2017-01-16 23:47:03 +00:00
|
|
|
home.file.".gtkrc-2.0".text =
|
|
|
|
concatStringsSep "\n" (
|
|
|
|
mapAttrsToList formatGtk2Option ini
|
|
|
|
) + "\n" + cfg2.extraConfig;
|
|
|
|
|
2017-10-24 16:30:35 +00:00
|
|
|
xdg.configFile."gtk-3.0/settings.ini".text =
|
2017-01-16 23:47:03 +00:00
|
|
|
toGtk3Ini { Settings = ini // cfg3.extraConfig; };
|
|
|
|
|
2017-10-24 16:30:35 +00:00
|
|
|
xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss;
|
2018-09-22 16:30:13 +00:00
|
|
|
|
2018-12-24 11:05:28 +00:00
|
|
|
dconf.settings."org/gnome/desktop/interface" = dconfIni;
|
2017-01-16 23:47:03 +00:00
|
|
|
}
|
|
|
|
);
|
|
|
|
}
|