2014-12-11 21:12:29 +00:00
|
|
|
{ config, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.psd;
|
|
|
|
in {
|
|
|
|
options.services.psd = with types; {
|
|
|
|
enable = mkOption {
|
|
|
|
type = bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Whether to enable the Profile Sync daemon.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
resyncTimer = mkOption {
|
|
|
|
type = str;
|
|
|
|
default = "1h";
|
|
|
|
example = "1h 30min";
|
|
|
|
description = ''
|
|
|
|
The amount of time to wait before syncing browser profiles back to the
|
|
|
|
disk.
|
|
|
|
|
|
|
|
Takes a systemd.unit time span. The time unit defaults to seconds if
|
|
|
|
omitted.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
systemd = {
|
2018-09-05 18:18:11 +01:00
|
|
|
user = {
|
|
|
|
services = {
|
|
|
|
psd = {
|
|
|
|
enable = true;
|
|
|
|
description = "Profile Sync daemon";
|
2019-09-01 02:07:23 +01:00
|
|
|
wants = [ "psd-resync.service" ];
|
2018-09-05 18:18:11 +01:00
|
|
|
wantedBy = [ "default.target" ];
|
2018-10-07 16:32:08 +01:00
|
|
|
path = with pkgs; [ rsync kmod gawk nettools utillinux profile-sync-daemon ];
|
2018-09-05 18:18:11 +01:00
|
|
|
unitConfig = {
|
|
|
|
RequiresMountsFor = [ "/home/" ];
|
|
|
|
};
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = "yes";
|
|
|
|
ExecStart = "${pkgs.profile-sync-daemon}/bin/profile-sync-daemon sync";
|
|
|
|
ExecStop = "${pkgs.profile-sync-daemon}/bin/profile-sync-daemon unsync";
|
|
|
|
};
|
2014-12-11 21:12:29 +00:00
|
|
|
};
|
|
|
|
|
2018-09-05 18:18:11 +01:00
|
|
|
psd-resync = {
|
|
|
|
enable = true;
|
|
|
|
description = "Timed profile resync";
|
|
|
|
after = [ "psd.service" ];
|
|
|
|
wants = [ "psd-resync.timer" ];
|
|
|
|
partOf = [ "psd.service" ];
|
|
|
|
wantedBy = [ "default.target" ];
|
2018-10-07 16:32:08 +01:00
|
|
|
path = with pkgs; [ rsync kmod gawk nettools utillinux profile-sync-daemon ];
|
2018-09-05 18:18:11 +01:00
|
|
|
serviceConfig = {
|
|
|
|
Type = "oneshot";
|
|
|
|
ExecStart = "${pkgs.profile-sync-daemon}/bin/profile-sync-daemon resync";
|
|
|
|
};
|
2014-12-11 21:12:29 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-09-05 18:18:11 +01:00
|
|
|
timers.psd-resync = {
|
|
|
|
description = "Timer for profile sync daemon - ${cfg.resyncTimer}";
|
|
|
|
partOf = [ "psd-resync.service" "psd.service" ];
|
2014-12-11 21:12:29 +00:00
|
|
|
|
2018-09-05 18:18:11 +01:00
|
|
|
timerConfig = {
|
|
|
|
OnUnitActiveSec = "${cfg.resyncTimer}";
|
2014-12-11 21:12:29 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|