blob: a1edbfa5566edba56b45b9b1e96f9795577d78bf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
{ config, lib, utils, pkgs, ... }:
{
options = {
environment.persistence = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule {
options = {
timezone = lib.mkEnableOption "storing system timezone";
};
});
};
};
config = {
systemd = lib.mkMerge (lib.mapAttrsToList (name: cfg: lib.mkIf cfg.timezone {
services = {
"timezone@${utils.escapeSystemdPath name}" = {
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "oneshot";
RemainAfterExit = true;
ExecStart = "${pkgs.coreutils}/bin/cp -vP ${utils.escapeSystemdExecArg "${name}/etc/localtime"} /etc/localtime";
ExecStop = "${pkgs.coreutils}/bin/cp -vP /etc/localtime ${utils.escapeSystemdExecArg "${name}/etc/localtime"}";
};
};
"etc-localtime@${utils.escapeSystemdPath name}" = {
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.coreutils}/bin/cp -vP /etc/localtime ${utils.escapeSystemdExecArg "${name}/etc/localtime"}";
};
};
};
paths."etc-localtime@${utils.escapeSystemdPath name}" = {
wantedBy = [ "timezone@${utils.escapeSystemdPath name}.service" ];
after = [ "timezone@${utils.escapeSystemdPath name}.service" ];
pathConfig.PathChanged = "/etc/localtime";
};
}) config.environment.persistence);
};
}
|