From 289d502c41dccd1d506bf04521c2f55c75649964 Mon Sep 17 00:00:00 2001 From: Ingolf Wagner Date: Tue, 26 Oct 2021 06:44:32 +0200 Subject: [PATCH] taskwarrior-pushover use dynamic user --- nixos/configs/pepe/taskwarrior-pushover.nix | 13 ++++++----- .../modules/services/taskwarrior-pushover.nix | 22 ++++++++++++++----- 2 files changed, 25 insertions(+), 10 deletions(-) diff --git a/nixos/configs/pepe/taskwarrior-pushover.nix b/nixos/configs/pepe/taskwarrior-pushover.nix index 6d3af65..dc82dd1 100644 --- a/nixos/configs/pepe/taskwarrior-pushover.nix +++ b/nixos/configs/pepe/taskwarrior-pushover.nix @@ -1,14 +1,17 @@ { config, lib, pkgs, ... }: { - sops.secrets.pushoverApiToken = {}; - sops.secrets.pushoverUserKey = {}; - sops.secrets.taskwarriorCa = {}; - sops.secrets.taskwarriorCertificate = {}; - sops.secrets.taskwarriorKey = {}; + users.users."taskwarrior-pushover".isSystemUser = true; + + sops.secrets.pushoverApiToken.owner = "taskwarrior-pushover"; + sops.secrets.pushoverUserKey.owner = "taskwarrior-pushover"; + sops.secrets.taskwarriorCa.owner = "taskwarrior-pushover"; + sops.secrets.taskwarriorCertificate.owner = "taskwarrior-pushover"; + sops.secrets.taskwarriorKey.owner = "taskwarrior-pushover"; services.taskwarrior-pushover = { enable = true; + onCalendar = "06:30:00"; server = "taskd.ingolf-wagner.de:53589"; pushoverApiTokenFile = config.sops.secrets.pushoverApiToken.path; pushoverUserKeyFile = config.sops.secrets.pushoverUserKey.path; diff --git a/nixos/modules/services/taskwarrior-pushover.nix b/nixos/modules/services/taskwarrior-pushover.nix index bc7df68..827cf5c 100644 --- a/nixos/modules/services/taskwarrior-pushover.nix +++ b/nixos/modules/services/taskwarrior-pushover.nix @@ -4,10 +4,15 @@ with lib; with types; let cfg = config.services.taskwarrior-pushover; + name = "taskwarrior-pushover"; in { options.services.taskwarrior-pushover = { enable = mkEnableOption "taskwarrior pushover notification service"; + onCalendar = mkOption { + type = str; + default = "4:00:00"; + }; pushoverApiTokenFile = mkOption { type = path; }; @@ -20,7 +25,7 @@ in }; dataDir = mkOption { type = str; - default = "/var/lib/taskwarrior-pushover"; + default = "tasks"; }; caFile = mkOption { type = path; @@ -42,14 +47,16 @@ in config = mkIf cfg.enable { systemd.services.taskwarrior-pushover = { enable = true; - #serviceConfig = { - # DynamicUser = true; - #}; + serviceConfig = { + DynamicUser = true; + StateDirectory = name; + }; script = let taskwarriorCommand = pkgs.writers.writeDash "taskwarrior-push" '' ${pkgs.taskwarrior}/bin/task \ rc.recurrence=off \ - rc.data.location=${cfg.dataDir} \ + rc:/var/lib/${name}/.taskrc \ + rc.data.location=/var/lib/${name}/${cfg.dataDir} \ rc.taskd.ca=${cfg.caFile} \ rc.taskd.certificate=${cfg.certificateFile} \ rc.taskd.credentials="${cfg.credentials}" \ @@ -83,6 +90,11 @@ in done ''; }; + systemd.timers.taskwarrior-pushover = { + enable = true; + timerConfig.OnCalendar = cfg.onCalendar; + wantedBy = [ "multi-user.target" ]; + }; }; }