{ config, lib, pkgs, ... }: with lib; let cfg = config.nixfiles.modules.psd; in { options.nixfiles.modules.psd.enable = mkEnableOption "Profile Sync Daemon"; config = mkIf cfg.enable { hm = { home.packages = with pkgs; [profile-sync-daemon]; xdg.configFile."psd/psd.conf".text = '' USE_OVERLAYFS="yes" ''; }; systemd.user = { services = { psd = { unitConfig = { Description = "Profile-sync-daemon"; Wants = ["psd-resync.service"]; RequiresMountsFor = "/home/"; After = ["local-fs.target"]; }; serviceConfig = { RemainAfterExit = true; ExecStart = "${pkgs.profile-sync-daemon}/bin/profile-sync-daemon startup"; ExecStop = "${pkgs.profile-sync-daemon}/bin/profile-sync-daemon unsync"; }; wantedBy = ["graphical.target"]; }; psd-resync = { unitConfig = { Description = "Profile-sync-daemon resync"; After = ["psd.service"]; Wants = ["psd-resync.timer"]; BindsTo = ["psd.service"]; }; serviceConfig.ExecStart = "${pkgs.profile-sync-daemon}/bin/profile-sync-daemon resync"; wantedBy = ["graphical.target"]; }; }; timers.psd-resync = { unitConfig = { Description = "Profile-sync-daemon resync timer"; BindsTo = ["psd.service"]; }; timerConfig.OnUnitActiveSec = "1h"; }; }; }; }