1
0
Fork 0

Add run script for Actual Server

master
Sudoer777's Guix Server 2024-05-30 20:27:36 -05:00
parent 2b120529c5
commit fee899ee77
No known key found for this signature in database
GPG Key ID: 030A38A3A5035E37
1 changed files with 52 additions and 2 deletions

View File

@ -88,6 +88,7 @@
#:use-module (guix download)
#:use-module (gnu packages)
#:use-module (gnu packages node)
#:use-module (gnu packages guile)
#:use-module
(gnu packages gcc)
#:use-module
@ -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)