aboutsummaryrefslogtreecommitdiff
path: root/home-manager/modules/misc/gtk.nix
diff options
context:
space:
mode:
Diffstat (limited to 'home-manager/modules/misc/gtk.nix')
-rw-r--r--home-manager/modules/misc/gtk.nix146
1 files changed, 61 insertions, 85 deletions
diff --git a/home-manager/modules/misc/gtk.nix b/home-manager/modules/misc/gtk.nix
index 1222db4ecab..bf25aaaf664 100644
--- a/home-manager/modules/misc/gtk.nix
+++ b/home-manager/modules/misc/gtk.nix
@@ -11,44 +11,22 @@ let
toGtk3Ini = generators.toINI {
mkKeyValue = key: value:
let
- value' =
- if isBool value then (if value then "true" else "false")
- else toString value;
- in
- "${key}=${value'}";
+ 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'}";
-
- 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.
- '';
- };
- };
- };
+ v' = if isBool v then
+ (if v then "true" else "false")
+ else if isString v then
+ ''"${v}"''
+ else
+ toString v;
+ in "${n} = ${v'}";
themeType = types.submodule {
options = {
@@ -71,13 +49,11 @@ let
};
};
-in
-
-{
+in {
meta.maintainers = [ maintainers.rycee ];
imports = [
- (mkRemovedOptionModule ["gtk" "gtk3" "waylandSupport"] ''
+ (mkRemovedOptionModule [ "gtk" "gtk3" "waylandSupport" ] ''
This options is not longer needed and can be removed.
'')
];
@@ -87,7 +63,7 @@ in
enable = mkEnableOption "GTK 2/3 configuration";
font = mkOption {
- type = types.nullOr fontType;
+ type = types.nullOr hm.types.fontType;
default = null;
description = ''
The font to use in GTK+ 2/3 applications.
@@ -119,10 +95,20 @@ in
};
gtk3 = {
+ bookmarks = mkOption {
+ type = types.listOf types.str;
+ default = [ ];
+ example = [ "file:///home/jane/Documents" ];
+ description = "Bookmarks in the sidebar of the GTK file browser";
+ };
+
extraConfig = mkOption {
type = with types; attrsOf (either bool (either int str));
- default = {};
- example = { gtk-cursor-blink = false; gtk-recent-files-limit = 20; };
+ 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>.
@@ -141,48 +127,38 @@ in
};
};
- config = mkIf cfg.enable (
- let
- ini =
- optionalAttrs (cfg.font != null)
- { gtk-font-name = cfg.font.name; }
- //
- optionalAttrs (cfg.theme != null)
- { gtk-theme-name = cfg.theme.name; }
- //
- optionalAttrs (cfg.iconTheme != null)
- { gtk-icon-theme-name = cfg.iconTheme.name; };
-
- 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; };
-
- 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
- ) + "\n" + cfg2.extraConfig;
-
- xdg.configFile."gtk-3.0/settings.ini".text =
- toGtk3Ini { Settings = ini // cfg3.extraConfig; };
-
- xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss;
-
- dconf.settings."org/gnome/desktop/interface" = dconfIni;
- }
- );
+ config = mkIf cfg.enable (let
+ ini = optionalAttrs (cfg.font != null) { gtk-font-name = cfg.font.name; }
+ // optionalAttrs (cfg.theme != null) { gtk-theme-name = cfg.theme.name; }
+ // optionalAttrs (cfg.iconTheme != null) {
+ gtk-icon-theme-name = cfg.iconTheme.name;
+ };
+
+ 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;
+ };
+
+ 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) + "\n"
+ + cfg2.extraConfig;
+
+ 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;
+ };
+
+ dconf.settings."org/gnome/desktop/interface" = dconfIni;
+ });
}