at 18.09-beta 2.1 kB view raw
1import ./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 # wait for user services 50 $machine->waitForUnit("default.target","alice"); 51 52 # Regression test for https://github.com/NixOS/nixpkgs/issues/35415 53 subtest "configuration files are recognized by systemd", sub { 54 $machine->succeed('test -e /system_conf_read'); 55 $machine->succeed('test -e /home/alice/user_conf_read'); 56 $machine->succeed('test -z $(ls -1 /var/log/journal)'); 57 }; 58 59 # Regression test for https://github.com/NixOS/nixpkgs/issues/35268 60 subtest "file system with x-initrd.mount is not unmounted", sub { 61 $machine->shutdown; 62 $machine->waitForUnit('multi-user.target'); 63 # If the file system was unmounted during the shutdown the file system 64 # has a last mount time, because the file system wasn't checked. 65 $machine->fail('dumpe2fs /dev/vdb | grep -q "^Last mount time: *n/a"'); 66 }; 67 ''; 68}