2019-07-25 20:50:02 +02:00
|
|
|
import ./make-test.nix ({ pkgs, ... }: {
|
systemd: Update to latest NixOS branch
Updated to the latest version of the nixos-v237 branch, which fixes two
things:
* Make sure that systemd looks in /etc for configuration files.
https://github.com/NixOS/systemd/pull/15
* Fix handling of the x-initrd.mount option.
https://github.com/NixOS/systemd/pull/16
I've added NixOS VM tests for both to ensure we won't run into
regressions. The newly added systemd test only tests for that and is by
no means exhaustive, but it's a start.
Personally I only wanted to fix the former issue, because that's the one
I've been debugging. After sending in a pull request for our systemd
fork (https://github.com/NixOS/systemd/pull/17) I got a notice from
@Mic92, that he already fixed this and his fix was even better as it's
even suitable for upstream (so we hopefully can drop that patch
someday).
The reason why the second one came in was simply because it has been
merged before the former, but I thought it would be a good idea to have
tests for that as well.
In addition I've removed the sysconfdir=$out/etc entry to make sure the
default (/etc) is used. Installing is still done to $out, because those
directories that were previously into sysconfdir now get into
factoryconfdir.
Quote from commit NixOS/systemd@98067cc806ae0d2759cdd2334f230cd8548e531:
By default systemd should read all its configuration from /etc.
Therefore we rely on -Dsysconfdir=/etc in meson as default value.
Unfortunately this would also lead to installation of systemd's own
configuration files to `/etc` whereas we are limited to /nix/store. To
counter that this commit introduces two new configuration variables
`factoryconfdir` and `factorypkgconfdir` to install systemd's own
configuration into nix store again, while having executables looking
up files in /etc.
Tested this change against all of the NixOS VM tests we have in
nixos/release.nix. Between this change and its parent no new tests were
failing (although a lot of them were flaky).
Signed-off-by: aszlig <aszlig@nix.build>
Cc: @Mic92, @tk-ecotelecom, @edolstra, @fpletz
Fixes: #35415
Fixes: #35268
2018-03-03 07:10:22 +01:00
|
|
|
name = "systemd";
|
|
|
|
|
|
|
|
machine = { lib, ... }: {
|
|
|
|
imports = [ common/user-account.nix common/x11.nix ];
|
|
|
|
|
|
|
|
virtualisation.emptyDiskImages = [ 512 ];
|
|
|
|
|
|
|
|
fileSystems = lib.mkVMOverride {
|
|
|
|
"/test-x-initrd-mount" = {
|
|
|
|
device = "/dev/vdb";
|
|
|
|
fsType = "ext2";
|
|
|
|
autoFormat = true;
|
|
|
|
noCheck = true;
|
|
|
|
options = [ "x-initrd.mount" ];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.extraConfig = "DefaultEnvironment=\"XXX_SYSTEM=foo\"";
|
|
|
|
systemd.user.extraConfig = "DefaultEnvironment=\"XXX_USER=bar\"";
|
|
|
|
services.journald.extraConfig = "Storage=volatile";
|
|
|
|
services.xserver.displayManager.auto.user = "alice";
|
|
|
|
|
2019-07-25 20:50:02 +02:00
|
|
|
systemd.shutdown.test = pkgs.writeScript "test.shutdown" ''
|
|
|
|
#!${pkgs.stdenv.shell}
|
|
|
|
PATH=${lib.makeBinPath (with pkgs; [ utillinux coreutils ])}
|
|
|
|
mount -t 9p shared -o trans=virtio,version=9p2000.L /tmp/shared
|
|
|
|
touch /tmp/shared/shutdown-test
|
|
|
|
umount /tmp/shared
|
|
|
|
'';
|
|
|
|
|
systemd: Update to latest NixOS branch
Updated to the latest version of the nixos-v237 branch, which fixes two
things:
* Make sure that systemd looks in /etc for configuration files.
https://github.com/NixOS/systemd/pull/15
* Fix handling of the x-initrd.mount option.
https://github.com/NixOS/systemd/pull/16
I've added NixOS VM tests for both to ensure we won't run into
regressions. The newly added systemd test only tests for that and is by
no means exhaustive, but it's a start.
Personally I only wanted to fix the former issue, because that's the one
I've been debugging. After sending in a pull request for our systemd
fork (https://github.com/NixOS/systemd/pull/17) I got a notice from
@Mic92, that he already fixed this and his fix was even better as it's
even suitable for upstream (so we hopefully can drop that patch
someday).
The reason why the second one came in was simply because it has been
merged before the former, but I thought it would be a good idea to have
tests for that as well.
In addition I've removed the sysconfdir=$out/etc entry to make sure the
default (/etc) is used. Installing is still done to $out, because those
directories that were previously into sysconfdir now get into
factoryconfdir.
Quote from commit NixOS/systemd@98067cc806ae0d2759cdd2334f230cd8548e531:
By default systemd should read all its configuration from /etc.
Therefore we rely on -Dsysconfdir=/etc in meson as default value.
Unfortunately this would also lead to installation of systemd's own
configuration files to `/etc` whereas we are limited to /nix/store. To
counter that this commit introduces two new configuration variables
`factoryconfdir` and `factorypkgconfdir` to install systemd's own
configuration into nix store again, while having executables looking
up files in /etc.
Tested this change against all of the NixOS VM tests we have in
nixos/release.nix. Between this change and its parent no new tests were
failing (although a lot of them were flaky).
Signed-off-by: aszlig <aszlig@nix.build>
Cc: @Mic92, @tk-ecotelecom, @edolstra, @fpletz
Fixes: #35415
Fixes: #35268
2018-03-03 07:10:22 +01:00
|
|
|
systemd.services.testservice1 = {
|
|
|
|
description = "Test Service 1";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
serviceConfig.Type = "oneshot";
|
|
|
|
script = ''
|
|
|
|
if [ "$XXX_SYSTEM" = foo ]; then
|
|
|
|
touch /system_conf_read
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.user.services.testservice2 = {
|
|
|
|
description = "Test Service 2";
|
|
|
|
wantedBy = [ "default.target" ];
|
|
|
|
serviceConfig.Type = "oneshot";
|
|
|
|
script = ''
|
|
|
|
if [ "$XXX_USER" = bar ]; then
|
|
|
|
touch "$HOME/user_conf_read"
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
testScript = ''
|
|
|
|
$machine->waitForX;
|
2018-04-16 00:43:33 +02:00
|
|
|
# wait for user services
|
|
|
|
$machine->waitForUnit("default.target","alice");
|
systemd: Update to latest NixOS branch
Updated to the latest version of the nixos-v237 branch, which fixes two
things:
* Make sure that systemd looks in /etc for configuration files.
https://github.com/NixOS/systemd/pull/15
* Fix handling of the x-initrd.mount option.
https://github.com/NixOS/systemd/pull/16
I've added NixOS VM tests for both to ensure we won't run into
regressions. The newly added systemd test only tests for that and is by
no means exhaustive, but it's a start.
Personally I only wanted to fix the former issue, because that's the one
I've been debugging. After sending in a pull request for our systemd
fork (https://github.com/NixOS/systemd/pull/17) I got a notice from
@Mic92, that he already fixed this and his fix was even better as it's
even suitable for upstream (so we hopefully can drop that patch
someday).
The reason why the second one came in was simply because it has been
merged before the former, but I thought it would be a good idea to have
tests for that as well.
In addition I've removed the sysconfdir=$out/etc entry to make sure the
default (/etc) is used. Installing is still done to $out, because those
directories that were previously into sysconfdir now get into
factoryconfdir.
Quote from commit NixOS/systemd@98067cc806ae0d2759cdd2334f230cd8548e531:
By default systemd should read all its configuration from /etc.
Therefore we rely on -Dsysconfdir=/etc in meson as default value.
Unfortunately this would also lead to installation of systemd's own
configuration files to `/etc` whereas we are limited to /nix/store. To
counter that this commit introduces two new configuration variables
`factoryconfdir` and `factorypkgconfdir` to install systemd's own
configuration into nix store again, while having executables looking
up files in /etc.
Tested this change against all of the NixOS VM tests we have in
nixos/release.nix. Between this change and its parent no new tests were
failing (although a lot of them were flaky).
Signed-off-by: aszlig <aszlig@nix.build>
Cc: @Mic92, @tk-ecotelecom, @edolstra, @fpletz
Fixes: #35415
Fixes: #35268
2018-03-03 07:10:22 +01:00
|
|
|
|
|
|
|
# Regression test for https://github.com/NixOS/nixpkgs/issues/35415
|
|
|
|
subtest "configuration files are recognized by systemd", sub {
|
|
|
|
$machine->succeed('test -e /system_conf_read');
|
|
|
|
$machine->succeed('test -e /home/alice/user_conf_read');
|
|
|
|
$machine->succeed('test -z $(ls -1 /var/log/journal)');
|
|
|
|
};
|
|
|
|
|
2018-11-13 17:06:03 +01:00
|
|
|
# Regression test for https://github.com/NixOS/nixpkgs/issues/50273
|
|
|
|
subtest "DynamicUser actually allocates a user", sub {
|
|
|
|
$machine->succeed('systemd-run --pty --property=Type=oneshot --property=DynamicUser=yes --property=User=iamatest whoami | grep iamatest');
|
|
|
|
};
|
|
|
|
|
systemd: Update to latest NixOS branch
Updated to the latest version of the nixos-v237 branch, which fixes two
things:
* Make sure that systemd looks in /etc for configuration files.
https://github.com/NixOS/systemd/pull/15
* Fix handling of the x-initrd.mount option.
https://github.com/NixOS/systemd/pull/16
I've added NixOS VM tests for both to ensure we won't run into
regressions. The newly added systemd test only tests for that and is by
no means exhaustive, but it's a start.
Personally I only wanted to fix the former issue, because that's the one
I've been debugging. After sending in a pull request for our systemd
fork (https://github.com/NixOS/systemd/pull/17) I got a notice from
@Mic92, that he already fixed this and his fix was even better as it's
even suitable for upstream (so we hopefully can drop that patch
someday).
The reason why the second one came in was simply because it has been
merged before the former, but I thought it would be a good idea to have
tests for that as well.
In addition I've removed the sysconfdir=$out/etc entry to make sure the
default (/etc) is used. Installing is still done to $out, because those
directories that were previously into sysconfdir now get into
factoryconfdir.
Quote from commit NixOS/systemd@98067cc806ae0d2759cdd2334f230cd8548e531:
By default systemd should read all its configuration from /etc.
Therefore we rely on -Dsysconfdir=/etc in meson as default value.
Unfortunately this would also lead to installation of systemd's own
configuration files to `/etc` whereas we are limited to /nix/store. To
counter that this commit introduces two new configuration variables
`factoryconfdir` and `factorypkgconfdir` to install systemd's own
configuration into nix store again, while having executables looking
up files in /etc.
Tested this change against all of the NixOS VM tests we have in
nixos/release.nix. Between this change and its parent no new tests were
failing (although a lot of them were flaky).
Signed-off-by: aszlig <aszlig@nix.build>
Cc: @Mic92, @tk-ecotelecom, @edolstra, @fpletz
Fixes: #35415
Fixes: #35268
2018-03-03 07:10:22 +01:00
|
|
|
# Regression test for https://github.com/NixOS/nixpkgs/issues/35268
|
|
|
|
subtest "file system with x-initrd.mount is not unmounted", sub {
|
|
|
|
$machine->shutdown;
|
|
|
|
$machine->waitForUnit('multi-user.target');
|
|
|
|
# If the file system was unmounted during the shutdown the file system
|
|
|
|
# has a last mount time, because the file system wasn't checked.
|
|
|
|
$machine->fail('dumpe2fs /dev/vdb | grep -q "^Last mount time: *n/a"');
|
|
|
|
};
|
2019-07-25 20:50:02 +02:00
|
|
|
|
|
|
|
subtest "systemd-shutdown works", sub {
|
|
|
|
$machine->shutdown;
|
|
|
|
$machine->waitForUnit('multi-user.target');
|
|
|
|
$machine->succeed('test -e /tmp/shared/shutdown-test');
|
|
|
|
};
|
2019-08-18 13:19:01 +02:00
|
|
|
|
|
|
|
# Test settings from /etc/sysctl.d/50-default.conf are applied
|
|
|
|
subtest "systemd sysctl settings are applied", sub {
|
|
|
|
$machine->waitForUnit('multi-user.target');
|
|
|
|
$machine->succeed('sysctl net.core.default_qdisc | grep -q "fq_codel"');
|
|
|
|
};
|
2019-08-19 17:59:30 +02:00
|
|
|
|
|
|
|
# Test cgroup accounting is enabled
|
|
|
|
subtest "systemd cgroup accounting is enabled", sub {
|
|
|
|
$machine->waitForUnit('multi-user.target');
|
|
|
|
$machine->succeed('systemctl show testservice1.service -p IOAccounting | grep -q "yes"');
|
|
|
|
$machine->succeed('systemctl status testservice1.service | grep -q "CPU:"');
|
|
|
|
};
|
systemd: Update to latest NixOS branch
Updated to the latest version of the nixos-v237 branch, which fixes two
things:
* Make sure that systemd looks in /etc for configuration files.
https://github.com/NixOS/systemd/pull/15
* Fix handling of the x-initrd.mount option.
https://github.com/NixOS/systemd/pull/16
I've added NixOS VM tests for both to ensure we won't run into
regressions. The newly added systemd test only tests for that and is by
no means exhaustive, but it's a start.
Personally I only wanted to fix the former issue, because that's the one
I've been debugging. After sending in a pull request for our systemd
fork (https://github.com/NixOS/systemd/pull/17) I got a notice from
@Mic92, that he already fixed this and his fix was even better as it's
even suitable for upstream (so we hopefully can drop that patch
someday).
The reason why the second one came in was simply because it has been
merged before the former, but I thought it would be a good idea to have
tests for that as well.
In addition I've removed the sysconfdir=$out/etc entry to make sure the
default (/etc) is used. Installing is still done to $out, because those
directories that were previously into sysconfdir now get into
factoryconfdir.
Quote from commit NixOS/systemd@98067cc806ae0d2759cdd2334f230cd8548e531:
By default systemd should read all its configuration from /etc.
Therefore we rely on -Dsysconfdir=/etc in meson as default value.
Unfortunately this would also lead to installation of systemd's own
configuration files to `/etc` whereas we are limited to /nix/store. To
counter that this commit introduces two new configuration variables
`factoryconfdir` and `factorypkgconfdir` to install systemd's own
configuration into nix store again, while having executables looking
up files in /etc.
Tested this change against all of the NixOS VM tests we have in
nixos/release.nix. Between this change and its parent no new tests were
failing (although a lot of them were flaky).
Signed-off-by: aszlig <aszlig@nix.build>
Cc: @Mic92, @tk-ecotelecom, @edolstra, @fpletz
Fixes: #35415
Fixes: #35268
2018-03-03 07:10:22 +01:00
|
|
|
'';
|
2019-07-25 20:50:02 +02:00
|
|
|
})
|