add taskwarrior-pushover module
This commit is contained in:
parent
fe2b8e501e
commit
3acf05147a
5 changed files with 114 additions and 4 deletions
|
@ -38,11 +38,11 @@
|
|||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1633422542,
|
||||
"narHash": "sha256-JYz2PmVogNRO8DhcvXzL/QhZzboTspJz2YSRlnAj8aM=",
|
||||
"lastModified": 1635070614,
|
||||
"narHash": "sha256-eRup9WsvSIhsRrSlNugPcQ7gfGOsbk3d4izufwVlz1Q=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "aff647e2704fa1223994604887bb78276dc57083",
|
||||
"rev": "3b1789322fcbcb5cf51228d732752714f1bf77da",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
@ -62,7 +62,7 @@
|
|||
"secrets": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"narHash": "sha256-1myorrO1qwgIHPz2UkU45qZp+X4RdQgJpay93z1VNCM=",
|
||||
"narHash": "sha256-7kNQHKkMjjTBPgRzHh34KqbcorqgEyGcu8UQfFxEvb8=",
|
||||
"path": "/home/palo/dev/secrets",
|
||||
"type": "path"
|
||||
},
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
./borg.nix
|
||||
./mpd.nix
|
||||
./grocy.nix
|
||||
./taskwarrior-pushover.nix
|
||||
|
||||
];
|
||||
|
||||
|
|
20
nixos/configs/pepe/taskwarrior-pushover.nix
Normal file
20
nixos/configs/pepe/taskwarrior-pushover.nix
Normal file
|
@ -0,0 +1,20 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
{
|
||||
sops.secrets.pushoverApiToken = {};
|
||||
sops.secrets.pushoverUserKey = {};
|
||||
sops.secrets.taskwarriorCa = {};
|
||||
sops.secrets.taskwarriorCertificate = {};
|
||||
sops.secrets.taskwarriorKey = {};
|
||||
|
||||
services.taskwarrior-pushover = {
|
||||
enable = true;
|
||||
server = "taskd.ingolf-wagner.de:53589";
|
||||
pushoverApiTokenFile = config.sops.secrets.pushoverApiToken.path;
|
||||
pushoverUserKeyFile = config.sops.secrets.pushoverUserKey.path;
|
||||
caFile = config.sops.secrets.taskwarriorCa.path;
|
||||
certificateFile = config.sops.secrets.taskwarriorCertificate.path;
|
||||
keyFile = config.sops.secrets.taskwarriorKey.path;
|
||||
credentials= "1337/palo/ed0fdbe8-2dc3-408b-84cb-d07d363bccd2";
|
||||
};
|
||||
}
|
|
@ -10,6 +10,7 @@
|
|||
./services/samba-share.nix
|
||||
./services/sshd.nix
|
||||
./services/videoencoder.nix
|
||||
./services/taskwarrior-pushover.nix
|
||||
|
||||
./programs/browser.nix
|
||||
./programs/citate.nix
|
||||
|
|
88
nixos/modules/services/taskwarrior-pushover.nix
Normal file
88
nixos/modules/services/taskwarrior-pushover.nix
Normal file
|
@ -0,0 +1,88 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
with types;
|
||||
let
|
||||
cfg = config.services.taskwarrior-pushover;
|
||||
in
|
||||
{
|
||||
options.services.taskwarrior-pushover = {
|
||||
enable = mkEnableOption "taskwarrior pushover notification service";
|
||||
pushoverApiTokenFile = mkOption {
|
||||
type = path;
|
||||
};
|
||||
pushoverUserKeyFile = mkOption {
|
||||
type = path;
|
||||
};
|
||||
query = mkOption {
|
||||
type = str;
|
||||
default = "+PENDING and ( +ACTIVE and +DUETODAY or +TODAY or +OVERDUE )";
|
||||
};
|
||||
dataDir = mkOption {
|
||||
type = str;
|
||||
default = "/var/lib/taskwarrior-pushover";
|
||||
};
|
||||
caFile = mkOption {
|
||||
type = path;
|
||||
};
|
||||
certificateFile = mkOption {
|
||||
type = path;
|
||||
};
|
||||
credentials= mkOption {
|
||||
type = str;
|
||||
};
|
||||
keyFile = mkOption {
|
||||
type = path;
|
||||
};
|
||||
server = mkOption {
|
||||
type = str;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.taskwarrior-pushover = {
|
||||
enable = true;
|
||||
#serviceConfig = {
|
||||
# DynamicUser = true;
|
||||
#};
|
||||
script = let
|
||||
taskwarriorCommand = pkgs.writers.writeDash "taskwarrior-push" ''
|
||||
${pkgs.taskwarrior}/bin/task \
|
||||
rc.recurrence=off \
|
||||
rc.data.location=${cfg.dataDir} \
|
||||
rc.taskd.ca=${cfg.caFile} \
|
||||
rc.taskd.certificate=${cfg.certificateFile} \
|
||||
rc.taskd.credentials="${cfg.credentials}" \
|
||||
rc.taskd.key=${cfg.keyFile} \
|
||||
rc.taskd.server=${cfg.server} \
|
||||
"$@"
|
||||
'';
|
||||
in
|
||||
''
|
||||
if [ -d ${cfg.dataDir} ]
|
||||
then
|
||||
echo "syncronize ${cfg.dataDir}"
|
||||
${taskwarriorCommand} sync
|
||||
else
|
||||
echo "initialize ${cfg.dataDir}"
|
||||
${pkgs.coreutils}/bin/yes | ${taskwarriorCommand} sync init
|
||||
fi
|
||||
|
||||
${taskwarriorCommand} '${cfg.query}' export \
|
||||
| ${pkgs.jq}/bin/jq -r '.[] | @base64' | while read entry
|
||||
do
|
||||
echo $entry | base64 --decode | \
|
||||
${pkgs.jq}/bin/jq '{
|
||||
"token": "'`cat ${cfg.pushoverApiTokenFile}`'",
|
||||
"user": "'`cat ${cfg.pushoverUserKeyFile}`'",
|
||||
"titel": "taskwarrior",
|
||||
message: .description
|
||||
}' \
|
||||
| ${pkgs.curl}/bin/curl -sS -X POST -H 'Content-Type: application/json' -d @- \
|
||||
"https://api.pushover.net/1/messages.json"
|
||||
done
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
}
|
Loading…
Reference in a new issue