diff options
Diffstat (limited to 'tw/system')
-rw-r--r-- | tw/system/files/restic/vin-electricity-conso-db.enc | 7 | ||||
-rw-r--r-- | tw/system/vin.scm | 51 |
2 files changed, 17 insertions, 41 deletions
diff --git a/tw/system/files/restic/vin-electricity-conso-db.enc b/tw/system/files/restic/vin-electricity-conso-db.enc new file mode 100644 index 00000000..eaf10064 --- /dev/null +++ b/tw/system/files/restic/vin-electricity-conso-db.enc @@ -0,0 +1,7 @@ +-----BEGIN AGE ENCRYPTED FILE----- +YWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IHNzaC1lZDI1NTE5IC9TV0hVQSBMMkRC +L3ZXSUZrS011cndFR0NaaW5TNS9LOVNaUjJ5NXBJemJJMGNrcGpZCmY2TkIwakRk +SDVjZmcvMkhhWGVJOEpJTWNwWVNlQ2FRalhhZldsdE5maHMKLS0tIExZV0Z6NWtM +K3RvN2NKdm0ycFp0TlN5QUMvUzB4U05ZVjZGZDFBTUI2N0UKscV1whui8YRflvSt +xYCv4MG9WV3ZNIA7hrhSaXbyAqOfnvrGS6vlwjTP19xPoie5sg== +-----END AGE ENCRYPTED FILE----- 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 |