From fee899ee7786b7183ae29a75de250c3b86d98a93 Mon Sep 17 00:00:00 2001 From: Sudoer777's Guix Server Date: Thu, 30 May 2024 20:27:36 -0500 Subject: [PATCH] Add run script for Actual Server --- .../packages/actual-server-installer.scm | 54 ++++++++++++++++++- 1 file changed, 52 insertions(+), 2 deletions(-) diff --git a/local-pkgs-gnu/packages/actual-server-installer.scm b/local-pkgs-gnu/packages/actual-server-installer.scm index dd75d93..b846f95 100644 --- a/local-pkgs-gnu/packages/actual-server-installer.scm +++ b/local-pkgs-gnu/packages/actual-server-installer.scm @@ -88,7 +88,8 @@ #:use-module (guix download) #:use-module (gnu packages) #:use-module (gnu packages node) -#:use-module + #:use-module (gnu packages guile) + #:use-module (gnu packages gcc) #:use-module (guix build utils) @@ -102,6 +103,51 @@ (source (origin (method url-fetch) (uri (string-append "file://" ,directory "/actual-server.tar.gz")) +(snippet + '(begin + ;; Guile code to pretty-print to a file + (use-modules (ice-9 pretty-print)) + (let ( + (run-output-file "actual-server-start")) + (call-with-output-file run-output-file + (lambda (port) + (format port "#!/usr/bin/env guile~%!#~%") + (pretty-print + '(begin + (use-modules + (ice-9 popen) + (ice-9 rdelim) + (srfi srfi-1) + (rnrs io ports) + (rnrs bytevectors) + (rnrs files) + (ice-9 pretty-print) + (ice-9 ftw)) + (define (run-and-display-command command) + (let* ((port (open-pipe* OPEN_READ "sh" "-c" command)) + (status #f)) + (let loop () + (let ((line (read-line port 'concat))) + (if (eof-object? line) + (begin + (set! status (close-pipe port)) + (if (not (zero? status)) + (error "Command failed" command status))) + (begin (display line) (force-output) (loop))))))) + (define ld-library-path "/lib") ;(getenv "LD_LIBRARY_PATH")) + (define home-path (getenv "HOME")) + (define sym-source (string-append home-path "/.cache/node")) + (define sym-target (string-append ld-library-path "/actual-server/node")) + +; (mkdir (string-append home-path "/.cache")) + (symlink sym-target sym-source) + + (run-and-display-command (string-append "cd " ld-library-path "/actual-server/proj && corepack enable && yarn start")) +; (run-and-display-command "corepack enable") +; (run-and-display-command "yarn start") + + ) + port)))))) (sha256 (base32 ,checksum)))) (build-system gnu-build-system) @@ -110,7 +156,8 @@ ("node" ,node-lts) ("bash" ,bash) ("coreutils" ,coreutils) -("findutils" ,findutils))) +("findutils" ,findutils) + ("guile" ,guile-3.0))) (native-inputs `(("patchelf" ,patchelf))) (arguments @@ -123,6 +170,9 @@ (lambda* (#:key outputs #:allow-other-keys) (let ((out (assoc-ref outputs "out"))) (copy-recursively "." (string-append out "/lib")) + (format #t "Checking if actual-server-start exists: ~a~%" (file-exists? (string-append out "/lib/actual-server-start"))) + (rename-file (string-append out "/lib/actual-server-start") (string-append out "/bin/actual-server")) + (chmod (string-append out "/bin/actual-server") #o755) #t))) (add-after 'copy-files 'patch-runpath (lambda* (#:key inputs outputs #:allow-other-keys)