Subject: [bug#70317] [PATCH v2 13/13] gnu: packages: Add soju

From: Jesse Eisses <[email-masked]>
Date: Fri, 26 Apr 2024 00:08:24 +0200

---
 gnu/packages/irc.scm       | 77 ++++++++++++++++++++++++++++++++++++
 gnu/packages/messaging.scm | 81 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 158 insertions(+)

diff --git a/gnu/packages/irc.scm b/gnu/packages/irc.scm
index 80b2e740ee..90dad61eb9 100644
--- a/gnu/packages/irc.scm
+++ b/gnu/packages/irc.scm
@@ -1032,3 +1032,80 @@ (define-public snuik
 now).  It has some basic functionality only, such as seen, tell, and
 what.")
     (license license:gpl3+)))
+
+(define-public soju
+  (package
+    (name "soju")
+    (version "0.7.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.sr.ht/~emersion/soju")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1a0mp8f5i1ajh67y6fasmzgca3w1ccaiz19sx87rflbyi1mrhdlz"))))
+    (build-system go-build-system)
+    (arguments
+     (list
+      #:import-path "git.sr.ht/~emersion/soju"
+      #:go go-1.19
+      #:install-source? #f
+      #:phases
+      #~(modify-phases %standard-phases
+          (replace 'build
+            (lambda* (#:key outputs #:allow-other-keys)
+              (with-directory-excursion "src/git.sr.ht/~emersion/soju"
+                (setenv "SYSCONFDIR"
+                        (string-append (assoc-ref outputs "out")
+                                       "/etc"))
+                (invoke "make"))))
+          (replace 'install
+            (lambda* (#:key outputs #:allow-other-keys)
+              (with-directory-excursion "src/git.sr.ht/~emersion/soju"
+                (let ((bin-dir (string-append (assoc-ref outputs "out")
+                                              "/bin"))
+                      (conf-dir (string-append (assoc-ref outputs
+                                                          "out")
+                                               "/etc/soju")))
+                  (install-file "soju" bin-dir)
+                  (install-file "sojudb" bin-dir)
+                  (install-file "sojuctl" bin-dir)
+                  ;; the default config file is not useful so we empty it for now
+                  (substitute* "config.in" ((".*") ""))
+                  (mkdir-p conf-dir)
+                  (copy-file "config.in"
+                             (string-append conf-dir "/config"))))))
+          (add-before 'build 'set-flags
+            (lambda _
+              (begin
+                (setenv "CGO_LDFLAGS"
+                        "-Wl,--unresolved-symbols=ignore-in-object-files") #t))))))
+    (native-inputs (list scdoc))
+    (inputs (list go-google-golang-org-protobuf go-1.19))
+    (propagated-inputs
+     (list go-nhooyr-io-websocket
+           go-gopkg-in-irc
+           go-golang-org-x-time
+           go-golang-org-x-crypto
+           go-github-com-prometheus-client-golang
+           go-github-com-pires-go-proxyproto
+           go-github-com-msteinert-pam
+           go-github-com-mattn-go-sqlite3
+           go-github-com-lib-pq
+           go-github-com-emersion-go-sasl
+           go-github-com-sherclockholmes-webpush-go
+           go-git-sr-ht-sircmpwn-go-bare
+           go-git-sr-ht-emersion-go-sqlite3-fts5
+           go-git-sr-ht-emersion-go-scfg))
+    (home-page "https://git.sr.ht/~emersion/soju")
+    (synopsis "User-friendly IRC bouncer") ;
+    (description
+     "Connects to upstream IRC servers on behalf of the user to provide
+extra functionality. soju supports many features
+such as multiple users, numerous @@url{https://ircv3.net/,IRCv3} extensions,
+chat history playback and detached channels.  It is well-suited for both small
+and large deployments.")
+    (license license:agpl3)))
+
diff --git a/gnu/packages/messaging.scm b/gnu/packages/messaging.scm
index 20bdb713b5..f2529f6cb3 100644
--- a/gnu/packages/messaging.scm
+++ b/gnu/packages/messaging.scm
@@ -88,6 +88,7 @@ (define-module (gnu packages messaging)
   #:use-module (gnu packages gnupg)
   #:use-module (gnu packages golang)
   #:use-module (gnu packages golang-build)
+  #:use-module (gnu packages golang-crypto)
   #:use-module (gnu packages golang-xyz)
   #:use-module (gnu packages gperf)
   #:use-module (gnu packages graphviz)
@@ -96,6 +97,7 @@ (define-module (gnu packages messaging)
   #:use-module (gnu packages guile)
   #:use-module (gnu packages hunspell)
   #:use-module (gnu packages icu4c)
+  #:use-module (gnu packages irc)
   #:use-module (gnu packages image)
   #:use-module (gnu packages kde)
   #:use-module (gnu packages kde-frameworks)
@@ -3625,4 +3627,83 @@ (define-public senpai
      "@code{senpai} is an IRC client that works best with bouncers.")
     (license license:isc)))
 
+(define-public soju
+  (package
+    (name "soju")
+    (version "0.7.0")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://git.sr.ht/~emersion/soju")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "1a0mp8f5i1ajh67y6fasmzgca3w1ccaiz19sx87rflbyi1mrhdlz"))))
+    (build-system go-build-system)
+    (arguments
+     `(#:import-path "git.sr.ht/~emersion/soju"
+       #:go ,go-1.19
+       #:install-source? #f
+       #:phases (modify-phases %standard-phases
+                  (replace 'build
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (with-directory-excursion "src/git.sr.ht/~emersion/soju"
+                        (setenv "SYSCONFDIR"
+                                (string-append (assoc-ref outputs "out")
+                                               "/etc"))
+                        (invoke "make"))))
+                  (replace 'install
+                    (lambda* (#:key outputs #:allow-other-keys)
+                      (with-directory-excursion "src/git.sr.ht/~emersion/soju"
+                        (let ((bin-dir (string-append (assoc-ref outputs "out")
+                                                      "/bin"))
+                              (conf-dir (string-append (assoc-ref outputs
+                                                                  "out")
+                                                       "/etc/soju")))
+                          (install-file "soju" bin-dir)
+                          (install-file "sojudb" bin-dir)
+                          (install-file "sojuctl" bin-dir)
+                          ;; the default config file is not useful so we empty it for now
+                          (substitute* "config.in" ((".*") ""))
+                          (mkdir-p conf-dir)
+                          (copy-file "config.in"
+                                     (string-append conf-dir "/config"))))))
+                  (add-before 'build 'set-flags
+                    (lambda _
+                      (begin
+                        (setenv "CGO_LDFLAGS"
+                         "-Wl,--unresolved-symbols=ignore-in-object-files") #t))))))
+    (native-inputs `(("scdoc" ,scdoc)))
+    (inputs `(("go-google-golang-org-protobuf" ,go-google-golang-org-protobuf)
+              ("go" ,go-1.19)))
+    (propagated-inputs
+     `(("go-nhooyr-io-websocket" ,go-nhooyr-io-websocket)
+       ("go-gopkg-in-irc-v4" ,go-gopkg-in-irc-v4)
+       ("go-golang-org-x-time" ,go-golang-org-x-time)
+       ("go-golang-org-x-crypto" ,go-golang-org-x-crypto)
+       ("go-github-com-prometheus-client-golang"
+        ,go-github-com-prometheus-client-golang-v1.17)
+       ("go-github-com-pires-go-proxyproto"
+        ,go-github-com-pires-go-proxyproto)
+       ("go-github-com-msteinert-pam" ,go-github-com-msteinert-pam)
+       ("go-github-com-mattn-go-sqlite3"
+        ,go-github-com-mattn-go-sqlite3)
+       ("go-github-com-lib-pq" ,go-github-com-lib-pq)
+       ("go-github-com-emersion-go-sasl" ,go-github-com-emersion-go-sasl)
+       ("go-github-com-sherclockholmes-webpush-go"
+        ,go-github-com-sherclockholmes-webpush-go)
+       ("go-git-sr-ht-sircmpwn-go-bare" ,go-git-sr-ht-sircmpwn-go-bare)
+       ("go-git-sr-ht-emersion-go-sqlite3-fts5" ,go-git-sr-ht-emersion-go-sqlite3-fts5)
+       ("go-git-sr-ht-emersion-go-scfg" ,go-git-sr-ht-emersion-go-scfg)))
+    (home-page "https://git.sr.ht/~emersion/soju")
+    (synopsis "User-friendly IRC bouncer") ;
+    (description
+     "Connects to upstream IRC servers on behalf of the user to provide
+extra functionality. soju supports many features
+such as multiple users, numerous @@url{https://ircv3.net/,IRCv3} extensions,
+chat history playback and detached channels.  It is well-suited for both small
+and large deployments.")
+    (license license:agpl3)))
+
 ;;; messaging.scm ends here
-- 
2.41.0