Subject: Add cl-yxorp-cli

From: Charles <[email-masked]>
Date: Sun, 15 Aug 2021 05:19:15 +0000

let me know if something is wrong or could be better: thanks.

From f7273b53facac11165e91af80a182837a85c064a Mon Sep 17 00:00:00 2001
From: Charles <[email-masked]>
Date: Sat, 14 Aug 2021 23:54:03 -0500
Subject: [PATCH] gnu: Add cl-yxorp-cli.

* gnu/packages/lisp-xyz.scm (sbcl-yxorp, ecl-yxorp, cl-yxorp): New variables.
* gnu/packages/web.scm (cl-yxorp-cli): New variable.
---
 gnu/packages/lisp-xyz.scm | 41 +++++++++++++++++++++++++++++++++++++++
 gnu/packages/web.scm      | 34 ++++++++++++++++++++++++++++++++
 2 files changed, 75 insertions(+)

diff --git a/gnu/packages/lisp-xyz.scm b/gnu/packages/lisp-xyz.scm
index 38cc7d6695..e88f920ec2 100644
--- a/gnu/packages/lisp-xyz.scm
+++ b/gnu/packages/lisp-xyz.scm
@@ -18243,6 +18243,47 @@ functions allow Lisp programs to explore the web.")
 (define-public cl-aserve
   (sbcl-package->cl-source-package sbcl-aserve))
 
+(define-public sbcl-yxorp
+  (let ((commit "d2e8f9304549e47ae5c7fa35a6b114804603eac9")
+        (revision "1"))
+    (package
+      (name "sbcl-yxorp")
+      (version (git-version "0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/charJe/cl-yxorp")
+               (commit commit)))
+         (file-name (git-file-name "cl-yxorp" version))
+         (sha256
+          (base32 "1zz1j678vzwkf817h2z0pf0fcyf4mldv4hiv1wyam58hd4bcrjsw"))))
+      (build-system asdf-build-system/sbcl)
+      (inputs
+       `(("cl+ssl" ,sbcl-cl+ssl)
+         ("cl-binding-arrows" ,sbcl-binding-arrows)
+         ("cl-str" ,sbcl-cl-str)
+         ("cl-usocket" ,sbcl-usocket)
+         ("flexi-streams" ,sbcl-flexi-streams)
+         ("trivial-garbage" ,sbcl-trivial-garbage)))
+      (home-page "https://github.com/charje/cl-yxorp")
+      (synopsis
+       "A reverse proxy server written in and configurable in Common Lisp.")
+      (description "It supports WebSocket, HTTP, HTTPS, HTTP to HTTPS
+redirecting, port and host forwarding configuration using a real programming
+language, HTTP header and body manipulation (also using a real programming
+language).")
+      (license license:agpl3))))
+
+(define-public ecl-yxorp
+  ;; Note that due to a bug in ECL this package does not build.
+  ;; The bug has already been fixed on the development branch,
+  ;; so this package will work work in the version after 21.2.1.
+  (sbcl-package->ecl-package sbcl-yxorp))x
+
+(define-public cl-yxorp
+  (sbcl-package->cl-source-package sbcl-yxorp))
+
 (define-public sbcl-rss
   ;; No release.
   (let ((commit "51d0145e91b86327ae5c36364f9c3048052e7a58"))
diff --git a/gnu/packages/web.scm b/gnu/packages/web.scm
index ff53333169..d499fa0299 100644
--- a/gnu/packages/web.scm
+++ b/gnu/packages/web.scm
@@ -141,6 +141,7 @@
   #:use-module (gnu packages libunistring)
   #:use-module (gnu packages libunwind)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages lisp)
   #:use-module (gnu packages lisp-xyz)
   #:use-module (gnu packages lsof)
   #:use-module (gnu packages lua)
@@ -893,6 +894,39 @@ memory footprint compared to other webservers.  Its features include FastCGI,
 CGI, authentication, output compression, URL rewriting and many more.")
     (license license:bsd-3)))
 
+(define-public cl-yxorp-cli
+  (package
+    (inherit sbcl-yxorp)
+    (name "cl-yxorp-cli")
+    (build-system gnu-build-system)
+    (arguments
+     '(#:tests? #f
+       #:strip-binaries? #f
+       #:phases
+       (modify-phases %standard-phases
+         (delete 'configure)
+         (add-after 'unpack 'set-home
+           (lambda _
+             (setenv "HOME" "/tmp")
+             #t))
+         (replace 'build
+           (lambda _
+             (invoke
+              "sbcl" "--noinform"
+              "--disable-debugger"
+              "--no-userinit"
+              "--eval" "(require :asdf)"
+              "--eval" "(pushnew (uiop:getcwd) asdf:*central-registry*)"
+              "--load" "build.lisp")
+             #t))
+         (replace 'install
+           (lambda* (#:key outputs #:allow-other-keys)
+             (let ((bin (string-append (assoc-ref outputs "out") "/bin")))
+               (mkdir-p bin)
+               (install-file"cl-yxorp" bin))
+             #t)))))
+    (inputs (cons (list "sbcl" sbcl) (package-inputs sbcl-yxorp)))))
+
 (define-public fcgi
   (package
     (name "fcgi")
-- 
2.32.0