diff options
Diffstat (limited to 'modules/impermanence-timezone.nix')
| -rw-r--r-- | modules/impermanence-timezone.nix | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/modules/impermanence-timezone.nix b/modules/impermanence-timezone.nix new file mode 100644 index 00000000..a1edbfa5 --- /dev/null +++ b/modules/impermanence-timezone.nix | |||
| @@ -0,0 +1,41 @@ | |||
| 1 | { config, lib, utils, pkgs, ... }: | ||
| 2 | |||
| 3 | { | ||
| 4 | options = { | ||
| 5 | environment.persistence = lib.mkOption { | ||
| 6 | type = lib.types.attrsOf (lib.types.submodule { | ||
| 7 | options = { | ||
| 8 | timezone = lib.mkEnableOption "storing system timezone"; | ||
| 9 | }; | ||
| 10 | }); | ||
| 11 | }; | ||
| 12 | }; | ||
| 13 | |||
| 14 | config = { | ||
| 15 | systemd = lib.mkMerge (lib.mapAttrsToList (name: cfg: lib.mkIf cfg.timezone { | ||
| 16 | services = { | ||
| 17 | "timezone@${utils.escapeSystemdPath name}" = { | ||
| 18 | wantedBy = [ "multi-user.target" ]; | ||
| 19 | serviceConfig = { | ||
| 20 | Type = "oneshot"; | ||
| 21 | RemainAfterExit = true; | ||
| 22 | ExecStart = "${pkgs.coreutils}/bin/cp -vP ${utils.escapeSystemdExecArg "${name}/etc/localtime"} /etc/localtime"; | ||
| 23 | ExecStop = "${pkgs.coreutils}/bin/cp -vP /etc/localtime ${utils.escapeSystemdExecArg "${name}/etc/localtime"}"; | ||
| 24 | }; | ||
| 25 | }; | ||
| 26 | "etc-localtime@${utils.escapeSystemdPath name}" = { | ||
| 27 | serviceConfig = { | ||
| 28 | Type = "oneshot"; | ||
| 29 | ExecStart = "${pkgs.coreutils}/bin/cp -vP /etc/localtime ${utils.escapeSystemdExecArg "${name}/etc/localtime"}"; | ||
| 30 | }; | ||
| 31 | }; | ||
| 32 | }; | ||
| 33 | paths."etc-localtime@${utils.escapeSystemdPath name}" = { | ||
| 34 | wantedBy = [ "timezone@${utils.escapeSystemdPath name}.service" ]; | ||
| 35 | after = [ "timezone@${utils.escapeSystemdPath name}.service" ]; | ||
| 36 | |||
| 37 | pathConfig.PathChanged = "/etc/localtime"; | ||
| 38 | }; | ||
| 39 | }) config.environment.persistence); | ||
| 40 | }; | ||
| 41 | } | ||
