diff --git a/modules/systemd.nix b/modules/systemd.nix index 18e88819..041b9dfa 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -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; }; diff --git a/tests/modules/systemd/default.nix b/tests/modules/systemd/default.nix index 250b8c79..ee8a9ae6 100644 --- a/tests/modules/systemd/default.nix +++ b/tests/modules/systemd/default.nix @@ -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; } diff --git a/tests/modules/systemd/empty-user-config.nix b/tests/modules/systemd/empty-user-config.nix new file mode 100644 index 00000000..9e192ae4 --- /dev/null +++ b/tests/modules/systemd/empty-user-config.nix @@ -0,0 +1,8 @@ +{ pkgs, ... }: + +{ + nmt.script = '' + userConf=home-files/.config/systemd/user.conf + assertPathNotExists $userConf + ''; +}