aboutsummaryrefslogtreecommitdiff
path: root/tw/system/vin.scm
diff options
context:
space:
mode:
authorTimo Wilken2024-02-11 22:41:39 +0100
committerTimo Wilken2024-02-11 22:41:39 +0100
commit94bdfc84fcd9659f7363d82127ae02ca49fa8f4d (patch)
tree02a8dbc473bf2b826d236a1fdc7c9cb98393834a /tw/system/vin.scm
parent726fe6c32ad19f1110cea6ab12d7d7a1e4c9d949 (diff)
Update ledgerplot and fetch exchange rates on weeknights
Diffstat (limited to 'tw/system/vin.scm')
-rw-r--r--tw/system/vin.scm14
1 files changed, 12 insertions, 2 deletions
diff --git a/tw/system/vin.scm b/tw/system/vin.scm
index 4d6b216f..e38f545a 100644
--- a/tw/system/vin.scm
+++ b/tw/system/vin.scm
@@ -8,6 +8,7 @@
#:use-module (gnu services docker)
#:use-module (gnu services dbus)
#:use-module (gnu services desktop) ; elogind-service-type
+ #:use-module (gnu services mcron)
#:use-module (gnu services shepherd)
#:use-module (gnu services syncthing)
#:use-module (gnu system locale)
@@ -214,7 +215,7 @@
(name "timo")
(create-database? #t)
(permissions '(login)))))
- (simple-service 'ledgerplot shepherd-root-service-type
+ (simple-service 'ledgerplot-file-watcher shepherd-root-service-type
(list (shepherd-service
(provision '(ledgerplot))
(requirement '(postgresql syncthing-timo))
@@ -222,7 +223,7 @@
"Monitor a ledger file and keep a database in sync with it.")
(start #~(make-forkexec-constructor
(list #$(file-append ledgerplot "/bin/ledgerplot")
- "-wd" "timo")
+ "-wd" "timo" "-H" "/var/run/postgresql")
#:user "timo" #:group "users"
#:environment-variables
(cons*
@@ -235,6 +236,15 @@
(car locale-definitions)))
(default-environment-variables))))
(stop #~(make-kill-destructor)))))
+ (simple-service 'ledgerplot-exchange-rates mcron-service-type
+ ;; Ledgerplot uses the Boerse Frankfurt API, so run after markets close there.
+ ;; According to https://www.boerse.de/handelszeiten/, it's 22:00 CET/CEST.
+ (list #~(job "5 22 * * mon-fri" ; weekdays after market close
+ #$(program-file "ledgerplot-exchange-rates-command"
+ #~(begin
+ (setenv "LEDGER_FILE" "/home/timo/sync/ledger/ledger.journal")
+ (execlp #$(file-append ledgerplot "/bin/ledgerplot") "-em")))
+ #:user "timo")))
(service unattended-upgrade-service-type
(unattended-upgrade-configuration