diff --git a/os/wireless/default.nix b/os/wireless/default.nix index 0bf1949..b3a7f75 100644 --- a/os/wireless/default.nix +++ b/os/wireless/default.nix @@ -53,24 +53,38 @@ in }) ]; # wireless support via wpa_supplicant - networking.wireless = { - enable = true; - extraConfig = '' - country=NL + networking = { + # Tell the time synchronisation service when we got/lost the connection + dhcpcd.runHook = '' + if $if_up; then + ${config.services.chrony.package}/bin/chronyc online + elif $if_down; then + ${config.services.chrony.package}/bin/chronyc offline + fi ''; - # Public wireless networks - networks = lib.genAttrs [ - "EurostarTrainsWiFi" - "_SNCF gare-gratuit" - "_SNCF_WIFI_INOUI" - "Wifi in de trein" - "WiFi in de trein" - "_WIFI_LYRIA" - "WIFIonICE" - ] (ssid: { }); - userControlled.enable = true; # Allow some control with wpa_cli + + wireless = { + enable = true; + extraConfig = '' + country=NL + ''; + # Public wireless networks + networks = lib.genAttrs [ + "EurostarTrainsWiFi" + "_SNCF gare-gratuit" + "_SNCF_WIFI_INOUI" + "Wifi in de trein" + "WiFi in de trein" + "_WIFI_LYRIA" + "WIFIonICE" + ] (ssid: { }); + userControlled.enable = true; # Allow some control with wpa_cli + }; }; + + # Wait until there's a connection to fetch time services.chrony.serverOption = "offline"; + systemd.services.wifi_apply = { after = [ "wpa_supplicant.service" ]; wantedBy = [ "wpa_supplicant.service" ];