Skip to content

Commit 88530e0

Browse files
committedMar 3, 2018
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. NixOS/systemd#15 * Fix handling of the x-initrd.mount option. NixOS/systemd#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 (NixOS/systemd#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@98067cc: 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
1 parent 1e53544 commit 88530e0

File tree

3 files changed

+69
-3
lines changed

3 files changed

+69
-3
lines changed
 

‎nixos/release.nix

+1
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ in rec {
355355
tests.snapper = callTest tests/snapper.nix {};
356356
tests.statsd = callTest tests/statsd.nix {};
357357
tests.sudo = callTest tests/sudo.nix {};
358+
tests.systemd = callTest tests/systemd.nix {};
358359
tests.switchTest = callTest tests/switch-test.nix {};
359360
tests.taskserver = callTest tests/taskserver.nix {};
360361
tests.tomcat = callTest tests/tomcat.nix {};

‎nixos/tests/systemd.nix

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
}

‎pkgs/os-specific/linux/systemd/default.nix

+2-3
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ in stdenv.mkDerivation rec {
2323
src = fetchFromGitHub {
2424
owner = "NixOS";
2525
repo = "systemd";
26-
rev = "1e8830dfa77a7dc6976509f4a6edb7e012c50792";
27-
sha256 = "1cw1k0i68azmzpqzi3r8jm6mbi2wqlql78fhcg0vvnv1ly8bf7vq";
26+
rev = "98067cc806ae0d2759cdd2334f230cd8548e5317";
27+
sha256 = "077svfs2xy3g30s62q69wcv5pb9vfhzh8i7lhfri73vvhwbpzd5q";
2828
};
2929

3030
outputs = [ "out" "lib" "man" "dev" ];
@@ -85,7 +85,6 @@ in stdenv.mkDerivation rec {
8585
mesonFlagsArray+=(-Ddbussessionservicedir=$out/share/dbus-1/services)
8686
mesonFlagsArray+=(-Ddbussystemservicedir=$out/share/dbus-1/system-services)
8787
mesonFlagsArray+=(-Dpamconfdir=$out/etc/pam.d)
88-
mesonFlagsArray+=(-Dsysconfdir=$out/etc)
8988
mesonFlagsArray+=(-Drootprefix=$out)
9089
mesonFlagsArray+=(-Dlibdir=$lib/lib)
9190
mesonFlagsArray+=(-Drootlibdir=$lib/lib)

0 commit comments

Comments
 (0)
Please sign in to comment.