1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-12-25 03:09: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:
Olli Helenius 2023-11-11 01:51:53 +02:00 committed by Mikilio
parent 5136542501
commit 8ab4e866f5
No known key found for this signature in database
GPG key ID: 5B2F1A890CF33F3F
3 changed files with 13 additions and 2 deletions

View file

@ -4,7 +4,9 @@ let
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; };
@ -93,7 +95,7 @@ let
+ "\n";
};
settings = mkIf (cfg.settings != { }) {
settings = mkIf (any (v: v != { }) (attrValues cfg.settings)) {
"systemd/user.conf".source =
settingsFormat.generate "user.conf" cfg.settings;
};

View file

@ -3,6 +3,7 @@
systemd-services-disabled-for-root = ./services-disabled-for-root.nix;
systemd-session-variables = ./session-variables.nix;
systemd-user-config = ./user-config.nix;
systemd-empty-user-config = ./empty-user-config.nix;
systemd-slices = ./slices.nix;
systemd-timers = ./timers.nix;
}

View file

@ -0,0 +1,8 @@
{ pkgs, ... }:
{
nmt.script = ''
userConf=home-files/.config/systemd/user.conf
assertPathNotExists $userConf
'';
}