From 28eb093a1e6999d52e60811008b4bfc7e20cc591 Mon Sep 17 00:00:00 2001 From: Robert Helgesson Date: Sun, 25 Oct 2020 22:39:02 +0100 Subject: [PATCH] systemd: use `listsAsDuplicateKeys` This causes list values to be emitted as a list of key-value pairs instead of a single key-value pair where the value is space separated. This is useful, e.g., for socket units that would like to specify more than one `ListenStream=` address. --- modules/systemd.nix | 1 + tests/modules/systemd/services-expected.conf | 5 ----- tests/modules/systemd/services.nix | 12 +++++++++++- 3 files changed, 12 insertions(+), 6 deletions(-) delete mode 100644 tests/modules/systemd/services-expected.conf diff --git a/modules/systemd.nix b/modules/systemd.nix index 66fffadf..dea6517e 100644 --- a/modules/systemd.nix +++ b/modules/systemd.nix @@ -14,6 +14,7 @@ let || cfg.sessionVariables != {}; toSystemdIni = generators.toINI { + listsAsDuplicateKeys = true; mkKeyValue = key: value: let value' = diff --git a/tests/modules/systemd/services-expected.conf b/tests/modules/systemd/services-expected.conf deleted file mode 100644 index 34b9618d..00000000 --- a/tests/modules/systemd/services-expected.conf +++ /dev/null @@ -1,5 +0,0 @@ -[Service] -ExecStart=/some/exec/start/command --with-arguments "%i" - -[Unit] -Description=A basic test service diff --git a/tests/modules/systemd/services.nix b/tests/modules/systemd/services.nix index ea9b2b4f..4f73c556 100644 --- a/tests/modules/systemd/services.nix +++ b/tests/modules/systemd/services.nix @@ -10,6 +10,7 @@ with lib; }; Service = { + Environment = [ "VAR1=1" "VAR2=2" ]; ExecStart = ''/some/exec/start/command --with-arguments "%i"''; }; }; @@ -17,7 +18,16 @@ with lib; nmt.script = '' serviceFile=home-files/.config/systemd/user/test-service@.service assertFileExists $serviceFile - assertFileContent $serviceFile ${./services-expected.conf} + assertFileContent $serviceFile \ + ${builtins.toFile "services-expected.conf" '' + [Service] + Environment=VAR1=1 + Environment=VAR2=2 + ExecStart=/some/exec/start/command --with-arguments "%i" + + [Unit] + Description=A basic test service + ''} ''; }; }