From e1788dbd24e0ba9133ef888d009637661070c6ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Geoffrey=20=E2=80=9CFrogeye=E2=80=9D=20Preud=27homme?= Date: Sat, 28 Oct 2023 19:33:40 +0200 Subject: [PATCH] nix: chrony --- .../automatrop/roles/system/files/chrony.conf | 7 ---- .../roles/system/files/dhcpcd.exit-hook | 5 --- config/automatrop/roles/system/tasks/main.yml | 37 ------------------- config/nix/modules/common.nix | 11 +++++- config/nix/modules/wireless.nix | 1 + 5 files changed, 10 insertions(+), 51 deletions(-) delete mode 100644 config/automatrop/roles/system/files/chrony.conf delete mode 100644 config/automatrop/roles/system/files/dhcpcd.exit-hook diff --git a/config/automatrop/roles/system/files/chrony.conf b/config/automatrop/roles/system/files/chrony.conf deleted file mode 100644 index ed8df86..0000000 --- a/config/automatrop/roles/system/files/chrony.conf +++ /dev/null @@ -1,7 +0,0 @@ -server 0.europe.pool.ntp.org offline -server 1.europe.pool.ntp.org offline -server 2.europe.pool.ntp.org offline -server 3.europe.pool.ntp.org offline -driftfile /etc/chrony.drift -rtconutc -rtcsync diff --git a/config/automatrop/roles/system/files/dhcpcd.exit-hook b/config/automatrop/roles/system/files/dhcpcd.exit-hook deleted file mode 100644 index 7f08fd8..0000000 --- a/config/automatrop/roles/system/files/dhcpcd.exit-hook +++ /dev/null @@ -1,5 +0,0 @@ -if $if_up; then - chronyc online -elif $if_down; then - chronyc offline -fi diff --git a/config/automatrop/roles/system/tasks/main.yml b/config/automatrop/roles/system/tasks/main.yml index 7f9ce9f..03cdc0d 100644 --- a/config/automatrop/roles/system/tasks/main.yml +++ b/config/automatrop/roles/system/tasks/main.yml @@ -79,43 +79,6 @@ ### STOPPED HERE ### -# Time synchronisation - -- name: Mask systemd-timesyncd - systemd: - name: systemd-timesyncd - state: stopped - enabled: no - masked: yes - become: yes - notify: etc changed - -- name: Configure chrony - copy: - src: chrony.conf - dest: /etc/chrony.conf - become: yes - notify: - - etc changed - - chrony reconfigured -# TODO More configuration, RTC configuration - -- name: Enable chronyd - systemd: - name: chronyd - enabled: yes - become: yes - notify: - - etc changed - - chrony reconfigured - -- name: Configure dhcpcd chrony hook - copy: - src: dhcpcd.exit-hook - dest: /etc/dhcpcd.exit-hook - become: yes - notify: etc changed - - name: Empty motd copy: content: "" diff --git a/config/nix/modules/common.nix b/config/nix/modules/common.nix index 95fb406..17763ac 100644 --- a/config/nix/modules/common.nix +++ b/config/nix/modules/common.nix @@ -1,4 +1,4 @@ -{ pkgs, ... }: +{ pkgs, lib, ... }: { boot.loader.grub.enable = true; boot.loader.efi.canTouchEfiVariables = true; @@ -142,7 +142,14 @@ # Enable the OpenSSH daemon openssh.enable = true; getty.autologinUser = "geoffrey"; # DEBUG - chrony.enable = true; + + # Time sychronisation + chrony = { + enable = true; + servers = map (n: "${toString n}.europe.pool.ntp.org") (lib.lists.range 0 3); + extraConfig = "rtcsync"; + }; + }; # TEST diff --git a/config/nix/modules/wireless.nix b/config/nix/modules/wireless.nix index e68ba94..c583dcf 100644 --- a/config/nix/modules/wireless.nix +++ b/config/nix/modules/wireless.nix @@ -11,4 +11,5 @@ interfaces = ["eth0"]; }; environment.systemPackages = with pkgs; [ wirelesstools ]; + services.chrony.serverOption = "offline"; }