Merge pull request #195135 from maxbrunet/feat/automatic-timezoned/init

authored by Bernardo Meurer and committed by GitHub 9959fe25 e3bd5d17

+142
+9
maintainers/maintainer-list.nix
··· 8686 8686 fingerprint = "1DE4 424D BF77 1192 5DC4 CF5E 9AED 8814 81D8 444E"; 8687 8687 }]; 8688 8688 }; 8689 + maxbrunet = { 8690 + email = "max@brnt.mx"; 8691 + github = "maxbrunet"; 8692 + githubId = 32458727; 8693 + name = "Maxime Brunet"; 8694 + keys = [{ 8695 + fingerprint = "E9A2 EE26 EAC6 B3ED 6C10 61F3 4379 62FF 87EC FE2B"; 8696 + }]; 8697 + }; 8689 8698 maxdamantus = { 8690 8699 email = "maxdamantus@gmail.com"; 8691 8700 github = "Maxdamantus";
+8
nixos/doc/manual/from_md/release-notes/rl-2211.section.xml
··· 207 207 </listitem> 208 208 <listitem> 209 209 <para> 210 + <link xlink:href="https://github.com/maxbrunet/automatic-timezoned">automatic-timezoned</link>. 211 + a Linux daemon to automatically update the system timezone 212 + based on location. Available as 213 + <link linkend="opt-services.automatic-timezoned.enable">services.automatic-timezoned</link>. 214 + </para> 215 + </listitem> 216 + <listitem> 217 + <para> 210 218 [xray] (https://github.com/XTLS/Xray-core), a fully compatible 211 219 v2ray-core replacement. Features XTLS, which when enabled on 212 220 server and client, brings UDP FullCone NAT to proxy setups.
+2
nixos/doc/manual/release-notes/rl-2211.section.md
··· 78 78 79 79 - [appvm](https://github.com/jollheef/appvm), Nix based app VMs. Available as [virtualisation.appvm](options.html#opt-virtualisation.appvm.enable). 80 80 81 + - [automatic-timezoned](https://github.com/maxbrunet/automatic-timezoned). a Linux daemon to automatically update the system timezone based on location. Available as [services.automatic-timezoned](#opt-services.automatic-timezoned.enable). 82 + 81 83 - [xray] (https://github.com/XTLS/Xray-core), a fully compatible v2ray-core replacement. Features XTLS, which when enabled on server and client, brings UDP FullCone NAT to proxy setups. Available as [services.xray](options.html#opt-services.xray.enable). 82 84 83 85 - [syncstorage-rs](https://github.com/mozilla-services/syncstorage-rs), a self-hostable sync server for Firefox. Available as [services.firefox-syncserver](options.html#opt-services.firefox-syncserver.enable).
+2
nixos/modules/misc/ids.nix
··· 355 355 pipewire = 323; 356 356 rstudio-server = 324; 357 357 localtimed = 325; 358 + automatic-timezoned = 326; 358 359 359 360 # When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399! 360 361 ··· 664 665 pipewire = 323; 665 666 rstudio-server = 324; 666 667 localtimed = 325; 668 + automatic-timezoned = 326; 667 669 668 670 # When adding a gid, make sure it doesn't match an existing 669 671 # uid. Users and groups with the same name should have equal
+1
nixos/modules/module-list.nix
··· 1049 1049 ./services/security/vault.nix 1050 1050 ./services/security/vaultwarden/default.nix 1051 1051 ./services/security/yubikey-agent.nix 1052 + ./services/system/automatic-timezoned.nix 1052 1053 ./services/system/cachix-agent/default.nix 1053 1054 ./services/system/cachix-watch-store.nix 1054 1055 ./services/system/cloud-init.nix
+92
nixos/modules/services/system/automatic-timezoned.nix
··· 1 + { config, lib, pkgs, ... }: 2 + 3 + with lib; 4 + 5 + let 6 + cfg = config.services.automatic-timezoned; 7 + in 8 + { 9 + options = { 10 + services.automatic-timezoned = { 11 + enable = mkOption { 12 + type = types.bool; 13 + default = false; 14 + description = mdDoc '' 15 + Enable `automatic-timezoned`, simple daemon for keeping the system 16 + timezone up-to-date based on the current location. It uses geoclue2 to 17 + determine the current location and systemd-timedated to actually set 18 + the timezone. 19 + ''; 20 + }; 21 + package = mkOption { 22 + type = types.package; 23 + default = pkgs.automatic-timezoned; 24 + defaultText = literalExpression "pkgs.automatic-timezoned"; 25 + description = mdDoc '' 26 + Which `automatic-timezoned` package to use. 27 + ''; 28 + }; 29 + }; 30 + }; 31 + 32 + config = mkIf cfg.enable { 33 + security.polkit.extraConfig = '' 34 + polkit.addRule(function(action, subject) { 35 + if (action.id == "org.freedesktop.timedate1.set-timezone" 36 + && subject.user == "automatic-timezoned") { 37 + return polkit.Result.YES; 38 + } 39 + }); 40 + ''; 41 + 42 + services.geoclue2 = { 43 + enable = true; 44 + appConfig.automatic-timezoned = { 45 + isAllowed = true; 46 + isSystem = true; 47 + users = [ (toString config.ids.uids.automatic-timezoned) ]; 48 + }; 49 + }; 50 + 51 + systemd.services = { 52 + 53 + automatic-timezoned = { 54 + description = "Automatically update system timezone based on location"; 55 + requires = [ "automatic-timezoned-geoclue-agent.service" ]; 56 + after = [ "automatic-timezoned-geoclue-agent.service" ]; 57 + serviceConfig = { 58 + Type = "exec"; 59 + User = "automatic-timezoned"; 60 + ExecStart = "${cfg.package}/bin/automatic-timezoned --zoneinfo-path=${pkgs.tzdata}/share/zoneinfo/zone1970.tab"; 61 + }; 62 + wantedBy = [ "default.target" ]; 63 + }; 64 + 65 + automatic-timezoned-geoclue-agent = { 66 + description = "Geoclue agent for automatic-timezoned"; 67 + requires = [ "geoclue.service" ]; 68 + after = [ "geoclue.service" ]; 69 + serviceConfig = { 70 + Type = "exec"; 71 + User = "automatic-timezoned"; 72 + ExecStart = "${pkgs.geoclue2-with-demo-agent}/libexec/geoclue-2.0/demos/agent"; 73 + Restart = "on-failure"; 74 + PrivateTmp = true; 75 + }; 76 + wantedBy = [ "default.target" ]; 77 + }; 78 + 79 + }; 80 + 81 + users = { 82 + users.automatic-timezoned = { 83 + description = "automatic-timezoned"; 84 + uid = config.ids.uids.automatic-timezoned; 85 + group = "automatic-timezoned"; 86 + }; 87 + groups.automatic-timezoned = { 88 + gid = config.ids.gids.automatic-timezoned; 89 + }; 90 + }; 91 + }; 92 + }
+26
pkgs/tools/system/automatic-timezoned/default.nix
··· 1 + { lib 2 + , fetchFromGitHub 3 + , rustPlatform 4 + }: 5 + 6 + rustPlatform.buildRustPackage rec { 7 + pname = "automatic-timezoned"; 8 + version = "1.0.41"; 9 + 10 + src = fetchFromGitHub { 11 + owner = "maxbrunet"; 12 + repo = pname; 13 + rev = "v${version}"; 14 + sha256 = "sha256-KT1mVP2pMn6M8BPBdBgK94iLuAuoUwGo24L5IT5fVAQ="; 15 + }; 16 + 17 + cargoSha256 = "sha256-hfhSbpNVJm6OE/wL3aPNRV+kJGIZnpoTh8e/trRG21c="; 18 + 19 + meta = with lib; { 20 + description = "Automatically update system timezone based on location"; 21 + homepage = "https://github.com/maxbrunet/automatic-timezoned"; 22 + license = licenses.gpl3; 23 + maintainers = with maintainers; [ maxbrunet ]; 24 + platforms = platforms.linux; 25 + }; 26 + }
+2
pkgs/top-level/all-packages.nix
··· 262 262 inherit (darwin.apple_sdk.frameworks) Security SystemConfiguration; 263 263 }; 264 264 265 + automatic-timezoned = callPackage ../tools/system/automatic-timezoned { }; 266 + 265 267 cve = with python3Packages; toPythonApplication cvelib; 266 268 267 269 fiche = callPackage ../servers/fiche { };