1
0
Fork 0

Allow actual-server-installer package to work in different directories

master
Sudoer777's Guix Server 2024-05-29 18:29:13 -05:00
parent 8bee267dcc
commit 0a1f9be5a1
No known key found for this signature in database
GPG Key ID: 030A38A3A5035E37
1 changed files with 79 additions and 77 deletions

View File

@ -70,6 +70,81 @@
(force-output)
(loop)))))))
(define (sha256sum file)
(call-with-input-file file
(lambda (port)
(let ((digest (sha256 (get-bytevector-all port))))
(bytevector->nix-base32-string digest)))))
(define (generate-actual-server-scm directory checksum)
`(
(define-module (actual-server)
#:use-module (guix packages)
#:use-module (gnu packages bash)
#:use-module (gnu packages base)
#:use-module (guix build-system gnu)
#:use-module (gnu packages gcc)
#:use-module (guix licenses)
#:use-module (guix download)
#:use-module (gnu packages)
#:use-module (gnu packages node)
#:use-module
(gnu packages gcc)
#:use-module
(guix build utils)
#:use-module
(gnu packages elf))
(define-public actual-server
(package
(name "actual-server")
(version "24.4.0")
(source (origin
(method url-fetch)
(uri (string-append "file://" ,directory "/actual-server.tar.gz"))
(sha256
(base32 ,checksum))))
(build-system gnu-build-system)
(propagated-inputs
`(("gcc" ,gcc "lib")
("node" ,node-lts)
("bash" ,bash)
("coreutils" ,coreutils)
("findutils" ,findutils)))
(native-inputs
`(("patchelf" ,patchelf)))
(arguments
`(#:tests? #f ; Disable tests
#:phases (modify-phases %standard-phases
(delete 'configure)
(delete 'build)
(delete 'install)
(add-after 'unpack 'copy-files
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
(copy-recursively "." (string-append out "/lib"))
#t)))
(add-after 'copy-files 'patch-runpath
(lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(gcc-lib (string-append (assoc-ref inputs "gcc") "/lib")))
(for-each
(lambda (binary)
(invoke "patchelf" "--set-rpath" gcc-lib binary))
(find-files (string-append out "/lib") ".*\\.node$"))))))))
(home-page "https://github.com/actualbudget/actual-server")
(synopsis "Actual server for budget management")
(description "Actual is a local-first personal finance tool.")
(license expat)))))
(define (write-actual-server-scm directory scm-content)
(call-with-output-file
(string-append directory "/actual-server.scm")
(lambda (port)
(for-each
(lambda (expr) (pretty-print expr port))
scm-content))))
(define (main args)
(if (< (length args) 1)
(error "Usage: script.scm <directory>"))
@ -81,7 +156,9 @@
directory
"=/actual-server actual-server-installer -- bash -c 'guile $GUIX_ENVIRONMENT/lib/actual-server-installer/build.scm'"))
))
(let* ((checksum (sha256sum (string-append directory "/actual-server.tar.gz")))
(scm-content (generate-actual-server-scm directory checksum)))
(write-actual-server-scm directory scm-content))))
(main (cdr (command-line)))
@ -157,82 +234,7 @@ directory
;; Create tar.gz archive
(run-and-display-command "tar -czvf /actual-server/actual-server.tar.gz -C /actual-server-build .")
;; Calculate checksum
(define (sha256sum file)
(call-with-input-file file
(lambda (port)
(let ((digest (sha256 (get-bytevector-all port))))
(bytevector->nix-base32-string digest)))))
(let* ((checksum (sha256sum "/actual-server/actual-server.tar.gz"))
(actual-server-scm
`(
(define-module (actual-server)
#:use-module (guix packages)
#:use-module (gnu packages bash)
#:use-module (gnu packages base)
#:use-module (guix build-system gnu)
#:use-module (gnu packages gcc)
#:use-module (guix licenses)
#:use-module (guix download)
#:use-module (gnu packages)
#:use-module (gnu packages node)
#:use-module
(gnu packages gcc)
#:use-module
(guix build utils)
#:use-module
(gnu packages elf))
(define-public actual-server
(package
(name "actual-server")
(version "24.4.0")
(source (origin
(method url-fetch)
(uri "file:///tmp/actual-server-installer/actual-server.tar.gz")
(sha256
(base32 ,checksum))))
(build-system gnu-build-system)
(propagated-inputs
`(("gcc" ,gcc "lib")
("node" ,node-lts)
("bash" ,bash)
("coreutils" ,coreutils)
("findutils" ,findutils)))
(native-inputs
`(("patchelf" ,patchelf)))
(arguments
`(#:tests? #f ; Disable tests
#:phases (modify-phases %standard-phases
(delete 'configure)
(delete 'build)
(delete 'install)
(add-after 'unpack 'copy-files
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
(copy-recursively "." (string-append out "/lib"))
#t)))
(add-after 'copy-files 'patch-runpath
(lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(gcc-lib (string-append (assoc-ref inputs "gcc") "/lib")))
(for-each
(lambda (binary)
(invoke "patchelf" "--set-rpath" gcc-lib binary))
(find-files (string-append out "/lib") ".*\\.node$"))))))))
(home-page "https://github.com/actualbudget/actual-server")
(synopsis "Actual server for budget management")
(description "Actual is a local-first personal finance tool.")
(license expat))))))
;; Write the content to actual-server.scm
(call-with-output-file "/actual-server/actual-server.scm"
(lambda (port)
(for-each (lambda (expr) (pretty-print expr port))
actual-server-scm)))))
port))))))))
port)))))))))
(build-system gnu-build-system)
(propagated-inputs
`(("bash" ,bash)