Hi, Julien Lepiller skribis: > Here's a new version, hopefully this addresses all your remarks. I'm > still not sure how (json) is pulled in to the build side though... How > does guix know it needs to use guile-json-3 instead of guile-json-1 for > instance? Ah, see below. > How does it work with inferiors? I think inferiors have nothing to do with it. > From 432f57aeeb3b2e48591288e6491d66ab299661f0 Mon Sep 17 00:00:00 2001 > From: Julien Lepiller > Date: Tue, 29 Oct 2019 20:58:51 +0100 > Subject: [PATCH 03/34] guix: Add composer-build-system. > > * guix/build-system/composer.scm: New file. > * guix/build/composer-build-system.scm: New file. > * gnu/packages/aux-files/findclass.php: New file. > * Makefile.am: Add them. > * doc/guix.texi (Build Systems): Document it. [...] > +(define %composer-build-system-modules > + ;; Build-side modules imported by default. > + `((guix build composer-build-system) > + (guix build union) > + (json) > + (json builder) > + (json parser) > + (json record) Here, as the comment says, you’re importing (json …) from the host side to the build side. That’s why it works. The problem is that it’s just picking whatever (json …) modules are on your load path on the host side: if you have Guile-JSON 3.x, it’ll use that, if you have 4.x, that’ll be 4.x, and if you have nothing, it’ll fail to build. So the fix is to remove those modules from this list. You should only ever import Guix modules. Now you need to bring Guile-JSON into the environment. When using gexp, we do that with ‘with-extensions’, but here it’s a bit clunky… > + (modules '((guix build composer-build-system) > + (guix build utils) > + (json)))) I think you don’t need (json) here. (This is the list of modules in scope.) > + (define builder > + `(begin > + (use-modules ,@modules) > + (composer-build #:source ,(match (assoc-ref inputs "source") > + (((? derivation? source)) > + (derivation->output-path source)) > + ((source) > + source) > + (source > + source)) > + #:system ,system > + #:outputs %outputs > + #:inputs %build-inputs > + #:search-paths ',(map search-path-specification->sexp > + search-paths) > + #:phases ,phases > + #:out-of-source? ,out-of-source? > + #:composer-file ,composer-file > + #:tests? ,tests? > + #:test-target ,test-target > + #:install-target ,install-target > + #:validate-runpath? ,validate-runpath? > + #:patch-shebangs? ,patch-shebangs? > + #:strip-binaries? ,strip-binaries? > + #:strip-flags ,strip-flags > + #:strip-directories ,strip-directories))) To bring in Guile-JSON, you need to do something similar to what ‘gexp->file’ does with ‘load-path-expression’, along these lines (untested): (define guile-json-drv (package-derivation store (module-ref (resolve-interface '(gnu packages guile)) 'guile-json) system)) (define builder `(begin (add-to-load-path (string-append ,(derivation->output-path guile-json-drv) "/share/guile/site/" (effective-version))) (use-modules ,@modules) …)) ;; … (build-expression->derivation store name builder ;; … #:inputs (append inputs `(("guile-json" ,guile-json-drv)))) I guess clunkiness is the reason why we didn’t do it last time… HTH! Ludo’.