1
0
Fork 0

Add script to generate actual-server package

master
Sudoer777's Guix Server 2024-05-26 01:47:49 -05:00
parent 8ee4a09c81
commit 18c0f73539
No known key found for this signature in database
GPG Key ID: 030A38A3A5035E37
1 changed files with 87 additions and 19 deletions

View File

@ -6,8 +6,17 @@
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
#:use-module (guix licenses) #:use-module (guix licenses)
#:use-module (gnu packages) #:use-module (gnu packages)
#:use-module (gnu packages base)
#:use-module (gnu packages bash)
#:use-module (gnu packages gawk)
#:use-module (gnu packages guile)
#:use-module (gnu packages shells)
#:use-module (gnu packages compression)
#:use-module (gnu packages node) #:use-module (gnu packages node)
#:use-module (gnu packages package-management) #:use-module (gnu packages package-management)
#:use-module (gnu packages gnupg)
#:use-module
(gnu packages gcc)
#:use-module (ice-9 pretty-print) #:use-module (ice-9 pretty-print)
#:use-module (srfi srfi-1) #:use-module (srfi srfi-1)
#:use-module (srfi srfi-26)) #:use-module (srfi srfi-26))
@ -41,25 +50,50 @@
(guix build utils) (guix build utils)
(ice-9 pretty-print) (ice-9 pretty-print)
(gcrypt hash) (gcrypt hash)
(guix base32)) (guix base32)
(ice-9 ftw))
(define (run-shell-command command)
(let* ((p (open-pipe* OPEN_READ "sh" "-c" command))
(output (get-string-all p)))
(close-pipe p)
output))
(define (run-and-display-command command) (define (run-and-display-command command)
(let ((port (open-pipe* OPEN_READ "sh" "-c" command))) (let* ((port (open-pipe* OPEN_READ "sh" "-c" command))
(status #f))
(let loop () (let loop ()
(let ((line (read-line port 'concat))) (let ((line (read-line port 'concat)))
(if (eof-object? line) (if (eof-object? line)
(close-pipe port) (begin
(set! status (close-pipe port))
(if (not (zero? status))
(error "Command failed" command status)))
(begin (begin
(display line) (display line)
(force-output) ; Ensure output is flushed immediately (force-output)
(loop))))))) (loop)))))))
(define (delete-directory-contents dir)
(for-each (lambda (file)
(let ((full-path (string-append dir "/" file)))
(if (directory-exists? full-path)
(delete-file-recursively full-path)
(delete-file full-path))))
(filter (lambda (file)
(not (member file '("." ".."))))
(scandir dir))))
(define (chmod-r path mode)
(define (change-permissions file stat flag)
(chmod file mode))
(ftw path change-permissions))
(delete-directory-contents "/actual-server")
(mkdir-p "/actual-server-build/lib")
(copy-recursively (string-append (getenv "GUIX_ENVIRONMENT") "/lib/actual-server-installer/repo")
"/actual-server-build/lib/actual-server")
(chmod-r "/actual-server-build/lib/actual-server" #o755)
(chdir "/actual-server-build/lib/actual-server")
;; Enable corepack and install yarn ;; Enable corepack and install yarn
(run-and-display-command "corepack enable") (run-and-display-command "corepack enable")
(run-and-display-command "corepack install") (run-and-display-command "corepack install")
@ -86,11 +120,20 @@ output))
`( `(
(define-module (actual-server) (define-module (actual-server)
#:use-module (guix packages) #:use-module (guix packages)
#:use-module (gnu packages bash)
#:use-module (gnu packages base)
#:use-module (guix build-system gnu) #:use-module (guix build-system gnu)
#:use-module (gnu packages gcc)
#:use-module (guix licenses) #:use-module (guix licenses)
#:use-module (guix download) #:use-module (guix download)
#:use-module (gnu packages) #:use-module (gnu packages)
#:use-module (gnu packages node)) #:use-module (gnu packages node)
#:use-module
(gnu packages gcc)
#:use-module
(guix build utils)
#:use-module
(gnu packages elf))
(define-public actual-server (define-public actual-server
(package (package
@ -102,8 +145,14 @@ output))
(sha256 (sha256
(base32 ,checksum)))) (base32 ,checksum))))
(build-system gnu-build-system) (build-system gnu-build-system)
(inputs (propagated-inputs
`(("node" ,node-lts))) `(("gcc" ,gcc "lib")
("node" ,node-lts)
("bash" ,bash)
("coreutils" ,coreutils)
("findutils" ,findutils)))
(native-inputs
`(("patchelf" ,patchelf)))
(arguments (arguments
`(#:tests? #f ; Disable tests `(#:tests? #f ; Disable tests
#:phases (modify-phases %standard-phases #:phases (modify-phases %standard-phases
@ -113,9 +162,16 @@ output))
(add-after 'unpack 'copy-files (add-after 'unpack 'copy-files
(lambda* (#:key outputs #:allow-other-keys) (lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out"))) (let ((out (assoc-ref outputs "out")))
(mkdir-p (string-append out "/lib")) (copy-recursively "." (string-append out "/lib"))
(copy-recursively (string-append (assoc-ref %build-inputs "source") "/lib") (string-append out "/lib")) #t)))
#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") (home-page "https://github.com/actualbudget/actual-server")
(synopsis "Actual server for budget management") (synopsis "Actual server for budget management")
(description "Actual is a local-first personal finance tool.") (description "Actual is a local-first personal finance tool.")
@ -128,8 +184,19 @@ output))
actual-server-scm))))) actual-server-scm)))))
port)))))))) port))))))))
(build-system gnu-build-system) (build-system gnu-build-system)
(inputs (propagated-inputs
`(("node" ,node-lts))) `(("bash" ,bash)
("coreutils" ,coreutils)
("findutils" ,findutils)
("tar" ,tar)
("gzip" ,gzip)
("gawk" ,gawk)
("node" ,node)
("guix" ,guix)
("guile" ,guile-3.0)
("guile-gcrypt" ,guile-gcrypt)
("node", node-lts)
("gcc" ,gcc "lib")))
(arguments (arguments
`(#:tests? #f ; Disable tests for simplicity `(#:tests? #f ; Disable tests for simplicity
#:phases (modify-phases %standard-phases #:phases (modify-phases %standard-phases
@ -140,6 +207,7 @@ port))))))))
(lambda* (#:key outputs #:allow-other-keys) (lambda* (#:key outputs #:allow-other-keys)
(let ((source-dir (assoc-ref outputs "out"))) (let ((source-dir (assoc-ref outputs "out")))
(copy-recursively "." (string-append source-dir "/lib/actual-server-installer/repo")) (copy-recursively "." (string-append source-dir "/lib/actual-server-installer/repo"))
(rename-file (string-append source-dir "/lib/actual-server-installer/repo/build.scm") (string-append source-dir "/lib/actual-server-installer/build.scm"))
#t)))))) #t))))))
(home-page "https://github.com/actualbudget/actual-server") (home-page "https://github.com/actualbudget/actual-server")
(synopsis "Actual server for budget management") (synopsis "Actual server for budget management")