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.
This commit is contained in:
Robert Helgesson 2020-10-25 22:39:02 +01:00
parent abaebf3b34
commit 28eb093a1e
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
3 changed files with 12 additions and 6 deletions

View file

@ -14,6 +14,7 @@ let
|| cfg.sessionVariables != {}; || cfg.sessionVariables != {};
toSystemdIni = generators.toINI { toSystemdIni = generators.toINI {
listsAsDuplicateKeys = true;
mkKeyValue = key: value: mkKeyValue = key: value:
let let
value' = value' =

View file

@ -1,5 +0,0 @@
[Service]
ExecStart=/some/exec/start/command --with-arguments "%i"
[Unit]
Description=A basic test service

View file

@ -10,6 +10,7 @@ with lib;
}; };
Service = { Service = {
Environment = [ "VAR1=1" "VAR2=2" ];
ExecStart = ''/some/exec/start/command --with-arguments "%i"''; ExecStart = ''/some/exec/start/command --with-arguments "%i"'';
}; };
}; };
@ -17,7 +18,16 @@ with lib;
nmt.script = '' nmt.script = ''
serviceFile=home-files/.config/systemd/user/test-service@.service serviceFile=home-files/.config/systemd/user/test-service@.service
assertFileExists $serviceFile 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
''}
''; '';
}; };
} }