mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
dconf: revert: dconf: Provide dconf (#7215)
Providing dconf via hm in this manner provided to be problematic for
user with systems that were already providing dconf (like ubunut).
Revert ff73544e4a
This commit is contained in:
parent
13a45ede6c
commit
09b0a4b0da
2 changed files with 63 additions and 65 deletions
|
|
@ -33,7 +33,8 @@ in
|
||||||
|
|
||||||
options = {
|
options = {
|
||||||
dconf = {
|
dconf = {
|
||||||
enable = lib.mkEnableOption "dconf" // {
|
enable = lib.mkOption {
|
||||||
|
type = types.bool;
|
||||||
# While technically dconf on darwin could work, our activation step
|
# While technically dconf on darwin could work, our activation step
|
||||||
# requires dbus, which only *lightly* supports Darwin in general, and
|
# requires dbus, which only *lightly* supports Darwin in general, and
|
||||||
# not at all in the way it's packaged in nixpkgs. Because of this, we
|
# not at all in the way it's packaged in nixpkgs. Because of this, we
|
||||||
|
|
@ -42,6 +43,13 @@ in
|
||||||
# re-enabled, unclear whether there's actual value in it though.
|
# re-enabled, unclear whether there's actual value in it though.
|
||||||
default = !pkgs.stdenv.hostPlatform.isDarwin;
|
default = !pkgs.stdenv.hostPlatform.isDarwin;
|
||||||
visible = false;
|
visible = false;
|
||||||
|
description = ''
|
||||||
|
Whether to enable dconf settings.Add commentMore actions
|
||||||
|
Note, if you use NixOS then you must add
|
||||||
|
`programs.dconf.enable = true`
|
||||||
|
to your system configuration. Otherwise you will see a systemd error
|
||||||
|
message when your configuration is activated.
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
settings = lib.mkOption {
|
settings = lib.mkOption {
|
||||||
|
|
@ -76,79 +84,70 @@ in
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkMerge [
|
config = lib.mkIf (cfg.enable && cfg.settings != { }) {
|
||||||
(lib.mkIf cfg.enable {
|
# Make sure the dconf directory exists.
|
||||||
home.packages = [ pkgs.dconf ];
|
xdg.configFile."dconf/.keep".source = builtins.toFile "keep" "";
|
||||||
dbus.packages = [ pkgs.dconf ];
|
|
||||||
home.sessionVariablesExtra = ''
|
|
||||||
export GIO_EXTRA_MODULES="${pkgs.dconf.lib}/lib/gio/modules''${GIO_EXTRA_MODULES:+:}$GIO_EXTRA_MODULES"
|
|
||||||
'';
|
|
||||||
})
|
|
||||||
(lib.mkIf (cfg.enable && cfg.settings != { }) {
|
|
||||||
# Make sure the dconf directory exists.
|
|
||||||
xdg.configFile."dconf/.keep".source = builtins.toFile "keep" "";
|
|
||||||
|
|
||||||
home.extraBuilderCommands = ''
|
home.extraBuilderCommands = ''
|
||||||
mkdir -p $out/state/
|
mkdir -p $out/state/
|
||||||
ln -s ${stateDconfKeys} $out/state/${stateDconfKeys.name}
|
ln -s ${stateDconfKeys} $out/state/${stateDconfKeys.name}
|
||||||
'';
|
'';
|
||||||
|
|
||||||
home.activation.dconfSettings = lib.hm.dag.entryAfter [ "installPackages" ] (
|
home.activation.dconfSettings = lib.hm.dag.entryAfter [ "installPackages" ] (
|
||||||
let
|
let
|
||||||
iniFile = pkgs.writeText "hm-dconf.ini" (toDconfIni cfg.settings);
|
iniFile = pkgs.writeText "hm-dconf.ini" (toDconfIni cfg.settings);
|
||||||
|
|
||||||
statePath = "state/${stateDconfKeys.name}";
|
statePath = "state/${stateDconfKeys.name}";
|
||||||
|
|
||||||
cleanup = pkgs.writeShellScript "dconf-cleanup" ''
|
cleanup = pkgs.writeShellScript "dconf-cleanup" ''
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
${config.lib.bash.initHomeManagerLib}
|
${config.lib.bash.initHomeManagerLib}
|
||||||
|
|
||||||
PATH=${
|
PATH=${
|
||||||
lib.makeBinPath [
|
lib.makeBinPath [
|
||||||
pkgs.dconf
|
pkgs.dconf
|
||||||
pkgs.jq
|
pkgs.jq
|
||||||
]
|
]
|
||||||
}''${PATH:+:}$PATH
|
}''${PATH:+:}$PATH
|
||||||
|
|
||||||
oldState="$1"
|
oldState="$1"
|
||||||
newState="$2"
|
newState="$2"
|
||||||
|
|
||||||
# Can't do cleanup if we don't know the old state.
|
# Can't do cleanup if we don't know the old state.
|
||||||
if [[ ! -f $oldState ]]; then
|
if [[ ! -f $oldState ]]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
|
||||||
|
|
||||||
# Reset all keys that are present in the old generation but not the new
|
|
||||||
# one.
|
|
||||||
jq -r -n \
|
|
||||||
--slurpfile old "$oldState" \
|
|
||||||
--slurpfile new "$newState" \
|
|
||||||
'($old[] - $new[])[]' \
|
|
||||||
| while read -r key; do
|
|
||||||
verboseEcho "Resetting dconf key \"$key\""
|
|
||||||
run $DCONF_DBUS_RUN_SESSION dconf reset "$key"
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
in
|
|
||||||
''
|
|
||||||
if [[ -v DBUS_SESSION_BUS_ADDRESS ]]; then
|
|
||||||
export DCONF_DBUS_RUN_SESSION=""
|
|
||||||
else
|
|
||||||
export DCONF_DBUS_RUN_SESSION="${pkgs.dbus}/bin/dbus-run-session --dbus-daemon=${pkgs.dbus}/bin/dbus-daemon"
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -v oldGenPath ]]; then
|
# Reset all keys that are present in the old generation but not the new
|
||||||
${cleanup} \
|
# one.
|
||||||
"$oldGenPath/${statePath}" \
|
jq -r -n \
|
||||||
"$newGenPath/${statePath}"
|
--slurpfile old "$oldState" \
|
||||||
fi
|
--slurpfile new "$newState" \
|
||||||
|
'($old[] - $new[])[]' \
|
||||||
|
| while read -r key; do
|
||||||
|
verboseEcho "Resetting dconf key \"$key\""
|
||||||
|
run $DCONF_DBUS_RUN_SESSION dconf reset "$key"
|
||||||
|
done
|
||||||
|
'';
|
||||||
|
in
|
||||||
|
''
|
||||||
|
if [[ -v DBUS_SESSION_BUS_ADDRESS ]]; then
|
||||||
|
export DCONF_DBUS_RUN_SESSION=""
|
||||||
|
else
|
||||||
|
export DCONF_DBUS_RUN_SESSION="${pkgs.dbus}/bin/dbus-run-session --dbus-daemon=${pkgs.dbus}/bin/dbus-daemon"
|
||||||
|
fi
|
||||||
|
|
||||||
run $DCONF_DBUS_RUN_SESSION ${pkgs.dconf}/bin/dconf load / < ${iniFile}
|
if [[ -v oldGenPath ]]; then
|
||||||
|
${cleanup} \
|
||||||
|
"$oldGenPath/${statePath}" \
|
||||||
|
"$newGenPath/${statePath}"
|
||||||
|
fi
|
||||||
|
|
||||||
unset DCONF_DBUS_RUN_SESSION
|
run $DCONF_DBUS_RUN_SESSION ${pkgs.dconf}/bin/dconf load / < ${iniFile}
|
||||||
''
|
|
||||||
);
|
unset DCONF_DBUS_RUN_SESSION
|
||||||
})
|
''
|
||||||
];
|
);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,6 @@ let
|
||||||
export XDG_DATA_HOME="/home/hm-user/.local/share"
|
export XDG_DATA_HOME="/home/hm-user/.local/share"
|
||||||
export XDG_STATE_HOME="/home/hm-user/.local/state"
|
export XDG_STATE_HOME="/home/hm-user/.local/state"
|
||||||
|
|
||||||
export GIO_EXTRA_MODULES="${pkgs.dconf}/lib/gio/modules''${GIO_EXTRA_MODULES:+:}$GIO_EXTRA_MODULES"
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
darwinExpected = ''
|
darwinExpected = ''
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue