Subject: Re: [bug#62008] [PATCH 0/2] Update Disarchive to 0.5.0

From: Simon Tournier <[email-masked]>
Date: Wed, 16 Aug 2023 19:28:18 +0200

Hi Ludo,

You closed this but the issue is still there, no? :-)

On Fri, 10 Mar 2023 at 17:44, Ludovic Courtès <[email-masked]> wrote:
> Simon Tournier <[email-masked]> skribis:
>
>> On ven., 10 mars 2023 at 09:17, Ludovic Courtès <[email-masked]> wrote:
>>
>>> Hmm good point.  So maybe we need to wrap after all, and also keep
>>> propagated inputs (as an example, (guix build download) uses the
>>> Disarchive modules directly, not the command.)
>>
>> I am proposing to have ’package/inherit’,
>>
>>  1. ’disarchive’: the standalone CLI with wrap
>>  2. ’guile-disarchive’: the library with propagated-inputs
>
> I think having a single package is more convenient: it would both
> propagate inputs and wrap the binaries as you proposed.

Because of this error:

--8<---------------cut here---------------start------------->8---
$ guix shell -C disarchive -- disarchive disassemble hello-2.12.1
Backtrace:
In ice-9/boot-9.scm:

[...]

ice-9/boot-9.scm:3329:6: In procedure resolve-interface:
no code for module (gcrypt hash)
--8<---------------cut here---------------end--------------->8---

solved by adding the package guile,

    $ guix shell -C disarchive guile -- disarchive disassemble hello-2.12.1

then, I think the contrary: having two packages is more convenient.

Well, from my point of view, two packages would be consistent with other
Guix packages as pandoc and ghc-pandoc for instance.  Plain name for the
CLI and <language>-name for the library in <language>, somehow.  The
<language> compiler/interpreter propagated/wrapped only with the CLI.

Somehow, I am proposing this attached patch.

diff --git a/gnu/packages/backup.scm b/gnu/packages/backup.scm
index d484c34826..e60570b037 100644
--- a/gnu/packages/backup.scm
+++ b/gnu/packages/backup.scm
@@ -1256,9 +1256,9 @@ (define-public burp
 backup.")
     (license license:agpl3)))
 
-(define-public disarchive
+(define-public guile-disarchive
   (package
-    (name "disarchive")
+    (name "guile-disarchive")
     (version "0.5.0")
     (source (origin
               (method url-fetch)
@@ -1290,6 +1290,42 @@ (define-public disarchive
 compression parameters used by Gzip.")
     (license license:gpl3+)))
 
+(define-public disarchive
+  (package/inherit guile-disarchive
+    (name "disarchive")
+    (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))))))))
+    (inputs
+     (list guile-3.0 guile-gcrypt guile-lzma zlib))
+    (propagated-inputs (list))))
+
 (define-public borgmatic
   (package
     (name "borgmatic")

Then tweaking around.

Cheers,
simon