From 88530e02b6fa9b5429dc09972b599e7b0a3af569 Mon Sep 17 00:00:00 2001 From: aszlig Date: Sat, 3 Mar 2018 07:10:22 +0100 Subject: [PATCH] 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 Cc: @Mic92, @tk-ecotelecom, @edolstra, @fpletz Fixes: #35415 Fixes: #35268 --- nixos/release.nix | 1 + nixos/tests/systemd.nix | 66 ++++++++++++++++++++++ pkgs/os-specific/linux/systemd/default.nix | 5 +- 3 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 nixos/tests/systemd.nix diff --git a/nixos/release.nix b/nixos/release.nix index 473b11313befce..2d8b6c6b8263a6 100644 --- a/nixos/release.nix +++ b/nixos/release.nix @@ -355,6 +355,7 @@ in rec { tests.snapper = callTest tests/snapper.nix {}; tests.statsd = callTest tests/statsd.nix {}; tests.sudo = callTest tests/sudo.nix {}; + tests.systemd = callTest tests/systemd.nix {}; tests.switchTest = callTest tests/switch-test.nix {}; tests.taskserver = callTest tests/taskserver.nix {}; tests.tomcat = callTest tests/tomcat.nix {}; diff --git a/nixos/tests/systemd.nix b/nixos/tests/systemd.nix new file mode 100644 index 00000000000000..2df6f341c4efe8 --- /dev/null +++ b/nixos/tests/systemd.nix @@ -0,0 +1,66 @@ +import ./make-test.nix { + 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"; + + 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; + + # 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)'); + }; + + # 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"'); + }; + ''; +} diff --git a/pkgs/os-specific/linux/systemd/default.nix b/pkgs/os-specific/linux/systemd/default.nix index 858312c55d4dd4..fc72728cbabe24 100644 --- a/pkgs/os-specific/linux/systemd/default.nix +++ b/pkgs/os-specific/linux/systemd/default.nix @@ -23,8 +23,8 @@ in stdenv.mkDerivation rec { src = fetchFromGitHub { owner = "NixOS"; repo = "systemd"; - rev = "1e8830dfa77a7dc6976509f4a6edb7e012c50792"; - sha256 = "1cw1k0i68azmzpqzi3r8jm6mbi2wqlql78fhcg0vvnv1ly8bf7vq"; + rev = "98067cc806ae0d2759cdd2334f230cd8548e5317"; + sha256 = "077svfs2xy3g30s62q69wcv5pb9vfhzh8i7lhfri73vvhwbpzd5q"; }; outputs = [ "out" "lib" "man" "dev" ]; @@ -85,7 +85,6 @@ in stdenv.mkDerivation rec { mesonFlagsArray+=(-Ddbussessionservicedir=$out/share/dbus-1/services) mesonFlagsArray+=(-Ddbussystemservicedir=$out/share/dbus-1/system-services) mesonFlagsArray+=(-Dpamconfdir=$out/etc/pam.d) - mesonFlagsArray+=(-Dsysconfdir=$out/etc) mesonFlagsArray+=(-Drootprefix=$out) mesonFlagsArray+=(-Dlibdir=$lib/lib) mesonFlagsArray+=(-Drootlibdir=$lib/lib)