Nixpkgs: Cannot change system date

Created on 29 Mar 2019  路  7Comments  路  Source: NixOS/nixpkgs

Issue description

I wish to change the system date to prepare an webapp for daylight savings.
I don't think this is possible.

Steps to reproduce

#( 03/29/19@ 9:32 )( jappie@portable-jappie-nixos ):~
   sudo timedatectl set-time '2019-04-01'
[sudo] wachtwoord voor jappie: 
Failed to set time: Automatic time synchronization is enabled
#( 03/29/19@ 9:32 )( jappie@portable-jappie-nixos ):~
   sudo timedatectl set-ntp false
Failed to set ntp: Changing system settings via systemd is not supported on NixOS.

I expect to be able to disable ntp so that I can change the system date.

Technical details

Please run nix-shell -p nix-info --run "nix-info -m" and paste the
results.

  • system: "x86_64-linux"
  • host os: Linux 4.14.103, NixOS, 18.09.2253.753f58d9a42 (Jellyfish)
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.1.3
  • channels(root): "nixos-18.09.2266.aabc61049c0, nixos-18.09-18.09.2266.aabc61049c0"
  • channels(jappie): ""
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos

Most helpful comment

systemctl stop systemd-timesyncd.service
date --set="10:00:00"

seems to work for me.

All 7 comments

Not sure why this needs to be disabled, ping @gebner who authored this in https://github.com/NixOS/systemd/commit/f65b136cc06

You can read the history here: https://github.com/NixOS/systemd/pull/2

This wasn't really my idea. Before my PR, the timedatectl executable wasn't even compiled---precisely because some commands could change the system state. I just wanted to run timedatectl status. So I disabled the set-time etc. features because I didn't want to start a long discussion about whether these features should available or not.

I see, but I don't see any way to actually set the time then, there's no NixOS option for it, and I have no idea how one could be implemented..

systemctl stop systemd-timesyncd.service
date --set="10:00:00"

seems to work for me.

Heh, now I'm not sure what I expected, because it doesn't make sense to set the date from a NixOS config. I guess for a permanent solution you'll just have to disable that service.

Thanks @symphorien that'll work for my use case.

Github now says this discussion happened 3 days ago, so it works!

Was this page helpful?
0 / 5 - 0 ratings