add taskwarrior-autotag to support ios
This commit is contained in:
parent
b68cba4fe3
commit
907171a441
3 changed files with 156 additions and 8 deletions
|
@ -1,12 +1,28 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
{
|
{
|
||||||
|
sops.secrets.pushoverApiToken = {
|
||||||
|
owner = "taskwarrior-pushover";
|
||||||
|
key = "pushoverApiToken";
|
||||||
|
};
|
||||||
|
sops.secrets.pushoverUserKey = {
|
||||||
|
owner = "taskwarrior-pushover";
|
||||||
|
key = "pushoverUserKey";
|
||||||
|
};
|
||||||
|
|
||||||
|
sops.secrets.pushoverTaskwarriorCa = {
|
||||||
|
owner = "taskwarrior-pushover";
|
||||||
|
key = "taskwarriorCa";
|
||||||
|
};
|
||||||
|
sops.secrets.pushoverTaskwarriorCertificate = {
|
||||||
|
owner = "taskwarrior-pushover";
|
||||||
|
key = "taskwarriorCertificate";
|
||||||
|
};
|
||||||
|
sops.secrets.pushoverTaskwarriorKey = {
|
||||||
|
owner = "taskwarrior-pushover";
|
||||||
|
key = "taskwarriorKey";
|
||||||
|
};
|
||||||
|
|
||||||
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 = {
|
services.taskwarrior-pushover = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
@ -15,9 +31,34 @@
|
||||||
server = "taskd.ingolf-wagner.de:53589";
|
server = "taskd.ingolf-wagner.de:53589";
|
||||||
pushoverApiTokenFile = config.sops.secrets.pushoverApiToken.path;
|
pushoverApiTokenFile = config.sops.secrets.pushoverApiToken.path;
|
||||||
pushoverUserKeyFile = config.sops.secrets.pushoverUserKey.path;
|
pushoverUserKeyFile = config.sops.secrets.pushoverUserKey.path;
|
||||||
caFile = config.sops.secrets.taskwarriorCa.path;
|
caFile = config.sops.secrets.pushoverTaskwarriorCa.path;
|
||||||
certificateFile = config.sops.secrets.taskwarriorCertificate.path;
|
certificateFile = config.sops.secrets.pushoverTaskwarriorCertificate.path;
|
||||||
keyFile = config.sops.secrets.taskwarriorKey.path;
|
keyFile = config.sops.secrets.pushoverTaskwarriorKey.path;
|
||||||
credentials = "1337/palo/ed0fdbe8-2dc3-408b-84cb-d07d363bccd2";
|
credentials = "1337/palo/ed0fdbe8-2dc3-408b-84cb-d07d363bccd2";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sops.secrets.autotagTaskwarriorCa = {
|
||||||
|
owner = "taskwarrior-autotag";
|
||||||
|
key = "taskwarriorCa";
|
||||||
|
};
|
||||||
|
sops.secrets.autotagTaskwarriorCertificate = {
|
||||||
|
owner = "taskwarrior-autotag";
|
||||||
|
key = "taskwarriorCertificate";
|
||||||
|
};
|
||||||
|
sops.secrets.autotagTaskwarriorKey = {
|
||||||
|
owner = "taskwarrior-autotag";
|
||||||
|
key = "taskwarriorKey";
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
services.taskwarrior-autotag = {
|
||||||
|
enable = true;
|
||||||
|
onCalendar = "hourly";
|
||||||
|
server = "taskd.ingolf-wagner.de:53589";
|
||||||
|
caFile = config.sops.secrets.autotagTaskwarriorCa.path;
|
||||||
|
certificateFile = config.sops.secrets.autotagTaskwarriorCertificate.path;
|
||||||
|
keyFile = config.sops.secrets.autotagTaskwarriorKey.path;
|
||||||
|
credentials = "1337/palo/ed0fdbe8-2dc3-408b-84cb-d07d363bccd2";
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
./services/sshd.nix
|
./services/sshd.nix
|
||||||
./services/videoencoder.nix
|
./services/videoencoder.nix
|
||||||
./services/taskwarrior-pushover.nix
|
./services/taskwarrior-pushover.nix
|
||||||
|
./services/taskwarrior-autotag.nix
|
||||||
|
|
||||||
./programs/browser.nix
|
./programs/browser.nix
|
||||||
./programs/citate.nix
|
./programs/citate.nix
|
||||||
|
|
106
nixos/modules/services/taskwarrior-autotag.nix
Normal file
106
nixos/modules/services/taskwarrior-autotag.nix
Normal file
|
@ -0,0 +1,106 @@
|
||||||
|
{ config, lib, pkgs, ... }:
|
||||||
|
|
||||||
|
with lib;
|
||||||
|
with types;
|
||||||
|
let
|
||||||
|
cfg = config.services.taskwarrior-autotag;
|
||||||
|
name = "taskwarrior-autotag";
|
||||||
|
in
|
||||||
|
{
|
||||||
|
options.services.taskwarrior-autotag = {
|
||||||
|
enable = mkEnableOption "taskwarrior autotag notification service";
|
||||||
|
onCalendar = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "4:00:00";
|
||||||
|
};
|
||||||
|
recurrence = mkOption {
|
||||||
|
type = enum [ "on" "off" ];
|
||||||
|
default = "off";
|
||||||
|
};
|
||||||
|
query = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "( +ACTIVE or +DUETODAY or +TODAY or +OVERDUE )";
|
||||||
|
};
|
||||||
|
dataDir = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "tasks";
|
||||||
|
};
|
||||||
|
tag_name = mkOption {
|
||||||
|
type = str;
|
||||||
|
default = "yolo";
|
||||||
|
description = "tag do be set to the querried tasks.";
|
||||||
|
};
|
||||||
|
caFile = mkOption {
|
||||||
|
type = path;
|
||||||
|
};
|
||||||
|
certificateFile = mkOption {
|
||||||
|
type = path;
|
||||||
|
};
|
||||||
|
credentials = mkOption {
|
||||||
|
type = str;
|
||||||
|
};
|
||||||
|
keyFile = mkOption {
|
||||||
|
type = path;
|
||||||
|
};
|
||||||
|
server = mkOption {
|
||||||
|
type = str;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
|
users.users.${name} = {
|
||||||
|
isSystemUser = true;
|
||||||
|
home = "/var/lib/${name}";
|
||||||
|
group = name;
|
||||||
|
};
|
||||||
|
users.groups.${name} = { };
|
||||||
|
|
||||||
|
systemd.services.taskwarrior-autotag = {
|
||||||
|
enable = true;
|
||||||
|
serviceConfig = {
|
||||||
|
User = name;
|
||||||
|
StateDirectory = name;
|
||||||
|
};
|
||||||
|
script =
|
||||||
|
let
|
||||||
|
taskwarriorCommand = pkgs.writers.writeDash "taskwarrior-autotag" ''
|
||||||
|
${pkgs.taskwarrior}/bin/task \
|
||||||
|
rc:/var/lib/${name}/.taskrc \
|
||||||
|
rc.data.location=/var/lib/${name}/${cfg.dataDir} \
|
||||||
|
rc.recurrence=${cfg.recurrence} \
|
||||||
|
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} \
|
||||||
|
"$@"
|
||||||
|
'';
|
||||||
|
set_tag_query = "status:pending '${cfg.query}'";
|
||||||
|
unset_tag_query = "'! ${cfg.query}'";
|
||||||
|
yes = "${pkgs.coreutils}/bin/yes";
|
||||||
|
in
|
||||||
|
''
|
||||||
|
if [ -d /var/lib/${name}/${cfg.dataDir} ]
|
||||||
|
then
|
||||||
|
echo "synchronize ${cfg.dataDir}"
|
||||||
|
${taskwarriorCommand} sync
|
||||||
|
else
|
||||||
|
echo "initialize ${cfg.dataDir}"
|
||||||
|
${pkgs.coreutils}/bin/yes | ${taskwarriorCommand} sync init
|
||||||
|
fi
|
||||||
|
|
||||||
|
# todo continue
|
||||||
|
${yes} | ${taskwarriorCommand} ${unset_tag_query} mod -${cfg.tag_name}
|
||||||
|
${yes} | ${taskwarriorCommand} ${set_tag_query} mod +${cfg.tag_name}
|
||||||
|
${taskwarriorCommand} sync
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
systemd.timers.taskwarrior-autotag = {
|
||||||
|
enable = true;
|
||||||
|
timerConfig.OnCalendar = cfg.onCalendar;
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in a new issue