2018-11-04 18:51:40 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.dconf;
|
|
|
|
|
|
|
|
toDconfIni = generators.toINI { mkKeyValue = mkIniKeyValue; };
|
|
|
|
|
|
|
|
mkIniKeyValue = key: value:
|
2020-03-09 22:25:45 +00:00
|
|
|
"${key}=${toString (hm.gvariant.mkValue value)}";
|
2018-11-04 18:51:40 +00:00
|
|
|
|
|
|
|
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 {
|
2020-03-09 22:25:45 +00:00
|
|
|
type = with types; attrsOf (attrsOf hm.types.gvariant);
|
2018-11-04 18:51:40 +00:00
|
|
|
default = {};
|
|
|
|
example = literalExample ''
|
|
|
|
{
|
|
|
|
"org/gnome/calculator" = {
|
|
|
|
button-mode = "programming";
|
|
|
|
show-thousands = true;
|
|
|
|
base = 10;
|
|
|
|
word-size = 64;
|
2020-03-09 22:25:45 +00:00
|
|
|
window-position = lib.hm.gvariant.mkTuple [100 100];
|
2018-11-04 18:51:40 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Settings to write to the dconf configuration system.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf (cfg.enable && cfg.settings != {}) {
|
2020-01-16 22:41:14 +00:00
|
|
|
home.activation.dconfSettings = hm.dag.entryAfter ["installPackages"] (
|
2018-11-04 18:51:40 +00:00
|
|
|
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
|
2020-06-06 12:10:38 +00:00
|
|
|
echo $DCONF_DBUS_RUN_SESSION ${pkgs.dconf}/bin/dconf load / "<" ${iniFile}
|
2018-11-04 18:51:40 +00:00
|
|
|
else
|
2020-06-06 12:10:38 +00:00
|
|
|
$DCONF_DBUS_RUN_SESSION ${pkgs.dconf}/bin/dconf load / < ${iniFile}
|
2018-11-04 18:51:40 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
unset DCONF_DBUS_RUN_SESSION
|
|
|
|
''
|
|
|
|
);
|
|
|
|
};
|
|
|
|
}
|