diff --git a/modules/misc/dconf.nix b/modules/misc/dconf.nix
new file mode 100644
index 000000000..8c28fe9cd
--- /dev/null
+++ b/modules/misc/dconf.nix
@@ -0,0 +1,83 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+
+ cfg = config.dconf;
+ dag = config.lib.dag;
+
+ toDconfIni = generators.toINI { mkKeyValue = mkIniKeyValue; };
+
+ mkIniKeyValue = key: value:
+ let
+ tweakVal = v:
+ if isString v then "'${v}'"
+ else if isList v then "[" + concatMapStringsSep "," tweakVal v + "]"
+ else if isBool v then (if v then "true" else "false")
+ else toString v;
+ in
+ "${key}=${tweakVal value}";
+
+ primitive = with types; either bool (either int str);
+
+in
+
+{
+ meta.maintainers = [ maintainers.gnidorah maintainers.rycee ];
+
+ options = {
+ dconf = {
+ enable = mkOption {
+ type = types.bool;
+ default = true;
+ visible = false;
+ description = ''
+ Whether to enable dconf settings.
+ '';
+ };
+
+ settings = mkOption {
+ type = with types;
+ attrsOf (attrsOf (either primitive (listOf primitive)));
+ default = {};
+ example = literalExample ''
+ {
+ "org/gnome/calculator" = {
+ button-mode = "programming";
+ show-thousands = true;
+ base = 10;
+ word-size = 64;
+ };
+ }
+ '';
+ description = ''
+ Settings to write to the dconf configuration system.
+ '';
+ };
+ };
+ };
+
+ config = mkIf (cfg.enable && cfg.settings != {}) {
+ home.activation.dconfSettings = dag.entryAfter ["installPackages"] (
+ let
+ iniFile = pkgs.writeText "hm-dconf.ini" (toDconfIni cfg.settings);
+ in
+ ''
+ if [[ -v DBUS_SESSION_BUS_ADDRESS ]]; then
+ DCONF_DBUS_RUN_SESSION=""
+ else
+ DCONF_DBUS_RUN_SESSION="${pkgs.dbus}/bin/dbus-run-session"
+ fi
+
+ if [[ -v DRY_RUN ]]; then
+ echo $DCONF_DBUS_RUN_SESSION ${pkgs.gnome3.dconf}/bin/dconf load / "<" ${iniFile}
+ else
+ $DCONF_DBUS_RUN_SESSION ${pkgs.gnome3.dconf}/bin/dconf load / < ${iniFile}
+ fi
+
+ unset DCONF_DBUS_RUN_SESSION
+ ''
+ );
+ };
+}
diff --git a/modules/misc/gtk.nix b/modules/misc/gtk.nix
index 930823ff4..c88ee4c00 100644
--- a/modules/misc/gtk.nix
+++ b/modules/misc/gtk.nix
@@ -8,8 +8,6 @@ let
cfg2 = config.gtk.gtk2;
cfg3 = config.gtk.gtk3;
- dag = config.lib.dag;
-
toGtk3Ini = generators.toINI {
mkKeyValue = key: value:
let
@@ -29,16 +27,6 @@ let
in
"${n} = ${v'}";
- toDconfIni = generators.toINI {
- mkKeyValue = key: value:
- let
- tweakVal = v:
- if isString v then "'${v}'"
- else toString v;
- in
- "${key}=${tweakVal value}";
- };
-
fontType = types.submodule {
options = {
package = mkOption {
@@ -88,6 +76,12 @@ in
{
meta.maintainers = [ maintainers.rycee ];
+ imports = [
+ (mkRemovedOptionModule ["gtk" "gtk3" "waylandSupport"] ''
+ This options is not longer needed and can be removed.
+ '')
+ ];
+
options = {
gtk = {
enable = mkEnableOption "GTK 2/3 configuration";
@@ -112,63 +106,36 @@ in
description = "The GTK+2/3 theme to use.";
};
- gtk2 = mkOption {
- description = "Options specific to GTK+ 2";
- default = {};
- type = types.submodule {
- options = {
- extraConfig = mkOption {
- type = types.lines;
- default = "";
- example = "gtk-can-change-accels = 1";
- description = ''
- Extra configuration lines to add verbatim to
- ~/.gtkrc-2.0.
- '';
- };
- };
+ gtk2 = {
+ extraConfig = mkOption {
+ type = types.lines;
+ default = "";
+ example = "gtk-can-change-accels = 1";
+ description = ''
+ Extra configuration lines to add verbatim to
+ ~/.gtkrc-2.0.
+ '';
};
};
- gtk3 = mkOption {
- description = "Options specific to GTK+ 3";
- default = {};
- type = types.submodule {
- options = {
- extraConfig = mkOption {
- type = types.attrs;
- default = {};
- example = { gtk-cursor-blink = false; gtk-recent-files-limit = 20; };
- description = ''
- Extra configuration options to add to
- ~/.config/gtk-3.0/settings.ini.
- '';
- };
+ gtk3 = {
+ extraConfig = mkOption {
+ type = types.attrs;
+ default = {};
+ example = { gtk-cursor-blink = false; gtk-recent-files-limit = 20; };
+ description = ''
+ Extra configuration options to add to
+ ~/.config/gtk-3.0/settings.ini.
+ '';
+ };
- extraCss = mkOption {
- type = types.lines;
- default = "";
- description = ''
- Extra configuration lines to add verbatim to
- ~/.config/gtk-3.0/gtk.css.
- '';
- };
-
- waylandSupport = mkOption {
- type = types.bool;
- default = false;
- description = ''
- Support GSettings provider (dconf) in addition to
- GtkSettings (INI file). This is needed for Wayland.
-
- Note, on NixOS the following line must be in the
- system configuration:
-
- services.dbus.packages = [ pkgs.gnome3.dconf ];
-
- '';
- };
- };
+ extraCss = mkOption {
+ type = types.lines;
+ default = "";
+ description = ''
+ Extra configuration lines to add verbatim to
+ ~/.config/gtk-3.0/gtk.css.
+ '';
};
};
};
@@ -200,7 +167,6 @@ in
optional (opt != null && opt.package != null) opt.package;
in
{
-
home.packages =
optionalPackage cfg.font
++ optionalPackage cfg.theme
@@ -216,22 +182,7 @@ in
xdg.configFile."gtk-3.0/gtk.css".text = cfg3.extraCss;
- home.activation = mkIf cfg3.waylandSupport {
- gtk3 = dag.entryAfter ["installPackages"] (
- let
- iniText = toDconfIni { "/" = dconfIni; };
- iniFile = pkgs.writeText "gtk3.ini" iniText;
- dconfPath = "/org/gnome/desktop/interface/";
- in
- ''
- if [[ -v DRY_RUN ]]; then
- echo ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} "<" ${iniFile}
- else
- ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} < ${iniFile}
- fi
- ''
- );
- };
+ dconf.settings."org/gnome/desktop/interface" = dconfIni;
}
);
}
diff --git a/modules/misc/news.nix b/modules/misc/news.nix
index 959485513..344f569cf 100644
--- a/modules/misc/news.nix
+++ b/modules/misc/news.nix
@@ -904,6 +904,13 @@ in
A new module is available: 'programs.jq'.
'';
}
+
+ {
+ time = "2018-12-24T16:26:16+00:00";
+ message = ''
+ A new module is available: 'dconf'.
+ '';
+ }
];
};
}
diff --git a/modules/modules.nix b/modules/modules.nix
index aa9c4583a..45ab16a36 100644
--- a/modules/modules.nix
+++ b/modules/modules.nix
@@ -25,6 +25,7 @@ let
(loadModule ./files.nix { })
(loadModule ./home-environment.nix { })
(loadModule ./manual.nix { })
+ (loadModule ./misc/dconf.nix { })
(loadModule ./misc/fontconfig.nix { })
(loadModule ./misc/gtk.nix { })
(loadModule ./misc/lib.nix { })
diff --git a/modules/programs/gnome-terminal.nix b/modules/programs/gnome-terminal.nix
index fa3794643..afe12849d 100644
--- a/modules/programs/gnome-terminal.nix
+++ b/modules/programs/gnome-terminal.nix
@@ -6,8 +6,6 @@ let
cfg = config.programs.gnome-terminal;
- dag = config.lib.dag;
-
profileColorsSubModule = types.submodule (
{ ... }: {
options = {
@@ -91,19 +89,6 @@ let
}
);
- toDconfIni = generators.toINI { mkKeyValue = mkIniKeyValue; };
-
- mkIniKeyValue = key: value:
- let
- tweakVal = v:
- if isString v then "'${v}'"
- else if isList v then "[" + concatStringsSep "," (map tweakVal v) + "]"
- else if isBool v && v then "true"
- else if isBool v && !v then "false"
- else toString v;
- in
- "${key}=${tweakVal value}";
-
buildProfileSet = pcfg:
{
visible-name = pcfg.visibleName;
@@ -136,25 +121,6 @@ let
)
);
- buildIniSet = cfg:
- {
- "/" = {
- default-show-menubar = cfg.showMenubar;
- schema-version = 3;
- };
- }
- //
- {
- "profiles:" = {
- default = head (attrNames (filterAttrs (n: v: v.default) cfg.profile));
- list = attrNames cfg.profile;
- };
- }
- //
- mapAttrs' (name: value:
- nameValuePair ("profiles:/:${name}") (buildProfileSet value)
- ) cfg.profile;
-
in
{
@@ -181,20 +147,23 @@ in
config = mkIf cfg.enable {
home.packages = [ pkgs.gnome3.gnome_terminal ];
- # The dconf service needs to be installed and prepared.
- home.activation.gnomeTerminal = dag.entryAfter ["installPackages"] (
+ dconf.settings =
let
- iniText = toDconfIni (buildIniSet cfg);
- iniFile = pkgs.writeText "gnome-terminal.ini" iniText;
- dconfPath = "/org/gnome/terminal/legacy/";
+ dconfPath = "org/gnome/terminal/legacy";
in
- ''
- if [[ -v DRY_RUN ]]; then
- echo ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} "<" ${iniFile}
- else
- ${pkgs.gnome3.dconf}/bin/dconf load ${dconfPath} < ${iniFile}
- fi
- ''
- );
+ {
+ "${dconfPath}" = {
+ default-show-menubar = cfg.showMenubar;
+ schema-version = 3;
+ };
+
+ "${dconfPath}/profiles:" = {
+ default = head (attrNames (filterAttrs (n: v: v.default) cfg.profile));
+ list = attrNames cfg.profile;
+ };
+ }
+ // mapAttrs' (n: v:
+ nameValuePair ("${dconfPath}/profiles:/:${n}") (buildProfileSet v)
+ ) cfg.profile;
};
}