mirror of
https://github.com/nix-community/home-manager
synced 2024-12-25 11:19:47 +01:00
systemd: avoid creating an empty user.conf
Due to the defaults in `systemd.user.settings`, the default value when there are no settings explicitly set is `{ Manager = { }; }`. This means an empty file is created even when `systemd.user.settings` is never used in home-manager configuration. Since user’s `user.conf` is preferred to the global `/etc/systemd/user.conf`, this can cause any values set in the latter to be discarded.
This commit is contained in:
parent
5136542501
commit
8ab4e866f5
3 changed files with 13 additions and 2 deletions
|
@ -4,7 +4,9 @@ let
|
||||||
|
|
||||||
cfg = config.systemd.user;
|
cfg = config.systemd.user;
|
||||||
|
|
||||||
inherit (lib) getAttr hm isBool literalExpression mkIf mkMerge mkOption types;
|
inherit (lib)
|
||||||
|
any attrValues getAttr hm isBool literalExpression mkIf mkMerge mkOption
|
||||||
|
types;
|
||||||
|
|
||||||
settingsFormat = pkgs.formats.ini { listsAsDuplicateKeys = true; };
|
settingsFormat = pkgs.formats.ini { listsAsDuplicateKeys = true; };
|
||||||
|
|
||||||
|
@ -93,7 +95,7 @@ let
|
||||||
+ "\n";
|
+ "\n";
|
||||||
};
|
};
|
||||||
|
|
||||||
settings = mkIf (cfg.settings != { }) {
|
settings = mkIf (any (v: v != { }) (attrValues cfg.settings)) {
|
||||||
"systemd/user.conf".source =
|
"systemd/user.conf".source =
|
||||||
settingsFormat.generate "user.conf" cfg.settings;
|
settingsFormat.generate "user.conf" cfg.settings;
|
||||||
};
|
};
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
systemd-services-disabled-for-root = ./services-disabled-for-root.nix;
|
systemd-services-disabled-for-root = ./services-disabled-for-root.nix;
|
||||||
systemd-session-variables = ./session-variables.nix;
|
systemd-session-variables = ./session-variables.nix;
|
||||||
systemd-user-config = ./user-config.nix;
|
systemd-user-config = ./user-config.nix;
|
||||||
|
systemd-empty-user-config = ./empty-user-config.nix;
|
||||||
systemd-slices = ./slices.nix;
|
systemd-slices = ./slices.nix;
|
||||||
systemd-timers = ./timers.nix;
|
systemd-timers = ./timers.nix;
|
||||||
}
|
}
|
||||||
|
|
8
tests/modules/systemd/empty-user-config.nix
Normal file
8
tests/modules/systemd/empty-user-config.nix
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
{ pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
nmt.script = ''
|
||||||
|
userConf=home-files/.config/systemd/user.conf
|
||||||
|
assertPathNotExists $userConf
|
||||||
|
'';
|
||||||
|
}
|
Loading…
Reference in a new issue