1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +01:00

gtk: improve theme and font configuration

Specifically, allow the user to specify the package that provides the
theme or font.

Fixes #1.
This commit is contained in:
Robert Helgesson 2017-11-08 01:17:46 +01:00
parent 592fd61788
commit bcb82da88f
No known key found for this signature in database
GPG key ID: C3DB11069E65DC86
2 changed files with 110 additions and 16 deletions

View file

@ -27,6 +27,50 @@ let
in in
"${n} = ${v'}"; "${n} = ${v'}";
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.";
};
};
};
in in
{ {
@ -36,27 +80,24 @@ in
gtk = { gtk = {
enable = mkEnableOption "GTK 2/3 configuration"; enable = mkEnableOption "GTK 2/3 configuration";
fontName = mkOption { font = mkOption {
type = types.nullOr types.str; type = types.nullOr fontType;
default = null; default = null;
example = "DejaVu Sans 8";
description = '' description = ''
The font to use in GTK+ 2/3 applications. The font to use in GTK+ 2/3 applications.
''; '';
}; };
themeName = mkOption { iconTheme = mkOption {
type = types.nullOr types.str; type = types.nullOr themeType;
default = null; default = null;
example = "Vertex-Dark"; description = "The icon theme to use.";
description = "The name of the GTK+2/3 theme to use.";
}; };
iconThemeName = mkOption { theme = mkOption {
type = types.nullOr types.str; type = types.nullOr themeType;
default = null; default = null;
example = "Tango"; description = "The GTK+2/3 theme to use.";
description = "The name of the icon theme to use.";
}; };
gtk2 = mkOption { gtk2 = mkOption {
@ -110,15 +151,24 @@ in
let let
ini = ini =
optionalAttrs (cfg.fontName != null) optionalAttrs (cfg.fontName != null)
{ gtk-font-name = cfg.fontName; } { gtk-font-name = cfg.font.name; }
// //
optionalAttrs (cfg.themeName != null) optionalAttrs (cfg.theme != null)
{ gtk-theme-name = cfg.themeName; } { gtk-theme-name = cfg.theme.name; }
// //
optionalAttrs (cfg.iconThemeName != null) optionalAttrs (cfg.iconTheme != null)
{ gtk-icon-theme-name = cfg.iconThemeName; }; { gtk-icon-theme-name = cfg.iconTheme.name; };
optionalPackage = opt:
optional (opt != null && opt.package != null) opt.package;
in in
{ {
home.packages =
optionalPackage cfg.font
++ optionalPackage cfg.theme
++ optionalPackage cfg.iconTheme;
home.file.".gtkrc-2.0".text = home.file.".gtkrc-2.0".text =
concatStringsSep "\n" ( concatStringsSep "\n" (
mapAttrsToList formatGtk2Option ini mapAttrsToList formatGtk2Option ini
@ -130,4 +180,21 @@ in
xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss; xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss;
} }
); );
imports =
let
name = n: [ "gtk" n ];
in [
(mkChangedOptionModule (name "fontName") (name "font") (
config: { name = getAttrFromPath (name "fontName") config; }
))
(mkChangedOptionModule (name "themeName") (name "theme") (
config: { name = getAttrFromPath (name "themeName") config; }
))
(mkChangedOptionModule (name "iconThemeName") (name "iconTheme") (
config: { name = getAttrFromPath (name "iconThemeName") config; }
))
];
} }

View file

@ -467,6 +467,33 @@ in
i3.config.focus.mouseWarping i3.config.focus.mouseWarping
''; '';
} }
{
time = "2017-11-23T00:31:12+00:00";
condition =
config.gtk.fontName != "_mkMergedOptionModule"
|| config.gtk.themeName != "_mkMergedOptionModule"
|| config.gtk.iconThemeName != "_mkMergedOptionModule";
message = ''
The options
gtk.fontName, gtk.themeName, and gtk.iconThemeName
are deprecated and will be removed on December 23, 2017.
Please use
gtk.font.name, gtk.theme.name, and gtk.iconTheme.name
instead. You can find information about these in the manual
page.
This change was made to introduce the options
'gtk.font.package', 'gtk.theme.package', and
'gtk.iconTheme.package', which allow you to specify the
package that provides the font or theme.
'';
}
]; ];
}; };
} }