2020-10-12 00:22:58 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
|
|
|
|
cfg = config.dconf;
|
|
|
|
|
|
|
|
toDconfIni = generators.toINI { mkKeyValue = mkIniKeyValue; };
|
|
|
|
|
2021-07-02 22:36:30 +00:00
|
|
|
mkIniKeyValue = key: value: "${key}=${toString (hm.gvariant.mkValue value)}";
|
2020-10-12 00:22:58 +00:00
|
|
|
|
2021-07-02 22:36:30 +00:00
|
|
|
in {
|
2020-10-12 00:22:58 +00:00
|
|
|
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 hm.types.gvariant);
|
2021-07-02 22:36:30 +00:00
|
|
|
default = { };
|
2021-11-04 16:42:44 +00:00
|
|
|
example = literalExpression ''
|
2020-10-12 00:22:58 +00:00
|
|
|
{
|
|
|
|
"org/gnome/calculator" = {
|
|
|
|
button-mode = "programming";
|
|
|
|
show-thousands = true;
|
|
|
|
base = 10;
|
|
|
|
word-size = 64;
|
|
|
|
window-position = lib.hm.gvariant.mkTuple [100 100];
|
|
|
|
};
|
|
|
|
}
|
|
|
|
'';
|
|
|
|
description = ''
|
|
|
|
Settings to write to the dconf configuration system.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2021-07-02 22:36:30 +00:00
|
|
|
config = mkIf (cfg.enable && cfg.settings != { }) {
|
|
|
|
# Make sure the dconf directory exists.
|
|
|
|
xdg.configFile."dconf/.keep".source = builtins.toFile "keep" "";
|
|
|
|
|
|
|
|
home.activation.dconfSettings = hm.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
|
2020-10-12 00:22:58 +00:00
|
|
|
|
2021-07-02 22:36:30 +00:00
|
|
|
if [[ -v DRY_RUN ]]; then
|
|
|
|
echo $DCONF_DBUS_RUN_SESSION ${pkgs.dconf}/bin/dconf load / "<" ${iniFile}
|
|
|
|
else
|
|
|
|
$DCONF_DBUS_RUN_SESSION ${pkgs.dconf}/bin/dconf load / < ${iniFile}
|
|
|
|
fi
|
2020-10-12 00:22:58 +00:00
|
|
|
|
2021-07-02 22:36:30 +00:00
|
|
|
unset DCONF_DBUS_RUN_SESSION
|
|
|
|
'');
|
2020-10-12 00:22:58 +00:00
|
|
|
};
|
|
|
|
}
|