From 726fe6c32ad19f1110cea6ab12d7d7a1e4c9d949 Mon Sep 17 00:00:00 2001 From: Timo Wilken Date: Sun, 11 Feb 2024 20:39:17 +0100 Subject: Use the less memory-hungry ledgerplot instead of hledger-dashboard --- tw/packages/finance.scm | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) (limited to 'tw/packages/finance.scm') diff --git a/tw/packages/finance.scm b/tw/packages/finance.scm index 38b20aa2..facb2bf7 100644 --- a/tw/packages/finance.scm +++ b/tw/packages/finance.scm @@ -1,6 +1,11 @@ (define-module (tw packages finance) + #:use-module (gnu packages databases) + #:use-module (gnu packages finance) #:use-module (gnu packages haskell-xyz) + #:use-module (gnu packages lisp-check) + #:use-module (gnu packages lisp-xyz) #:use-module (guix build-system haskell) + #:use-module (guix build-system asdf) #:use-module (guix gexp) #:use-module (guix git-download) #:use-module (guix packages) @@ -23,3 +28,75 @@ (description "Maintain a database containing financial data extracted from hledger, for use in Grafana, e.g. to create nice graphs.") (license license:gpl3+))) + +;; Upstream binary-types declares "bt" as a package nickname, but +;; bordeaux-threads also uses that, so there's a conflict at load time: +;; https://github.com/Ferada/cl-inotify/issues/3 +;; https://github.com/frodef/binary-types/issues/1 +;; Instead, use a fixed version of binary-types. +(define sbcl-binary-types/fix + (let ((commit "a17caf8890f11fdc56f6ea3a21260bf0fb9c589c")) + (package + (inherit sbcl-binary-types) + (version (git-version "1.2" "2" commit)) + (home-page "https://github.com/Ferada/binary-types") + (source + (origin + (method git-fetch) + (uri (git-reference (url home-page) (commit commit))) + (file-name (git-file-name "binary-types" version)) + (sha256 + (base32 "1bh65p9vg2kgh4m8q1a4jiyncnp5prdzh0d0l4pzh3jvfhgbm0gh"))))))) + +(define sbcl-cl-inotify/fix + (package + (inherit sbcl-cl-inotify) + (inputs (modify-inputs (package-inputs sbcl-cl-inotify) + (replace "sbcl-binary-types" sbcl-binary-types/fix))))) + +(define-public ledgerplot + (package + (name "ledgerplot") + (version "1.1.0") + (source (origin + (method git-fetch) + (uri (git-reference + (url "https://git.twilken.net/ledgerplot") + (commit version))) + (sha256 (base32 "04i6chp2b3vd0i7bj9zp2bfy50mdbjcdr9zqspy9np3y7i48pimv")))) + ;; Ledgerplot only works with SBCL. + (build-system asdf-build-system/sbcl) + (arguments `(#:phases + ,#~(modify-phases %standard-phases + (add-after 'unpack 'patch-executable-names + (lambda* (#:key inputs #:allow-other-keys) + (substitute* (find-files "src" "\\.lisp$") + (("\"hledger\"") + (string-append "\"" (search-input-file inputs "bin/hledger") "\""))))) + (add-after 'create-asdf-configuration 'build-program + (lambda* (#:key outputs #:allow-other-keys) + (build-program + (string-append (assoc-ref outputs "out") "/bin/ledgerplot") + outputs + #:entry-program '((ledgerplot:main) 0))))))) + (inputs (list hledger + sbcl-bordeaux-threads + sbcl-local-time + sbcl-cl-ppcre + sbcl-trivia + sbcl-parse-float + sbcl-unix-opts + sbcl-cl-inotify/fix + sbcl-cl-json + sbcl-cl-csv + sbcl-drakma + sbcl-eazy-gnuplot + sbcl-md5 + sbcl-postmodern)) + (native-inputs (list postgresql-15 ; tests bring up a temporary database + sbcl-fiveam)) + (home-page "https://cgit.twilken.net/ledgerplot/about/") + (synopsis "Visualise data from hledger") + (description "Ledgerplot reads financial data from the hledger plain text +accounting system and processes it into various useful plots.") + (license license:gpl3+))) -- cgit v1.2.3