dconf: format file

This commit is contained in:
Robert Helgesson 2020-12-21 23:22:22 +01:00
parent 2b1892e646
commit 8b3fca4ec5
No known key found for this signature in database
GPG Key ID: 36BDAA14C2797E89
2 changed files with 19 additions and 27 deletions

2
format
View File

@ -26,7 +26,6 @@ find . -name '*.nix' \
! -path ./modules/lib/default.nix \
! -path ./modules/lib/file-type.nix \
! -path ./modules/manual.nix \
! -path ./modules/misc/dconf.nix \
! -path ./modules/misc/news.nix \
! -path ./modules/misc/nixpkgs.nix \
! -path ./modules/misc/xdg.nix \
@ -51,7 +50,6 @@ find . -name '*.nix' \
! -path ./tests/modules/home-environment/default.nix \
! -path ./tests/modules/home-environment/session-variables.nix \
! -path ./tests/modules/programs/gpg/override-defaults.nix \
! -path ./tests/modules/programs/tmux/default.nix \
! -path ./tests/modules/programs/zsh/session-variables.nix \
! -path ./tests/modules/services/sxhkd/service.nix \
! -path ./tests/modules/systemd/services.nix \

View File

@ -8,12 +8,9 @@ let
toDconfIni = generators.toINI { mkKeyValue = mkIniKeyValue; };
mkIniKeyValue = key: value:
"${key}=${toString (hm.gvariant.mkValue value)}";
mkIniKeyValue = key: value: "${key}=${toString (hm.gvariant.mkValue value)}";
in
{
in {
meta.maintainers = [ maintainers.gnidorah maintainers.rycee ];
options = {
@ -29,7 +26,7 @@ in
settings = mkOption {
type = with types; attrsOf (attrsOf hm.types.gvariant);
default = {};
default = { };
example = literalExample ''
{
"org/gnome/calculator" = {
@ -48,26 +45,23 @@ in
};
};
config = mkIf (cfg.enable && cfg.settings != {}) {
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
config = mkIf (cfg.enable && cfg.settings != { }) {
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
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
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
unset DCONF_DBUS_RUN_SESSION
''
);
unset DCONF_DBUS_RUN_SESSION
'');
};
}