-
-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nixos.timezone: set TZ to :/etc/localtime #23078
Conversation
Please wait just a few minutes as I'm about to push a better version of this PR. |
This prevents glibc from calling stat() every time localtime() is called. This could be a significant performance problem if /etc is on an NFS filesystem. For systemd services, we point TZ to the actual time zone file instead of the /etc/localtime symlink so that systemd services are restarted if the time zone is changed. Fixes NixOS#23053
9cbe2c4
to
27bfcf4
Compare
Ok, with this updated version, systemd services are now restarted if the time zone changes. I don't know if it still makes sense to keep the |
Ah, I believe So I think we should keep the |
Anything blocking this from either an in-extremis merge for 18.09 or an early merge for 19.03? I'm don't have the required knowledge about glibc to confirm the speed assertions, neither the setup to test, but reading the appropriate manual section confirms this approach seems implemented right
|
Looks good to me. |
It breaks the
This comes from the previous change where timeZone now default to I have added a WIP commit I'd like reviewed; the tests pass, and it seems semantically correct, but I'm not entirely confident (but pretty sure) it implements the change while not breaking the current assumptions. |
@samueldr: Looks good to me! |
27bfcf4
to
7e32133
Compare
Pushed on @wizeman's repo after the approval; fixing the merge conflict, now ready to merge. |
7e32133
to
aa021db
Compare
Are there any updates on this pull request, please? |
Thank you for your contributions.
|
I think I must have force-pushed my git branch by mistake and undid @samueldr's merge conflict fixes... Note that while I was using these changes, I was running into a bug where Go programs couldn't parse the Perhaps golang/go#27570 would fix that (but I'm not sure). |
I'm don't think we can do this, at least until this isn't supported in major language runtimes (like Go). |
The commit golang/go@58fe2cd was landed, so Go 1.16+ will be ready for this change. |
Cool! Did someone check if python supports this, too? Edit: It seems at least |
@flokli It appearently works with Python 3.7 on NixOS 20.03: [nix-shell:~]$ ls -l /etc/localtime
lrwxrwxrwx 1 root root 24 Oct 12 06:33 /etc/localtime -> /etc/zoneinfo/Asia/Tokyo
[nix-shell:~]$ TZ=UTC python
Python 3.7.6 (default, Dec 18 2019, 19:23:55)
[GCC 9.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> import time
>>> os.environ['TZ']
'UTC'
>>> time.tzset()
>>> time.tzname
('UTC', 'UTC')
>>> time.strftime('%X %x %Z')
'12:08:22 10/12/20 UTC'
>>> os.environ['TZ'] = ':/etc/localtime'
>>> time.tzset()
>>> time.tzname
('JST', 'JST')
>>> time.strftime('%X %x %Z')
'21:08:45 10/12/20 JST'
>>> (JST: Japan Standard Time; same as Asia/Tokyo and its offset from UTC is +09:00) |
@wizeman Can you rebase this? |
@wizeman Are you still interested in pushing this through the last mile? :) |
Here is a good news: Go 1.16 is released 🎉 |
@Ekleog I'm interested but I don't have enough time at the moment. @omasanori Please, feel free to take over. Thanks! |
@wizeman I see, Thank you for prompt response! |
newer version in #113555 |
Motivation for this change
This prevents glibc from calling stat() every time localtime() is called.
This could be a significant performance problem if
/etc
is on an NFS filesystem.For systemd services, we point TZ to the actual time zone file instead of the /etc/localtime symlink so that systemd services are restarted if the time zone is changed.
Fixes #23053
Things done
(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)