Skip to content

Commit

Permalink
nixos/systemd: set TZDIR for PID 1
Browse files Browse the repository at this point in the history
Fixes #105049

(cherry picked from commit 901d4f1)
  • Loading branch information
ncfavier authored and github-actions[bot] committed Dec 22, 2021
1 parent 669de38 commit 3ea5c9e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions nixos/modules/system/boot/stage-2-init.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -172,4 +172,5 @@ echo "starting systemd..."
PATH=/run/current-system/systemd/lib/systemd:@fsPackagesPath@ \
LOCALE_ARCHIVE=/run/current-system/sw/lib/locale/locale-archive @systemdUnitPathEnvVar@ \
TZDIR=/etc/zoneinfo \
exec @systemdExecutable@
12 changes: 12 additions & 0 deletions nixos/tests/systemd.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ import ./make-test-python.nix ({ pkgs, ... }: {
umount /tmp/shared
'';

systemd.services.oncalendar-test = {
description = "calendar test";
# Japan does not have DST which makes the test a little bit simpler
startAt = "Wed 10:00 Asia/Tokyo";
script = "true";
};

systemd.services.testservice1 = {
description = "Test Service 1";
wantedBy = [ "multi-user.target" ];
Expand Down Expand Up @@ -69,6 +76,11 @@ import ./make-test-python.nix ({ pkgs, ... }: {
# wait for user services
machine.wait_for_unit("default.target", "alice")
# Regression test for https://github.com/NixOS/nixpkgs/issues/105049
with subtest("systemd reads timezone database in /etc/zoneinfo"):
timer = machine.succeed("TZ=UTC systemctl show --property=TimersCalendar oncalendar-test.timer")
assert re.search("next_elapse=Wed ....-..-.. 01:00:00 UTC", timer), f"got {timer.strip()}"
# Regression test for https://github.com/NixOS/nixpkgs/issues/35415
with subtest("configuration files are recognized by systemd"):
machine.succeed("test -e /system_conf_read")
Expand Down

0 comments on commit 3ea5c9e

Please sign in to comment.