taskwarrior-pushover use dynamic user

This commit is contained in:
Ingolf Wagner 2021-10-26 06:44:32 +02:00
parent 3acf05147a
commit 289d502c41
No known key found for this signature in database
GPG key ID: 76BF5F1928B9618B
2 changed files with 25 additions and 10 deletions

View file

@ -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;

View file

@ -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" ];
};
};
}