1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-26 21:19:45 +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 GitHub
parent f5182ffc42
commit e27be9db7b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
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
'';
}