diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix index f0fc8b1a..db374c35 100644 --- a/modules/misc/gtk.nix +++ b/modules/misc/gtk.nix @@ -27,6 +27,50 @@ let in "${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 null 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 null 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 { @@ -36,27 +80,24 @@ in gtk = { enable = mkEnableOption "GTK 2/3 configuration"; - fontName = mkOption { - type = types.nullOr types.str; + font = mkOption { + type = types.nullOr fontType; default = null; - example = "DejaVu Sans 8"; description = '' The font to use in GTK+ 2/3 applications. ''; }; - themeName = mkOption { - type = types.nullOr types.str; + iconTheme = mkOption { + type = types.nullOr themeType; default = null; - example = "Vertex-Dark"; - description = "The name of the GTK+2/3 theme to use."; + description = "The icon theme to use."; }; - iconThemeName = mkOption { - type = types.nullOr types.str; + theme = mkOption { + type = types.nullOr themeType; default = null; - example = "Tango"; - description = "The name of the icon theme to use."; + description = "The GTK+2/3 theme to use."; }; gtk2 = mkOption { @@ -110,15 +151,24 @@ in let ini = optionalAttrs (cfg.fontName != null) - { gtk-font-name = cfg.fontName; } + { gtk-font-name = cfg.font.name; } // - optionalAttrs (cfg.themeName != null) - { gtk-theme-name = cfg.themeName; } + optionalAttrs (cfg.theme != null) + { gtk-theme-name = cfg.theme.name; } // - optionalAttrs (cfg.iconThemeName != null) - { gtk-icon-theme-name = cfg.iconThemeName; }; + optionalAttrs (cfg.iconTheme != null) + { gtk-icon-theme-name = 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; + home.file.".gtkrc-2.0".text = concatStringsSep "\n" ( mapAttrsToList formatGtk2Option ini @@ -130,4 +180,21 @@ in 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; } + )) + ]; } diff --git a/modules/misc/news.nix b/modules/misc/news.nix index b27882ec..656e95e5 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -467,6 +467,33 @@ in 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. + ''; + } ]; }; }