aboutsummaryrefslogtreecommitdiff
path: root/tw/system/vin.scm
diff options
context:
space:
mode:
Diffstat (limited to 'tw/system/vin.scm')
-rw-r--r--tw/system/vin.scm51
1 files changed, 10 insertions, 41 deletions
diff --git a/tw/system/vin.scm b/tw/system/vin.scm
index e7f4bb4b..772098a0 100644
--- a/tw/system/vin.scm
+++ b/tw/system/vin.scm
@@ -8,16 +8,14 @@
#: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)
#:use-module (gnu system nss)
#:use-module (guix gexp)
#:use-module (tw channels)
- #:use-module (tw packages finance)
#:use-module (tw services dns)
#:use-module (tw services grafana)
+ #:use-module (tw services personal-data-exporter)
#:use-module (tw services restic)
#:use-module (tw services secrets)
#:use-module (tw system))
@@ -208,49 +206,20 @@
(certbot-configuration
(email "letsencrypt@twilken.net")))
- ;; Personal statistics exporter: stores hledger data (and soon location
- ;; data?) in Postgres for Grafana to read.
+ ;; Personal statistics exporter: stores electricity and hledger data
+ ;; (and soon location data?) in Postgres for Grafana to read.
(service syncthing-service-type
(syncthing-configuration (user "timo")))
(service postgresql-service-type
(postgresql-configuration
(postgresql postgresql-15)))
- (simple-service 'ledgerplot-roles postgresql-role-service-type
- (list (postgresql-role
- (name "timo")
- (create-database? #t)
- (permissions '(login)))))
- (simple-service 'ledgerplot-file-watcher shepherd-root-service-type
- (list (shepherd-service
- (provision '(ledgerplot))
- (requirement '(postgresql syncthing-timo))
- (documentation
- "Monitor a ledger file and keep a database in sync with it.")
- (start #~(make-forkexec-constructor
- (list #$(file-append ledgerplot "/bin/ledgerplot")
- "-wd" "timo" "-U" "timo" "-H" "/var/run/postgresql")
- #:user "timo" #:group "users"
- #:environment-variables
- (cons*
- ;; This is where Syncthing puts the ledger file.
- "LEDGER_FILE=/home/timo/sync/ledger/ledger.journal"
- ;; Use an appropriate locale so that ledgerplot
- ;; can read the UTF-8 ledger file.
- (string-append
- "LC_ALL=" #$(locale-definition-name
- (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")
- (execl #$(file-append ledgerplot "/bin/ledgerplot")
- "ledgerplot" "-em")))
- #:user "timo")))
+ (service personal-data-exporter-service-type
+ (personal-data-exporter-configuration
+ (user "timo") (group "users")
+ ;; This is where Syncthing puts the ledger file.
+ (ledger-file "/home/timo/sync/ledger/ledger.journal")
+ ;; Match the Postgres version configured for the server.
+ (postgresql postgresql-15)))
(service unattended-upgrade-service-type
(unattended-upgrade-configuration