1 { pkgs, lib, stdenv, ... }:
4 failures = lib.runTests {
5 # Merging two non-list definitions must still result in an error
6 # about a conflicting definition.
7 test-unitOption-merging-non-lists-conflict =
8 let nixos = pkgs.nixos {
9 system.stateVersion = lib.trivial.release;
10 systemd.services.systemd-test-nixos = {
11 serviceConfig = lib.mkMerge [
12 { StateDirectory = "foo"; }
13 { StateDirectory = "bar"; }
18 expr = (builtins.tryEval (nixos.config.systemd.services.systemd-test-nixos.serviceConfig.StateDirectory)).success;
22 # Merging must lift non-list definitions to a list
23 # if at least one of them is a list.
24 test-unitOption-merging-list-non-list-append =
25 let nixos = pkgs.nixos {
26 system.stateVersion = lib.trivial.release;
27 systemd.services.systemd-test-nixos = {
28 serviceConfig = lib.mkMerge [
29 { StateDirectory = "foo"; }
30 { StateDirectory = ["bar"]; }
35 expr = nixos.config.systemd.services.systemd-test-nixos.serviceConfig.StateDirectory;
36 expected = [ "foo" "bar" ];
41 lib.optional (failures != [])
42 (throw "The following systemd unit tests failed: ${lib.generators.toPretty {} failures}")