|
| 1 | +import ./make-test.nix { |
| 2 | + name = "systemd"; |
| 3 | + |
| 4 | + machine = { lib, ... }: { |
| 5 | + imports = [ common/user-account.nix common/x11.nix ]; |
| 6 | + |
| 7 | + virtualisation.emptyDiskImages = [ 512 ]; |
| 8 | + |
| 9 | + fileSystems = lib.mkVMOverride { |
| 10 | + "/test-x-initrd-mount" = { |
| 11 | + device = "/dev/vdb"; |
| 12 | + fsType = "ext2"; |
| 13 | + autoFormat = true; |
| 14 | + noCheck = true; |
| 15 | + options = [ "x-initrd.mount" ]; |
| 16 | + }; |
| 17 | + }; |
| 18 | + |
| 19 | + systemd.extraConfig = "DefaultEnvironment=\"XXX_SYSTEM=foo\""; |
| 20 | + systemd.user.extraConfig = "DefaultEnvironment=\"XXX_USER=bar\""; |
| 21 | + services.journald.extraConfig = "Storage=volatile"; |
| 22 | + services.xserver.displayManager.auto.user = "alice"; |
| 23 | + |
| 24 | + systemd.services.testservice1 = { |
| 25 | + description = "Test Service 1"; |
| 26 | + wantedBy = [ "multi-user.target" ]; |
| 27 | + serviceConfig.Type = "oneshot"; |
| 28 | + script = '' |
| 29 | + if [ "$XXX_SYSTEM" = foo ]; then |
| 30 | + touch /system_conf_read |
| 31 | + fi |
| 32 | + ''; |
| 33 | + }; |
| 34 | + |
| 35 | + systemd.user.services.testservice2 = { |
| 36 | + description = "Test Service 2"; |
| 37 | + wantedBy = [ "default.target" ]; |
| 38 | + serviceConfig.Type = "oneshot"; |
| 39 | + script = '' |
| 40 | + if [ "$XXX_USER" = bar ]; then |
| 41 | + touch "$HOME/user_conf_read" |
| 42 | + fi |
| 43 | + ''; |
| 44 | + }; |
| 45 | + }; |
| 46 | + |
| 47 | + testScript = '' |
| 48 | + $machine->waitForX; |
| 49 | +
|
| 50 | + # Regression test for https://github.com/NixOS/nixpkgs/issues/35415 |
| 51 | + subtest "configuration files are recognized by systemd", sub { |
| 52 | + $machine->succeed('test -e /system_conf_read'); |
| 53 | + $machine->succeed('test -e /home/alice/user_conf_read'); |
| 54 | + $machine->succeed('test -z $(ls -1 /var/log/journal)'); |
| 55 | + }; |
| 56 | +
|
| 57 | + # Regression test for https://github.com/NixOS/nixpkgs/issues/35268 |
| 58 | + subtest "file system with x-initrd.mount is not unmounted", sub { |
| 59 | + $machine->shutdown; |
| 60 | + $machine->waitForUnit('multi-user.target'); |
| 61 | + # If the file system was unmounted during the shutdown the file system |
| 62 | + # has a last mount time, because the file system wasn't checked. |
| 63 | + $machine->fail('dumpe2fs /dev/vdb | grep -q "^Last mount time: *n/a"'); |
| 64 | + }; |
| 65 | + ''; |
| 66 | +} |
0 commit comments