Subject: [PATCH 1/2] gnu: disarchive: Wrap program instead of using propagated inputs..

From: Simon Tournier <[email-masked]>
Date: Mon, 6 Mar 2023 20:19:49 +0100

* gnu/packages/backup.scm (disarchive)[arguments]: Add phase after install
to wrap program.
[inputs]: Add guile-gcrypt and guile-lzma.
[propagated-inputs]: Remove it.
---
 gnu/packages/backup.scm | 34 +++++++++++++++++++++++++++++++---
 1 file changed, 31 insertions(+), 3 deletions(-)

diff --git a/gnu/packages/backup.scm b/gnu/packages/backup.scm
index 7be0c813bb..7fe2e80d39 100644
--- a/gnu/packages/backup.scm
+++ b/gnu/packages/backup.scm
@@ -23,6 +23,7 @@
 ;;; Copyright © 2021 Sarah Morgensen <[email-masked]>
 ;;; Copyright © 2022 Maxim Cournoyer <[email-masked]>
 ;;; Copyright © 2022 Feng Shu <[email-masked]>
+;;; Copyright © 2023 Simon Tournier <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -1230,6 +1231,35 @@ (define-public disarchive
                (base32
                 "1pql8cspsxyx8cpw3xyhirnisv6rb4vj5mxr1d7w9la72q740n8s"))))
     (build-system gnu-build-system)
+    (arguments
+     (list
+      #:modules `((ice-9 popen)
+                  ,@%gnu-build-system-modules)
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-after 'install 'wrap-program
+            (lambda* (#:key inputs outputs #:allow-other-keys)
+              (let* ((effective
+                      (read (open-pipe* OPEN_READ
+                                        (string-append #$guile-3.0 "/bin/guile")
+                                        "-c" "(write (effective-version))")))
+                     (scm-dir (string-append "/share/guile/site/" effective))
+                     (go-dir (string-append "/lib/guile/" effective
+                                            "/site-ccache/"))
+                     (modules (list #$output
+                                    #$guile-bytestructures
+                                    #$guile-gcrypt
+                                    #$guile-lzma))
+                     (scm-path
+                      (map (lambda (module) (string-append module scm-dir))
+                           modules))
+                     (go-path
+                      (map (lambda (module) (string-append module scm-dir))
+                           modules)))
+                (wrap-program (string-append #$output "/bin/disarchive")
+                  `("PATH" ":" prefix (,(string-append #$output "/bin")))
+                  `("GUILE_LOAD_PATH" ":" prefix ,scm-path)
+                  `("GUILE_LOAD_COMPILED_PATH" ":" prefix ,go-path))))))))
     (native-inputs
      (list autoconf
            automake
@@ -1239,9 +1269,7 @@ (define-public disarchive
            guile-lzma
            guile-quickcheck))
     (inputs
-     (list guile-3.0 zlib))
-    (propagated-inputs
-     (list guile-gcrypt guile-lzma))
+     (list guile-3.0 guile-gcrypt guile-lzma zlib))
     (home-page "https://ngyro.com/software/disarchive.html")
     (synopsis "Software archive disassembler")
     (description "Disarchive can disassemble software archives into data
-- 
2.38.1