Merge pull request #195135 from maxbrunet/feat/automatic-timezoned/init
This commit is contained in:
commit
9959fe259d
8 changed files with 142 additions and 0 deletions
|
@ -8685,6 +8685,15 @@
|
|||
keys = [{
|
||||
fingerprint = "1DE4 424D BF77 1192 5DC4 CF5E 9AED 8814 81D8 444E";
|
||||
}];
|
||||
};
|
||||
maxbrunet = {
|
||||
email = "max@brnt.mx";
|
||||
github = "maxbrunet";
|
||||
githubId = 32458727;
|
||||
name = "Maxime Brunet";
|
||||
keys = [{
|
||||
fingerprint = "E9A2 EE26 EAC6 B3ED 6C10 61F3 4379 62FF 87EC FE2B";
|
||||
}];
|
||||
};
|
||||
maxdamantus = {
|
||||
email = "maxdamantus@gmail.com";
|
||||
|
|
|
@ -205,6 +205,14 @@
|
|||
<link xlink:href="options.html#opt-virtualisation.appvm.enable">virtualisation.appvm</link>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
<link xlink:href="https://github.com/maxbrunet/automatic-timezoned">automatic-timezoned</link>.
|
||||
a Linux daemon to automatically update the system timezone
|
||||
based on location. Available as
|
||||
<link linkend="opt-services.automatic-timezoned.enable">services.automatic-timezoned</link>.
|
||||
</para>
|
||||
</listitem>
|
||||
<listitem>
|
||||
<para>
|
||||
[xray] (https://github.com/XTLS/Xray-core), a fully compatible
|
||||
|
|
|
@ -78,6 +78,8 @@ In addition to numerous new and upgraded packages, this release has the followin
|
|||
|
||||
- [appvm](https://github.com/jollheef/appvm), Nix based app VMs. Available as [virtualisation.appvm](options.html#opt-virtualisation.appvm.enable).
|
||||
|
||||
- [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).
|
||||
|
||||
- [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).
|
||||
|
||||
- [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).
|
||||
|
|
|
@ -355,6 +355,7 @@ in
|
|||
pipewire = 323;
|
||||
rstudio-server = 324;
|
||||
localtimed = 325;
|
||||
automatic-timezoned = 326;
|
||||
|
||||
# When adding a uid, make sure it doesn't match an existing gid. And don't use uids above 399!
|
||||
|
||||
|
@ -664,6 +665,7 @@ in
|
|||
pipewire = 323;
|
||||
rstudio-server = 324;
|
||||
localtimed = 325;
|
||||
automatic-timezoned = 326;
|
||||
|
||||
# When adding a gid, make sure it doesn't match an existing
|
||||
# uid. Users and groups with the same name should have equal
|
||||
|
|
|
@ -1049,6 +1049,7 @@
|
|||
./services/security/vault.nix
|
||||
./services/security/vaultwarden/default.nix
|
||||
./services/security/yubikey-agent.nix
|
||||
./services/system/automatic-timezoned.nix
|
||||
./services/system/cachix-agent/default.nix
|
||||
./services/system/cachix-watch-store.nix
|
||||
./services/system/cloud-init.nix
|
||||
|
|
92
nixos/modules/services/system/automatic-timezoned.nix
Normal file
92
nixos/modules/services/system/automatic-timezoned.nix
Normal file
|
@ -0,0 +1,92 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.services.automatic-timezoned;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
services.automatic-timezoned = {
|
||||
enable = mkOption {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
description = mdDoc ''
|
||||
Enable `automatic-timezoned`, simple daemon for keeping the system
|
||||
timezone up-to-date based on the current location. It uses geoclue2 to
|
||||
determine the current location and systemd-timedated to actually set
|
||||
the timezone.
|
||||
'';
|
||||
};
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
default = pkgs.automatic-timezoned;
|
||||
defaultText = literalExpression "pkgs.automatic-timezoned";
|
||||
description = mdDoc ''
|
||||
Which `automatic-timezoned` package to use.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
security.polkit.extraConfig = ''
|
||||
polkit.addRule(function(action, subject) {
|
||||
if (action.id == "org.freedesktop.timedate1.set-timezone"
|
||||
&& subject.user == "automatic-timezoned") {
|
||||
return polkit.Result.YES;
|
||||
}
|
||||
});
|
||||
'';
|
||||
|
||||
services.geoclue2 = {
|
||||
enable = true;
|
||||
appConfig.automatic-timezoned = {
|
||||
isAllowed = true;
|
||||
isSystem = true;
|
||||
users = [ (toString config.ids.uids.automatic-timezoned) ];
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services = {
|
||||
|
||||
automatic-timezoned = {
|
||||
description = "Automatically update system timezone based on location";
|
||||
requires = [ "automatic-timezoned-geoclue-agent.service" ];
|
||||
after = [ "automatic-timezoned-geoclue-agent.service" ];
|
||||
serviceConfig = {
|
||||
Type = "exec";
|
||||
User = "automatic-timezoned";
|
||||
ExecStart = "${cfg.package}/bin/automatic-timezoned --zoneinfo-path=${pkgs.tzdata}/share/zoneinfo/zone1970.tab";
|
||||
};
|
||||
wantedBy = [ "default.target" ];
|
||||
};
|
||||
|
||||
automatic-timezoned-geoclue-agent = {
|
||||
description = "Geoclue agent for automatic-timezoned";
|
||||
requires = [ "geoclue.service" ];
|
||||
after = [ "geoclue.service" ];
|
||||
serviceConfig = {
|
||||
Type = "exec";
|
||||
User = "automatic-timezoned";
|
||||
ExecStart = "${pkgs.geoclue2-with-demo-agent}/libexec/geoclue-2.0/demos/agent";
|
||||
Restart = "on-failure";
|
||||
PrivateTmp = true;
|
||||
};
|
||||
wantedBy = [ "default.target" ];
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
users = {
|
||||
users.automatic-timezoned = {
|
||||
description = "automatic-timezoned";
|
||||
uid = config.ids.uids.automatic-timezoned;
|
||||
group = "automatic-timezoned";
|
||||
};
|
||||
groups.automatic-timezoned = {
|
||||
gid = config.ids.gids.automatic-timezoned;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
26
pkgs/tools/system/automatic-timezoned/default.nix
Normal file
26
pkgs/tools/system/automatic-timezoned/default.nix
Normal file
|
@ -0,0 +1,26 @@
|
|||
{ lib
|
||||
, fetchFromGitHub
|
||||
, rustPlatform
|
||||
}:
|
||||
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "automatic-timezoned";
|
||||
version = "1.0.41";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "maxbrunet";
|
||||
repo = pname;
|
||||
rev = "v${version}";
|
||||
sha256 = "sha256-KT1mVP2pMn6M8BPBdBgK94iLuAuoUwGo24L5IT5fVAQ=";
|
||||
};
|
||||
|
||||
cargoSha256 = "sha256-hfhSbpNVJm6OE/wL3aPNRV+kJGIZnpoTh8e/trRG21c=";
|
||||
|
||||
meta = with lib; {
|
||||
description = "Automatically update system timezone based on location";
|
||||
homepage = "https://github.com/maxbrunet/automatic-timezoned";
|
||||
license = licenses.gpl3;
|
||||
maintainers = with maintainers; [ maxbrunet ];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
|
@ -262,6 +262,8 @@ with pkgs;
|
|||
inherit (darwin.apple_sdk.frameworks) Security SystemConfiguration;
|
||||
};
|
||||
|
||||
automatic-timezoned = callPackage ../tools/system/automatic-timezoned { };
|
||||
|
||||
cve = with python3Packages; toPythonApplication cvelib;
|
||||
|
||||
fiche = callPackage ../servers/fiche { };
|
||||
|
|
Loading…
Reference in a new issue