From 1b5e860f65607b4cc7de4b6b5db95460cf144526 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 6 Jan 2014 18:23:41 +0100 Subject: [PATCH] Make /etc/localtime a direct symlink to the zoneinfo file Some programs (notably the Java Runtime Environment) expect to be able to extract the name of the time zone from the target of the /etc/localtime symlink. That doesn't work if /etc/localtime is a symlink to /etc/static/localtime. So make it a direct symlink. --- nixos/modules/config/timezone.nix | 5 ++++- nixos/modules/system/etc/setup-etc.pl | 10 +++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/nixos/modules/config/timezone.nix b/nixos/modules/config/timezone.nix index 07a76d9ad1fa..979778046fda 100644 --- a/nixos/modules/config/timezone.nix +++ b/nixos/modules/config/timezone.nix @@ -27,7 +27,10 @@ with pkgs.lib; environment.variables.TZDIR = "/etc/zoneinfo"; environment.variables.TZ = config.time.timeZone; - environment.etc.localtime.source = "${pkgs.tzdata}/share/zoneinfo/${config.time.timeZone}"; + environment.etc.localtime = + { source = "${pkgs.tzdata}/share/zoneinfo/${config.time.timeZone}"; + mode = "direct-symlink"; + }; environment.etc.zoneinfo.source = "${pkgs.tzdata}/share/zoneinfo"; diff --git a/nixos/modules/system/etc/setup-etc.pl b/nixos/modules/system/etc/setup-etc.pl index 7cb6d2a6a45e..4b79dbaab89e 100644 --- a/nixos/modules/system/etc/setup-etc.pl +++ b/nixos/modules/system/etc/setup-etc.pl @@ -57,9 +57,13 @@ sub link { open MODE, "<$_.mode"; my $mode = ; chomp $mode; close MODE; - copy "$static/$fn", "$target.tmp" or warn; - chmod oct($mode), "$target.tmp" or warn; - rename "$target.tmp", $target or warn; + if ($mode eq "direct-symlink") { + atomicSymlink readlink("$static/$fn"), $target or warn; + } else { + copy "$static/$fn", "$target.tmp" or warn; + chmod oct($mode), "$target.tmp" or warn; + rename "$target.tmp", $target or warn; + } } elsif (-l "$_") { atomicSymlink "$static/$fn", $target or warn; }