unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
* bug#45017: asdf-build-system packages have priority over user ones
@ 2020-12-03  9:42 Pierre Neidhardt
  2020-12-03 12:04 ` Guillaume Le Vaillant
  0 siblings, 1 reply; 17+ messages in thread
From: Pierre Neidhardt @ 2020-12-03  9:42 UTC (permalink / raw)
  To: 45017

[-- Attachment #1: Type: text/plain, Size: 2110 bytes --]

Since staging was merged a few days ago, I've noticed an undesirable
side-effect of our revamped asdf-build-system: the systems packages have
priority over the user-local ones.

Here is the default list of registries:

--8<---------------cut here---------------start------------->8---
(defparameter* *default-source-registries*
    '(environment-source-registry
      user-source-registry
      user-source-registry-directory
      default-user-source-registry
      system-source-registry
      system-source-registry-directory
      default-system-source-registry)
    "List of default source registries" "3.1.0.102")
--8<---------------cut here---------------end--------------->8---

`user-source-registry' points to what is read in
~/.config/common-lisp/source-registry.conf(.d/)?, so nothing by default.

user-source-registry-directory reads what's in XDG_CONFIG_DIRS, and it
finds the Guix packages there.

The default-user-source-registry expands to

--8<---------------cut here---------------start------------->8---
(:SOURCE-REGISTRY (:TREE (:HOME "common-lisp/"))
                (:DIRECTORY (:HOME ".sbcl/systems/"))
                (:DIRECTORY
                 #P"/home/ambrevar/.local/share/common-lisp/systems/")
                (:TREE #P"/home/ambrevar/.local/share/common-lisp/source/")
                :INHERIT-CONFIGURATION)
--8<---------------cut here---------------end--------------->8---

which is where I would drop my user-local packages.

Finally, default-system-source-registry reads what's in XDG_DATA_DIRS,
and it finds the packages there again, but it does not read the
Guix-generated conf which collects the dependencies of each package.



I believe the issue is that `user-source-registry-directory' should read
from XDG_CONFIG_HOME, and not XDG_CONFIG_DIRS (which would make it
redundant with `user-source-registry').  This would make it an upstream
issue, but I wanted to double-check I properly understood the problem
with the Guix community first.

Guillaume, thoughts on this?

-- 
Pierre Neidhardt
https://ambrevar.xyz/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 511 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#45017: asdf-build-system packages have priority over user ones
  2020-12-03  9:42 bug#45017: asdf-build-system packages have priority over user ones Pierre Neidhardt
@ 2020-12-03 12:04 ` Guillaume Le Vaillant
  2020-12-03 12:40   ` Pierre Neidhardt
  0 siblings, 1 reply; 17+ messages in thread
From: Guillaume Le Vaillant @ 2020-12-03 12:04 UTC (permalink / raw)
  To: Pierre Neidhardt; +Cc: 45017

[-- Attachment #1: Type: text/plain, Size: 4684 bytes --]


Pierre Neidhardt <mail@ambrevar.xyz> skribis:

> Since staging was merged a few days ago, I've noticed an undesirable
> side-effect of our revamped asdf-build-system: the systems packages have
> priority over the user-local ones.
>
> Here is the default list of registries:
>
> --8<---------------cut here---------------start------------->8---
> (defparameter* *default-source-registries*
>     '(environment-source-registry
>       user-source-registry
>       user-source-registry-directory
>       default-user-source-registry
>       system-source-registry
>       system-source-registry-directory
>       default-system-source-registry)
>     "List of default source registries" "3.1.0.102")
> --8<---------------cut here---------------end--------------->8---
>
> `user-source-registry' points to what is read in
> ~/.config/common-lisp/source-registry.conf(.d/)?, so nothing by default.
>
> user-source-registry-directory reads what's in XDG_CONFIG_DIRS, and it
> finds the Guix packages there.
>
> The default-user-source-registry expands to
>
> --8<---------------cut here---------------start------------->8---
> (:SOURCE-REGISTRY (:TREE (:HOME "common-lisp/"))
>                 (:DIRECTORY (:HOME ".sbcl/systems/"))
>                 (:DIRECTORY
>                  #P"/home/ambrevar/.local/share/common-lisp/systems/")
>                 (:TREE #P"/home/ambrevar/.local/share/common-lisp/source/")
>                 :INHERIT-CONFIGURATION)
> --8<---------------cut here---------------end--------------->8---
>
> which is where I would drop my user-local packages.
>
> Finally, default-system-source-registry reads what's in XDG_DATA_DIRS,
> and it finds the packages there again, but it does not read the
> Guix-generated conf which collects the dependencies of each package.
>
>
>
> I believe the issue is that `user-source-registry-directory' should read
> from XDG_CONFIG_HOME, and not XDG_CONFIG_DIRS (which would make it
> redundant with `user-source-registry').  This would make it an upstream
> issue, but I wanted to double-check I properly understood the problem
> with the Guix community first.
>
> Guillaume, thoughts on this?

Our cl-asdf package definition has little patches for
'user-source-registry-directory' and
'user-output-translations-directory-pathname' to make ASDF read
configuration files in all the directories listed in 'XDG_CONFIG_DIRS'
(IIRC regular ASDF was only reading from the first valid one in
'XDG_CONFIG_HOME' or 'XDG_CONFIG_DIRS'):

--8<---------------cut here---------------start------------->8---
(substitute* dst-asdf
  (("\\(xdg-config-pathname \\*source-registry-directory\\* direction\\)")
   "`(:source-registry
      ,@(loop
           for dir in (xdg-config-dirs
                       \"common-lisp/source-registry.conf.d/\")
           collect `(:include ,dir))
      :inherit-configuration)")
  (("\\(xdg-config-pathname \\*output-translations-directory\\* direction\\)")
   "`(:output-translations
      ,@(loop
           for dir in (xdg-config-dirs
                       \"common-lisp/asdf-output-translations.conf.d/\")
           collect `(:include ,dir))
      :inherit-configuration)")))
--8<---------------cut here---------------end--------------->8---

I guess 'XDG_CONFIG_HOME' is missing here and we could add it in the
list before the 'XDG_CONFIG_DIRS' directories. Something like:

--8<---------------cut here---------------start------------->8---
(substitute* dst-asdf
  (("\\(xdg-config-pathname \\*source-registry-directory\\* direction\\)")
   "`(:source-registry
      (:include (xdg-config-home \"common-lisp/source-registry.conf.d/\"))
      ,@(loop
           for dir in (xdg-config-dirs
                       \"common-lisp/source-registry.conf.d/\")
           collect `(:include ,dir))
      :inherit-configuration)")
  (("\\(xdg-config-pathname \\*output-translations-directory\\* direction\\)")
   "`(:output-translations
      (:include (xdg-config-home \"common-lisp/asdf-output-translations.conf.d/\"))
      ,@(loop
           for dir in (xdg-config-dirs
                       \"common-lisp/asdf-output-translations.conf.d/\")
           collect `(:include ,dir))
      :inherit-configuration)")))
--8<---------------cut here---------------end--------------->8---

Or maybe we could make a better patch not changing
'user-source-registry-directory', but adding a new
'guix-source-registry' between 'default-user-source-registry' and
'system-source-registry' in the list of registries (and likewise for
output-translations).
I think this way the systems in '$HOME/.config/...', '$HOME/.local/...'
or '$HOME/common-lisp/...' will have priority on the ones in Guix
profiles.

What do you think?

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#45017: asdf-build-system packages have priority over user ones
  2020-12-03 12:04 ` Guillaume Le Vaillant
@ 2020-12-03 12:40   ` Pierre Neidhardt
  2020-12-03 14:29     ` Guillaume Le Vaillant
  0 siblings, 1 reply; 17+ messages in thread
From: Pierre Neidhardt @ 2020-12-03 12:40 UTC (permalink / raw)
  To: Guillaume Le Vaillant; +Cc: 45017

[-- Attachment #1: Type: text/plain, Size: 1971 bytes --]

Oh, I had missed that!  Good thing I asked you first then ;)

> --8<---------------cut here---------------start------------->8---
> (substitute* dst-asdf
>   (("\\(xdg-config-pathname \\*source-registry-directory\\* direction\\)")
>    "`(:source-registry
>       (:include (xdg-config-home \"common-lisp/source-registry.conf.d/\"))
>       ,@(loop
>            for dir in (xdg-config-dirs
>                        \"common-lisp/source-registry.conf.d/\")
>            collect `(:include ,dir))
>       :inherit-configuration)")
>   (("\\(xdg-config-pathname \\*output-translations-directory\\* direction\\)")
>    "`(:output-translations
>       (:include (xdg-config-home \"common-lisp/asdf-output-translations.conf.d/\"))
>       ,@(loop
>            for dir in (xdg-config-dirs
>                        \"common-lisp/asdf-output-translations.conf.d/\")
>            collect `(:include ,dir))
>       :inherit-configuration)")))
> --8<---------------cut here---------------end--------------->8---

Hmm, I don't think this would work when the user has no
~/.config/common-lisp/source-registry.conf.
Would it?

> Or maybe we could make a better patch not changing
> 'user-source-registry-directory', but adding a new
> 'guix-source-registry' between 'default-user-source-registry' and
> 'system-source-registry' in the list of registries (and likewise for
> output-translations).
> I think this way the systems in '$HOME/.config/...', '$HOME/.local/...'
> or '$HOME/common-lisp/...' will have priority on the ones in Guix
> profiles.

I like it!

Possible pitfall: if the user set *default-source-registries* in their
Lisp RC file (e.g. ~/.sbclrc) this will prevent ASDF from seeing this
new Guix source registry.

Alternately, we could simply move the patch from
user-source-registry-directory to system-source-registry-directory; same
for the output translation.

Thoughts?

-- 
Pierre Neidhardt
https://ambrevar.xyz/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 511 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#45017: asdf-build-system packages have priority over user ones
  2020-12-03 12:40   ` Pierre Neidhardt
@ 2020-12-03 14:29     ` Guillaume Le Vaillant
  2020-12-04  8:51       ` Pierre Neidhardt
  2020-12-05  9:17       ` Pierre Neidhardt
  0 siblings, 2 replies; 17+ messages in thread
From: Guillaume Le Vaillant @ 2020-12-03 14:29 UTC (permalink / raw)
  To: Pierre Neidhardt; +Cc: 45017


[-- Attachment #1.1: Type: text/plain, Size: 268 bytes --]


Pierre Neidhardt <mail@ambrevar.xyz> skribis:

> Alternately, we could simply move the patch from
> user-source-registry-directory to system-source-registry-directory; same
> for the output translation.

What do you think of the attached patch? Does it work for you?

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-gnu-cl-asdf-Improve-priorities-of-configuration-file.patch --]
[-- Type: text/x-patch, Size: 5827 bytes --]

From cb8d52ec606bb8984622f6b117346b4772bf0d16 Mon Sep 17 00:00:00 2001
From: Guillaume Le Vaillant <glv@posteo.net>
Date: Thu, 3 Dec 2020 14:52:02 +0100
Subject: [PATCH] gnu: cl-asdf: Improve priorities of configuration file
 search.

* gnu/packages/patches/cl-asdf-config-directories.patch: New file.
* gnu/local.mk (dist_PATCH_DATA): Add it.
* gnu/packages/lisp.scm (cl-asdf)[native-inputs]: Add it.
  [arguments]: Apply the new patch.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/lisp.scm                         | 28 +++++----------
 .../patches/cl-asdf-config-directories.patch  | 36 +++++++++++++++++++
 3 files changed, 45 insertions(+), 20 deletions(-)
 create mode 100644 gnu/packages/patches/cl-asdf-config-directories.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 28ad119846..f838ebe1fa 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -868,6 +868,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/cdrtools-3.01-mkisofs-isoinfo.patch 	\
   %D%/packages/patches/ceph-disable-cpu-optimizations.patch	\
   %D%/packages/patches/chmlib-inttypes.patch			\
+  %D%/packages/patches/cl-asdf-config-directories.patch		\
   %D%/packages/patches/clamav-config-llvm-libs.patch		\
   %D%/packages/patches/clamav-system-tomsfastmath.patch		\
   %D%/packages/patches/clang-3.5-libc-search-path.patch		\
diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm
index e4c963070e..0038cb0dca 100644
--- a/gnu/packages/lisp.scm
+++ b/gnu/packages/lisp.scm
@@ -90,6 +90,9 @@
        (sha256
         (base32 "1hpx30f6yrak15nw992k7x3pn75ahvjs04n4f134k68mhgs62km2"))))
     (build-system trivial-build-system)
+    (native-inputs
+     `(("config-patch" ,@(search-patches "cl-asdf-config-directories.patch"))
+       ("patch" ,patch)))
     (arguments
      `(#:modules ((guix build utils)
                   (guix build lisp-utils))
@@ -101,28 +104,13 @@
                 (asdf-install (string-append out %source-install-prefix
                                              "/source/asdf/"))
                 (src-asdf (string-append (assoc-ref %build-inputs "source")))
-                (dst-asdf (string-append asdf-install "asdf.lisp")))
+                (dst-asdf (string-append asdf-install "asdf.lisp"))
+                (patch (string-append (assoc-ref %build-inputs "patch")
+                                      "/bin/patch"))
+                (config-patch (assoc-ref %build-inputs "config-patch")))
            (mkdir-p asdf-install)
            (copy-file src-asdf dst-asdf)
-           ;; Patch ASDF to make it read the configuration files in all
-           ;; the direcories listed in '$XDG_CONFIG_DIRS' instead of just
-           ;; the first.
-           (substitute* dst-asdf
-             (("\\(xdg-config-pathname \\*source-registry-directory\\* direction\\)")
-              "`(:source-registry
-                 ,@(loop
-                      for dir in (xdg-config-dirs
-                                  \"common-lisp/source-registry.conf.d/\")
-                      collect `(:include ,dir))
-                 :inherit-configuration)")
-             (("\\(xdg-config-pathname \\*output-translations-directory\\* direction\\)")
-              "`(:output-translations
-                 ,@(loop
-                      for dir in (xdg-config-dirs
-                                  \"common-lisp/asdf-output-translations.conf.d/\")
-                      collect `(:include ,dir))
-                 :inherit-configuration)")))
-         #t)))
+           (invoke patch "-p1" "-i" config-patch dst-asdf)))))
     (home-page "https://common-lisp.net/project/asdf/")
     (synopsis "Another System Definition Facility")
     (description
diff --git a/gnu/packages/patches/cl-asdf-config-directories.patch b/gnu/packages/patches/cl-asdf-config-directories.patch
new file mode 100644
index 0000000000..04ec67c9a0
--- /dev/null
+++ b/gnu/packages/patches/cl-asdf-config-directories.patch
@@ -0,0 +1,36 @@
+Search for ASDF configuration files first in user directories, and then in
+Guix profiles.
+
+diff -ru a/asdf-3.3.4.lisp b/asdf-3.3.4.lisp
+--- a/asdf-3.3.4.lisp	2020-02-14 20:16:22.000000000 +0100
++++ b/asdf-3.3.4.lisp	2020-12-03 13:57:54.843428936 +0100
+@@ -12537,8 +12537,12 @@
+   (defun user-output-translations-directory-pathname (&key (direction :input))
+     (xdg-config-pathname *output-translations-directory* direction))
+   (defun system-output-translations-directory-pathname (&key (direction :input))
+-    (find-preferred-file (system-config-pathnames *output-translations-directory*)
+-                         :direction direction))
++    `(:output-translations
++      ,@(loop :for dir :in (filter-pathname-set
++                            (xdg-config-dirs
++                             "common-lisp/asdf-output-translations.conf.d/"))
++              :collect `(:include ,dir))
++      :inherit-configuration))
+   (defun environment-output-translations ()
+     (getenv "ASDF_OUTPUT_TRANSLATIONS"))
+ 
+@@ -12923,8 +12927,12 @@
+   (defun user-source-registry-directory (&key (direction :input))
+     (xdg-config-pathname *source-registry-directory* direction))
+   (defun system-source-registry-directory (&key (direction :input))
+-    (find-preferred-file (system-config-pathnames *source-registry-directory*)
+-                         :direction direction))
++    `(:source-registry
++      ,@(loop :for dir :in (filter-pathname-set
++                            (xdg-config-dirs
++                             "common-lisp/source-registry.conf.d/"))
++              :collect `(:include ,dir))
++      :inherit-configuration))
+   (defun environment-source-registry ()
+     (getenv "CL_SOURCE_REGISTRY"))
+ 
-- 
2.29.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* bug#45017: asdf-build-system packages have priority over user ones
  2020-12-03 14:29     ` Guillaume Le Vaillant
@ 2020-12-04  8:51       ` Pierre Neidhardt
  2020-12-04  9:12         ` Guillaume Le Vaillant
  2020-12-05  9:17       ` Pierre Neidhardt
  1 sibling, 1 reply; 17+ messages in thread
From: Pierre Neidhardt @ 2020-12-04  8:51 UTC (permalink / raw)
  To: Guillaume Le Vaillant; +Cc: 45017

[-- Attachment #1: Type: text/plain, Size: 301 bytes --]

Thanks for taking a shot at this, looks great!

I'll test later, but for now one question: we patch sbcl to use our
cl-asdf, but what about the other compilers?  Seems to me that the other
compilers are going to have the same problem, aren't they?

-- 
Pierre Neidhardt
https://ambrevar.xyz/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 511 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#45017: asdf-build-system packages have priority over user ones
  2020-12-04  8:51       ` Pierre Neidhardt
@ 2020-12-04  9:12         ` Guillaume Le Vaillant
  2020-12-04 12:46           ` Pierre Neidhardt
  0 siblings, 1 reply; 17+ messages in thread
From: Guillaume Le Vaillant @ 2020-12-04  9:12 UTC (permalink / raw)
  To: Pierre Neidhardt; +Cc: 45017

[-- Attachment #1: Type: text/plain, Size: 612 bytes --]


Pierre Neidhardt <mail@ambrevar.xyz> skribis:

> Thanks for taking a shot at this, looks great!
>
> I'll test later, but for now one question: we patch sbcl to use our
> cl-asdf, but what about the other compilers?  Seems to me that the other
> compilers are going to have the same problem, aren't they?

SBCL and ECL are patched to use our cl-asdf because it is necessary to
build the sbcl-* and ecl-* packages. Also patching ABCL, CCL, and Clisp
sounds like a good idea. At least all the compilers would use the same
version of ASDF, and hopefully behave in the same way when looking for
configuration files.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#45017: asdf-build-system packages have priority over user ones
  2020-12-04  9:12         ` Guillaume Le Vaillant
@ 2020-12-04 12:46           ` Pierre Neidhardt
  2020-12-04 13:53             ` Guillaume Le Vaillant
  0 siblings, 1 reply; 17+ messages in thread
From: Pierre Neidhardt @ 2020-12-04 12:46 UTC (permalink / raw)
  To: Guillaume Le Vaillant; +Cc: 45017

[-- Attachment #1: Type: text/plain, Size: 1964 bytes --]

Guillaume Le Vaillant <glv@posteo.net> writes:

> SBCL and ECL are patched to use our cl-asdf because it is necessary to
> build the sbcl-* and ecl-* packages. Also patching ABCL, CCL, and Clisp
> sounds like a good idea. At least all the compilers would use the same
> version of ASDF, and hopefully behave in the same way when looking for
> configuration files.

Yup, that'd be neat :)

Related to this, I've noticed another issue with SBCL packages: when an
SBCL package has a dependency that's updated in ~/common-lisp,
(asdf:load-system ...) tries to recompile it in its folder, which fails
since /gnu/store is read-only.

Example:

- Apply the above patch or edit
  ~/.config/common-lisp/source-registry.conf
  to make sure ~/common-lisp is loaded before system packages.

- Install sbcl-cl-cookie.

- Check out https://github.com/fukamachi/quri:
  git clone https://github.com/fukamachi/quri ~/common-lisp/quri

- Now run

--8<---------------cut here---------------start------------->8---
$ sbcl
* (asdf:load-system :cl-cookie)
WARNING: System definition file #P"/gnu/store/81cwmspx3366vdjs6v20rnd8a0xyr6in-sbcl-cl-fad-0.7.6/share/common-lisp/sbcl/cl-fad/cl-fad.asd" contains definition for system "cl-fad-test". Please only define "cl-fad" and secondary systems with a name starting with "cl-fad/" (e.g. "cl-fad/test") in that file.

debugger invoked on a SB-INT:SIMPLE-FILE-ERROR in thread
#<THREAD "main thread" RUNNING {100B790203}>:
  Error opening #P"/gnu/store/22q4ydm0pagi4irz0clssgkhkyh115j8-sbcl-cl-cookie-0.9.10-1.cea55ae/lib/common-lisp/sbcl/cl-cookie/src/cl-cookie-tmpGHU3ALSV.fasl":

    Read-only file system
--8<---------------cut here---------------end--------------->8---

Not sure what to do about this.

I'm guessing that Common Lisp development is not practical with Guix'
SBCL packages and I should just stick to the CL packages.

Thoughts?

-- 
Pierre Neidhardt
https://ambrevar.xyz/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 511 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#45017: asdf-build-system packages have priority over user ones
  2020-12-04 12:46           ` Pierre Neidhardt
@ 2020-12-04 13:53             ` Guillaume Le Vaillant
  2020-12-04 17:30               ` Guillaume Le Vaillant
  2020-12-05  8:18               ` Pierre Neidhardt
  0 siblings, 2 replies; 17+ messages in thread
From: Guillaume Le Vaillant @ 2020-12-04 13:53 UTC (permalink / raw)
  To: Pierre Neidhardt; +Cc: 45017


[-- Attachment #1.1: Type: text/plain, Size: 2568 bytes --]


Pierre Neidhardt <mail@ambrevar.xyz> skribis:

> Guillaume Le Vaillant <glv@posteo.net> writes:
>
>> SBCL and ECL are patched to use our cl-asdf because it is necessary to
>> build the sbcl-* and ecl-* packages. Also patching ABCL, CCL, and Clisp
>> sounds like a good idea. At least all the compilers would use the same
>> version of ASDF, and hopefully behave in the same way when looking for
>> configuration files.
>
> Yup, that'd be neat :)

Patches for CCL and Clisp attached. ABCL fails to build with ASDF 3.3.4
and I have not seen an obvious error message in the logs, so this one
will need more investigation...


> Related to this, I've noticed another issue with SBCL packages: when an
> SBCL package has a dependency that's updated in ~/common-lisp,
> (asdf:load-system ...) tries to recompile it in its folder, which fails
> since /gnu/store is read-only.
>
> Example:
>
> - Apply the above patch or edit
>   ~/.config/common-lisp/source-registry.conf
>   to make sure ~/common-lisp is loaded before system packages.
>
> - Install sbcl-cl-cookie.
>
> - Check out https://github.com/fukamachi/quri:
>   git clone https://github.com/fukamachi/quri ~/common-lisp/quri
>
> - Now run
>
> --8<---------------cut here---------------start------------->8---
> $ sbcl
> * (asdf:load-system :cl-cookie)
> WARNING: System definition file #P"/gnu/store/81cwmspx3366vdjs6v20rnd8a0xyr6in-sbcl-cl-fad-0.7.6/share/common-lisp/sbcl/cl-fad/cl-fad.asd" contains definition for system "cl-fad-test". Please only define "cl-fad" and secondary systems with a name starting with "cl-fad/" (e.g. "cl-fad/test") in that file.
>
> debugger invoked on a SB-INT:SIMPLE-FILE-ERROR in thread
> #<THREAD "main thread" RUNNING {100B790203}>:
>   Error opening #P"/gnu/store/22q4ydm0pagi4irz0clssgkhkyh115j8-sbcl-cl-cookie-0.9.10-1.cea55ae/lib/common-lisp/sbcl/cl-cookie/src/cl-cookie-tmpGHU3ALSV.fasl":
>
>     Read-only file system
> --8<---------------cut here---------------end--------------->8---
>
> Not sure what to do about this.
>
> I'm guessing that Common Lisp development is not practical with Guix'
> SBCL packages and I should just stick to the CL packages.
>
> Thoughts?

The Lisp systems of sbcl-* and ecl-* packages installed in a profile are
supposed to be already compiled and immutable, so recompiling them
anyway would require tweaking the ASDF configuration from inside SBCL to
remove the output translations for these systems.
When doing development, it might be more convenient to just use the
sources or source packages of every system that has to be recompiled.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0002-gnu-ccl-Use-system-ASDF-instead-of-bundled-one.patch --]
[-- Type: text/x-patch, Size: 2818 bytes --]

From 5ce14232fafef61fdd5f9412c50dbfbb90f0d03e Mon Sep 17 00:00:00 2001
From: Guillaume Le Vaillant <glv@posteo.net>
Date: Fri, 4 Dec 2020 10:29:34 +0100
Subject: [PATCH 2/4] gnu: ccl: Use system ASDF instead of bundled one.

* gnu/packages/lisp.scm (ccl)[native-inputs]: Add cl-asdf.
  [arguments]: Add 'replace-asdf' phase.
  [native-search-paths]: Add XDG_CONFIG_DIRS and XDG_DATA_DIRS.
---
 gnu/packages/lisp.scm | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm
index 0038cb0dca..2a8c59546e 100644
--- a/gnu/packages/lisp.scm
+++ b/gnu/packages/lisp.scm
@@ -603,7 +603,8 @@ statistical profiler, a code coverage tool, and many other extensions.")
                 "0x4bjx6cxsjvxyagijhlvmc7jkyxifdvz5q5zvz37028va65243c")
                (_ "15l7cfa4a7jkfwdzsfm4q3n22jnb57imxahpql3h77xin57v1gbz"))))))))
     (native-inputs
-     `(("m4" ,m4)))
+     `(("cl-asdf" ,cl-asdf)
+       ("m4" ,m4)))
     (arguments
      `(#:tests? #f                      ;no 'check' target
        #:modules ((ice-9 match)
@@ -615,6 +616,17 @@ statistical profiler, a code coverage tool, and many other extensions.")
          (add-after 'unpack 'unpack-image
            (lambda* (#:key inputs #:allow-other-keys)
              (invoke "tar" "xzvf" (assoc-ref inputs "ccl-bootstrap"))))
+         (add-after 'unpack 'replace-asdf
+           ;; Use system ASDF instead of bundled one.
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((cl-asdf (assoc-ref inputs "cl-asdf"))
+                    (guix-asdf (string-append
+                                cl-asdf
+                                "/share/common-lisp/source/asdf/asdf.lisp"))
+                    (out (string-append (assoc-ref outputs "out")))
+                    (contrib-asdf "tools/asdf.lisp"))
+               (delete-file contrib-asdf)
+               (copy-file guix-asdf contrib-asdf))))
          (delete 'configure)
          (add-before 'build 'pre-build
            ;; Enter the source directory for the current platform's lisp
@@ -678,6 +690,13 @@ statistical profiler, a code coverage tool, and many other extensions.")
                      "exec -a \"$0\" " libdir kernel " \"$@\"\n"))))
                (chmod wrapper #o755))
              #t)))))
+    (native-search-paths
+     (list (search-path-specification
+            (variable "XDG_DATA_DIRS")
+            (files '("share")))
+           (search-path-specification
+            (variable "XDG_CONFIG_DIRS")
+            (files '("etc")))))
     (supported-systems '("i686-linux" "x86_64-linux" "armhf-linux"))
     (home-page "https://ccl.clozure.com/")
     (synopsis "Common Lisp implementation")
-- 
2.29.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0003-gnu-clisp-Use-system-ASDF-instead-of-bundled-one.patch --]
[-- Type: text/x-patch, Size: 2352 bytes --]

From 15c7a20030a7e7643af7948982791074e4c358be Mon Sep 17 00:00:00 2001
From: Guillaume Le Vaillant <glv@posteo.net>
Date: Fri, 4 Dec 2020 10:48:41 +0100
Subject: [PATCH 3/4] gnu: clisp: Use system ASDF instead of bundled one.

* gnu/packages/lisp.scm (clisp)[native-inputs]: Add cl-asdf.
  [arguments]: Add 'replace-asdf' phase.
  [native-search-paths]: Add XDG_CONFIG_DIRS and XDG_DATA_DIRS.
---
 gnu/packages/lisp.scm | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm
index 2a8c59546e..07d54747cb 100644
--- a/gnu/packages/lisp.scm
+++ b/gnu/packages/lisp.scm
@@ -322,6 +322,8 @@ supporting ASDF, Sockets, Gray streams, MOP, and other useful components.")
        (sha256
         (base32 "0k2dmgl0miz3767iks4p0mvp6xw0ysyxhjpklyh11j010rmh6hqb"))))
     (build-system gnu-build-system)
+    (native-inputs
+     `(("cl-asdf" ,cl-asdf)))
     (inputs `(("libffcall" ,libffcall)
               ("ncurses" ,ncurses)
               ("readline" ,readline)
@@ -356,7 +358,25 @@ supporting ASDF, Sockets, Gray streams, MOP, and other useful components.")
                (("/bin/sh") "sh"))
              (substitute* '("src/clisp-link.in")
                (("/bin/pwd") "pwd"))
-             #t)))))
+             #t))
+         (add-after 'unpack 'replace-asdf
+           ;; Use system ASDF instead of bundled one.
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let* ((cl-asdf (assoc-ref inputs "cl-asdf"))
+                    (guix-asdf (string-append
+                                cl-asdf
+                                "/share/common-lisp/source/asdf/asdf.lisp"))
+                    (out (string-append (assoc-ref outputs "out")))
+                    (contrib-asdf "modules/asdf/asdf.lisp"))
+               (delete-file contrib-asdf)
+               (copy-file guix-asdf contrib-asdf)))))))
+    (native-search-paths
+     (list (search-path-specification
+            (variable "XDG_DATA_DIRS")
+            (files '("share")))
+           (search-path-specification
+            (variable "XDG_CONFIG_DIRS")
+            (files '("etc")))))
     (home-page "https://clisp.sourceforge.io/")
     (synopsis "A Common Lisp implementation")
     (description
-- 
2.29.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* bug#45017: asdf-build-system packages have priority over user ones
  2020-12-04 13:53             ` Guillaume Le Vaillant
@ 2020-12-04 17:30               ` Guillaume Le Vaillant
  2020-12-05  8:18               ` Pierre Neidhardt
  1 sibling, 0 replies; 17+ messages in thread
From: Guillaume Le Vaillant @ 2020-12-04 17:30 UTC (permalink / raw)
  To: Pierre Neidhardt; +Cc: 45017

[-- Attachment #1: Type: text/plain, Size: 1124 bytes --]


Guillaume Le Vaillant <glv@posteo.net> skribis:

> The Lisp systems of sbcl-* and ecl-* packages installed in a profile are
> supposed to be already compiled and immutable, so recompiling them
> anyway would require tweaking the ASDF configuration from inside SBCL to
> remove the output translations for these systems.
> When doing development, it might be more convenient to just use the
> sources or source packages of every system that has to be recompiled.

I think entering the following expressions just after starting SBCL will
allow development mixing libraries from user directories and from Guix
profiles:

--8<---------------cut here---------------start------------->8---
(require :asdf)
(asdf:clear-output-translations)
(asdf:initialize-output-translations
 '(:output-translations
   :enable-user-cache
   :ignore-inherited-configuration))
--8<---------------cut here---------------end--------------->8---

However with this configuration, the pre-compiled files in
"/gnu/store/..." will not be used at all; everything will be compiled
again if necessary and put in the user cache in ".cache/common-lisp/...".

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#45017: asdf-build-system packages have priority over user ones
  2020-12-04 13:53             ` Guillaume Le Vaillant
  2020-12-04 17:30               ` Guillaume Le Vaillant
@ 2020-12-05  8:18               ` Pierre Neidhardt
  2020-12-05  9:42                 ` Guillaume Le Vaillant
  1 sibling, 1 reply; 17+ messages in thread
From: Pierre Neidhardt @ 2020-12-05  8:18 UTC (permalink / raw)
  To: Guillaume Le Vaillant; +Cc: 45017

[-- Attachment #1: Type: text/plain, Size: 1593 bytes --]

A few comments:

> @@ -603,7 +603,8 @@ statistical profiler, a code coverage tool, and many other extensions.")
>                  "0x4bjx6cxsjvxyagijhlvmc7jkyxifdvz5q5zvz37028va65243c")
>                 (_ "15l7cfa4a7jkfwdzsfm4q3n22jnb57imxahpql3h77xin57v1gbz"))))))))
>      (native-inputs
> -     `(("m4" ,m4)))
> +     `(("cl-asdf" ,cl-asdf)
> +       ("m4" ,m4)))
>      (arguments
>       `(#:tests? #f                      ;no 'check' target
>         #:modules ((ice-9 match)
> @@ -615,6 +616,17 @@ statistical profiler, a code coverage tool, and many other extensions.")
>           (add-after 'unpack 'unpack-image
>             (lambda* (#:key inputs #:allow-other-keys)
>               (invoke "tar" "xzvf" (assoc-ref inputs "ccl-bootstrap"))))
> +         (add-after 'unpack 'replace-asdf
> +           ;; Use system ASDF instead of bundled one.
> +           (lambda* (#:key inputs outputs #:allow-other-keys)
> +             (let* ((cl-asdf (assoc-ref inputs "cl-asdf"))
> +                    (guix-asdf (string-append
> +                                cl-asdf
> +                                "/share/common-lisp/source/asdf/asdf.lisp"))
> +                    (out (string-append (assoc-ref outputs "out")))

"out" is unused.  By the way, the same "out" is unused in SBCL.

> +                    (contrib-asdf "tools/asdf.lisp"))
> +               (delete-file contrib-asdf)

I think you don't need to delete the file, copy-file should overwrite.
That's what SBCL does.

Same with CLISP.

-- 
Pierre Neidhardt
https://ambrevar.xyz/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 511 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#45017: asdf-build-system packages have priority over user ones
  2020-12-03 14:29     ` Guillaume Le Vaillant
  2020-12-04  8:51       ` Pierre Neidhardt
@ 2020-12-05  9:17       ` Pierre Neidhardt
  2020-12-05 10:03         ` Guillaume Le Vaillant
  1 sibling, 1 reply; 17+ messages in thread
From: Pierre Neidhardt @ 2020-12-05  9:17 UTC (permalink / raw)
  To: Guillaume Le Vaillant; +Cc: 45017

[-- Attachment #1: Type: text/plain, Size: 2236 bytes --]

Tested!

I've installed sbcl to my "common-lisp" profile along quri.
I've also cloned quri to ~/common-lisp.

Then:

--8<---------------cut here---------------start------------->8---
$ sbcl
* (asdf:locate-system :quri)
T
NIL
#P"/gnu/store/5gj1inwiqpn2fm9w384zd0grpyadx96m-sbcl-quri-0.1.0-2.b53231c/share/common-lisp/sbcl/quri/quri.asd"
NIL
NIL
NIL

;; Indeed:
* (asdf:user-source-registry-directory)
#P"/gnu/store/75qppl3a062b138fkrn324qq8f912zqh-profile/etc/common-lisp/source-registry.conf.d/"
--8<---------------cut here---------------end--------------->8---

It does not work because the sbcl package definition sets the
XDG_CONFIG_DIRS native search path which is picked by
user-source-registry-directory, which has higher priority than
default-user-source-registry.

I think the flaw is ASDF's this time:

--8<---------------cut here---------------start------------->8---
  (defun user-source-registry-directory (&key (direction :input))
    (xdg-config-pathname *source-registry-directory* direction))

;...

  (defun xdg-config-pathnames (&rest more)
    "Return a list of pathnames for application configuration.
MORE may contain specifications for a subpath relative to these directories: a
subpathname specification and keyword arguments as per RESOLVE-LOCATION \(see
also \"Configuration DSL\"\) in the ASDF manual."
    (filter-pathname-set
     `(,(xdg-config-home more)
       ,@(xdg-config-dirs more))))
--8<---------------cut here---------------end--------------->8---

So the user registry looks into XDG_CONFIG_DIRS, while really it should
just look at XDG_CONFIG_HOME.

So this patch should do (untested):

--8<---------------cut here---------------start------------->8---
- (defun user-source-registry-directory (&key (direction :input))
-   (xdg-config-pathname *source-registry-directory* direction))
+ (defun user-source-registry-directory (&key (direction :input))
+   (find-preferred-file (list (xdg-config-home *source-registry-directory*)) :direction direction))
--8<---------------cut here---------------end--------------->8---

If you confirm, then we should also report upstream I think.

Cheers!

-- 
Pierre Neidhardt
https://ambrevar.xyz/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 511 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#45017: asdf-build-system packages have priority over user ones
  2020-12-05  8:18               ` Pierre Neidhardt
@ 2020-12-05  9:42                 ` Guillaume Le Vaillant
  0 siblings, 0 replies; 17+ messages in thread
From: Guillaume Le Vaillant @ 2020-12-05  9:42 UTC (permalink / raw)
  To: Pierre Neidhardt; +Cc: 45017

[-- Attachment #1: Type: text/plain, Size: 1774 bytes --]


Pierre Neidhardt <mail@ambrevar.xyz> skribis:

> A few comments:
>
>> @@ -603,7 +603,8 @@ statistical profiler, a code coverage tool, and many other extensions.")
>>                  "0x4bjx6cxsjvxyagijhlvmc7jkyxifdvz5q5zvz37028va65243c")
>>                 (_ "15l7cfa4a7jkfwdzsfm4q3n22jnb57imxahpql3h77xin57v1gbz"))))))))
>>      (native-inputs
>> -     `(("m4" ,m4)))
>> +     `(("cl-asdf" ,cl-asdf)
>> +       ("m4" ,m4)))
>>      (arguments
>>       `(#:tests? #f                      ;no 'check' target
>>         #:modules ((ice-9 match)
>> @@ -615,6 +616,17 @@ statistical profiler, a code coverage tool, and many other extensions.")
>>           (add-after 'unpack 'unpack-image
>>             (lambda* (#:key inputs #:allow-other-keys)
>>               (invoke "tar" "xzvf" (assoc-ref inputs "ccl-bootstrap"))))
>> +         (add-after 'unpack 'replace-asdf
>> +           ;; Use system ASDF instead of bundled one.
>> +           (lambda* (#:key inputs outputs #:allow-other-keys)
>> +             (let* ((cl-asdf (assoc-ref inputs "cl-asdf"))
>> +                    (guix-asdf (string-append
>> +                                cl-asdf
>> +                                "/share/common-lisp/source/asdf/asdf.lisp"))
>> +                    (out (string-append (assoc-ref outputs "out")))
>
> "out" is unused.  By the way, the same "out" is unused in SBCL.
>

Indeed, I'll fix that.

>> +                    (contrib-asdf "tools/asdf.lisp"))
>> +               (delete-file contrib-asdf)
>
> I think you don't need to delete the file, copy-file should overwrite.
> That's what SBCL does.
>
> Same with CLISP.

Actually, for CCL and Clisp, I get a "In procedure copy-file: Permission
denied" error if I don't delete the current file before copying the new
one.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#45017: asdf-build-system packages have priority over user ones
  2020-12-05  9:17       ` Pierre Neidhardt
@ 2020-12-05 10:03         ` Guillaume Le Vaillant
  2020-12-05 10:52           ` Guillaume Le Vaillant
  0 siblings, 1 reply; 17+ messages in thread
From: Guillaume Le Vaillant @ 2020-12-05 10:03 UTC (permalink / raw)
  To: Pierre Neidhardt; +Cc: 45017

[-- Attachment #1: Type: text/plain, Size: 2836 bytes --]


Pierre Neidhardt <mail@ambrevar.xyz> skribis:

> Tested!
>
> I've installed sbcl to my "common-lisp" profile along quri.
> I've also cloned quri to ~/common-lisp.
>
> Then:
>
> --8<---------------cut here---------------start------------->8---
> $ sbcl
> * (asdf:locate-system :quri)
> T
> NIL
> #P"/gnu/store/5gj1inwiqpn2fm9w384zd0grpyadx96m-sbcl-quri-0.1.0-2.b53231c/share/common-lisp/sbcl/quri/quri.asd"
> NIL
> NIL
> NIL
>
> ;; Indeed:
> * (asdf:user-source-registry-directory)
> #P"/gnu/store/75qppl3a062b138fkrn324qq8f912zqh-profile/etc/common-lisp/source-registry.conf.d/"
> --8<---------------cut here---------------end--------------->8---
>
> It does not work because the sbcl package definition sets the
> XDG_CONFIG_DIRS native search path which is picked by
> user-source-registry-directory, which has higher priority than
> default-user-source-registry.
>
> I think the flaw is ASDF's this time:
>
> --8<---------------cut here---------------start------------->8---
>   (defun user-source-registry-directory (&key (direction :input))
>     (xdg-config-pathname *source-registry-directory* direction))
>
> ;...
>
>   (defun xdg-config-pathnames (&rest more)
>     "Return a list of pathnames for application configuration.
> MORE may contain specifications for a subpath relative to these directories: a
> subpathname specification and keyword arguments as per RESOLVE-LOCATION \(see
> also \"Configuration DSL\"\) in the ASDF manual."
>     (filter-pathname-set
>      `(,(xdg-config-home more)
>        ,@(xdg-config-dirs more))))
> --8<---------------cut here---------------end--------------->8---
>
> So the user registry looks into XDG_CONFIG_DIRS, while really it should
> just look at XDG_CONFIG_HOME.
>

The same test works for me. I think it's because I have
a ".config/common-lisp/source-registry.conf.d" directory (even if it's
empty), and '(user-source-registry-directory)' returns it instead of the
first directory in XDG_CONFIG_DIRS.

> So this patch should do (untested):
>
> --8<---------------cut here---------------start------------->8---
> - (defun user-source-registry-directory (&key (direction :input))
> -   (xdg-config-pathname *source-registry-directory* direction))
> + (defun user-source-registry-directory (&key (direction :input))
> +   (find-preferred-file (list (xdg-config-home *source-registry-directory*)) :direction direction))
> --8<---------------cut here---------------end--------------->8---
>
> If you confirm, then we should also report upstream I think.
>
> Cheers!

I don't know if the fact that ASDF can give priority to XDG_CONFIG_DIRS
over "~/common-lisp" is a feature or a bug, so you could ask upstream.
Anyway in our case, your patch makes sense since we always want to give
priority to "~/common-lisp" and other usual user directories. I'll add
it to our patch for cl-asdf.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#45017: asdf-build-system packages have priority over user ones
  2020-12-05 10:03         ` Guillaume Le Vaillant
@ 2020-12-05 10:52           ` Guillaume Le Vaillant
  2020-12-05 14:42             ` Pierre Neidhardt
  0 siblings, 1 reply; 17+ messages in thread
From: Guillaume Le Vaillant @ 2020-12-05 10:52 UTC (permalink / raw)
  To: Pierre Neidhardt; +Cc: 45017


[-- Attachment #1.1: Type: text/plain, Size: 77 bytes --]


Updated patches in attachment.
Do you see something else to fix or improve?

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-gnu-cl-asdf-Improve-priorities-of-configuration-file.patch --]
[-- Type: text/x-patch, Size: 6467 bytes --]

From 757b4f4a84fdbcbd26148f2a170d84ba8c128c7a Mon Sep 17 00:00:00 2001
From: Guillaume Le Vaillant <glv@posteo.net>
Date: Thu, 3 Dec 2020 14:52:02 +0100
Subject: [PATCH 1/6] gnu: cl-asdf: Improve priorities of configuration file
 search.

* gnu/packages/patches/cl-asdf-config-directories.patch: New file.
* gnu/local.mk (dist_PATCH_DATA): Add it.
* gnu/packages/lisp.scm (cl-asdf)[native-inputs]: Add it.
  [arguments]: Apply the new patch.

Co-authored-by: Pierre Neidhardt <mail@ambrevar.xyz>
---
 gnu/local.mk                                  |  1 +
 gnu/packages/lisp.scm                         | 28 ++++--------
 .../patches/cl-asdf-config-directories.patch  | 44 +++++++++++++++++++
 3 files changed, 53 insertions(+), 20 deletions(-)
 create mode 100644 gnu/packages/patches/cl-asdf-config-directories.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 28ad119846..f838ebe1fa 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -868,6 +868,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/cdrtools-3.01-mkisofs-isoinfo.patch 	\
   %D%/packages/patches/ceph-disable-cpu-optimizations.patch	\
   %D%/packages/patches/chmlib-inttypes.patch			\
+  %D%/packages/patches/cl-asdf-config-directories.patch		\
   %D%/packages/patches/clamav-config-llvm-libs.patch		\
   %D%/packages/patches/clamav-system-tomsfastmath.patch		\
   %D%/packages/patches/clang-3.5-libc-search-path.patch		\
diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm
index e4c963070e..0038cb0dca 100644
--- a/gnu/packages/lisp.scm
+++ b/gnu/packages/lisp.scm
@@ -90,6 +90,9 @@
        (sha256
         (base32 "1hpx30f6yrak15nw992k7x3pn75ahvjs04n4f134k68mhgs62km2"))))
     (build-system trivial-build-system)
+    (native-inputs
+     `(("config-patch" ,@(search-patches "cl-asdf-config-directories.patch"))
+       ("patch" ,patch)))
     (arguments
      `(#:modules ((guix build utils)
                   (guix build lisp-utils))
@@ -101,28 +104,13 @@
                 (asdf-install (string-append out %source-install-prefix
                                              "/source/asdf/"))
                 (src-asdf (string-append (assoc-ref %build-inputs "source")))
-                (dst-asdf (string-append asdf-install "asdf.lisp")))
+                (dst-asdf (string-append asdf-install "asdf.lisp"))
+                (patch (string-append (assoc-ref %build-inputs "patch")
+                                      "/bin/patch"))
+                (config-patch (assoc-ref %build-inputs "config-patch")))
            (mkdir-p asdf-install)
            (copy-file src-asdf dst-asdf)
-           ;; Patch ASDF to make it read the configuration files in all
-           ;; the direcories listed in '$XDG_CONFIG_DIRS' instead of just
-           ;; the first.
-           (substitute* dst-asdf
-             (("\\(xdg-config-pathname \\*source-registry-directory\\* direction\\)")
-              "`(:source-registry
-                 ,@(loop
-                      for dir in (xdg-config-dirs
-                                  \"common-lisp/source-registry.conf.d/\")
-                      collect `(:include ,dir))
-                 :inherit-configuration)")
-             (("\\(xdg-config-pathname \\*output-translations-directory\\* direction\\)")
-              "`(:output-translations
-                 ,@(loop
-                      for dir in (xdg-config-dirs
-                                  \"common-lisp/asdf-output-translations.conf.d/\")
-                      collect `(:include ,dir))
-                 :inherit-configuration)")))
-         #t)))
+           (invoke patch "-p1" "-i" config-patch dst-asdf)))))
     (home-page "https://common-lisp.net/project/asdf/")
     (synopsis "Another System Definition Facility")
     (description
diff --git a/gnu/packages/patches/cl-asdf-config-directories.patch b/gnu/packages/patches/cl-asdf-config-directories.patch
new file mode 100644
index 0000000000..2b1b51932c
--- /dev/null
+++ b/gnu/packages/patches/cl-asdf-config-directories.patch
@@ -0,0 +1,44 @@
+Search for ASDF configuration files first in user directories, and then in
+Guix profiles.
+
+diff -ru a/asdf-3.3.4.lisp b/asdf-3.3.4.lisp
+--- a/asdf-3.3.4.lisp	2020-02-14 20:16:22.000000000 +0100
++++ b/asdf-3.3.4.lisp	2020-12-05 11:09:56.066229482 +0100
+@@ -12535,10 +12535,15 @@
+     (find-preferred-file (system-config-pathnames *output-translations-file*)
+                          :direction direction))
+   (defun user-output-translations-directory-pathname (&key (direction :input))
+-    (xdg-config-pathname *output-translations-directory* direction))
+-  (defun system-output-translations-directory-pathname (&key (direction :input))
+-    (find-preferred-file (system-config-pathnames *output-translations-directory*)
++    (find-preferred-file (list (xdg-config-home *output-translations-directory*))
+                          :direction direction))
++  (defun system-output-translations-directory-pathname (&key (direction :input))
++    `(:output-translations
++      ,@(loop :for dir :in (filter-pathname-set
++                            (xdg-config-dirs
++                             "common-lisp/asdf-output-translations.conf.d/"))
++              :collect `(:include ,dir))
++      :inherit-configuration))
+   (defun environment-output-translations ()
+     (getenv "ASDF_OUTPUT_TRANSLATIONS"))
+ 
+@@ -12921,10 +12926,15 @@
+     (find-preferred-file (system-config-pathnames *source-registry-file*)
+                          :direction direction))
+   (defun user-source-registry-directory (&key (direction :input))
+-    (xdg-config-pathname *source-registry-directory* direction))
+-  (defun system-source-registry-directory (&key (direction :input))
+-    (find-preferred-file (system-config-pathnames *source-registry-directory*)
++    (find-preferred-file (list (xdg-config-home *source-registry-directory*))
+                          :direction direction))
++  (defun system-source-registry-directory (&key (direction :input))
++    `(:source-registry
++      ,@(loop :for dir :in (filter-pathname-set
++                            (xdg-config-dirs
++                             "common-lisp/source-registry.conf.d/"))
++              :collect `(:include ,dir))
++      :inherit-configuration))
+   (defun environment-source-registry ()
+     (getenv "CL_SOURCE_REGISTRY"))
+ 
-- 
2.29.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.3: 0002-gnu-ccl-Use-system-ASDF-instead-of-bundled-one.patch --]
[-- Type: text/x-patch, Size: 2739 bytes --]

From 53a63ff01929f4afe0d841ee9f4a09a5514b0ca8 Mon Sep 17 00:00:00 2001
From: Guillaume Le Vaillant <glv@posteo.net>
Date: Fri, 4 Dec 2020 10:29:34 +0100
Subject: [PATCH 2/6] gnu: ccl: Use system ASDF instead of bundled one.

* gnu/packages/lisp.scm (ccl)[native-inputs]: Add cl-asdf.
  [arguments]: Add 'replace-asdf' phase.
  [native-search-paths]: Add XDG_CONFIG_DIRS and XDG_DATA_DIRS.
---
 gnu/packages/lisp.scm | 20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm
index 0038cb0dca..a4cbc28ffc 100644
--- a/gnu/packages/lisp.scm
+++ b/gnu/packages/lisp.scm
@@ -603,7 +603,8 @@ statistical profiler, a code coverage tool, and many other extensions.")
                 "0x4bjx6cxsjvxyagijhlvmc7jkyxifdvz5q5zvz37028va65243c")
                (_ "15l7cfa4a7jkfwdzsfm4q3n22jnb57imxahpql3h77xin57v1gbz"))))))))
     (native-inputs
-     `(("m4" ,m4)))
+     `(("cl-asdf" ,cl-asdf)
+       ("m4" ,m4)))
     (arguments
      `(#:tests? #f                      ;no 'check' target
        #:modules ((ice-9 match)
@@ -615,6 +616,16 @@ statistical profiler, a code coverage tool, and many other extensions.")
          (add-after 'unpack 'unpack-image
            (lambda* (#:key inputs #:allow-other-keys)
              (invoke "tar" "xzvf" (assoc-ref inputs "ccl-bootstrap"))))
+         (add-after 'unpack 'replace-asdf
+           ;; Use system ASDF instead of bundled one.
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let* ((cl-asdf (assoc-ref inputs "cl-asdf"))
+                    (guix-asdf (string-append
+                                cl-asdf
+                                "/share/common-lisp/source/asdf/asdf.lisp"))
+                    (contrib-asdf "tools/asdf.lisp"))
+               (delete-file contrib-asdf)
+               (copy-file guix-asdf contrib-asdf))))
          (delete 'configure)
          (add-before 'build 'pre-build
            ;; Enter the source directory for the current platform's lisp
@@ -678,6 +689,13 @@ statistical profiler, a code coverage tool, and many other extensions.")
                      "exec -a \"$0\" " libdir kernel " \"$@\"\n"))))
                (chmod wrapper #o755))
              #t)))))
+    (native-search-paths
+     (list (search-path-specification
+            (variable "XDG_DATA_DIRS")
+            (files '("share")))
+           (search-path-specification
+            (variable "XDG_CONFIG_DIRS")
+            (files '("etc")))))
     (supported-systems '("i686-linux" "x86_64-linux" "armhf-linux"))
     (home-page "https://ccl.clozure.com/")
     (synopsis "Common Lisp implementation")
-- 
2.29.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.4: 0003-gnu-clisp-Use-system-ASDF-instead-of-bundled-one.patch --]
[-- Type: text/x-patch, Size: 2273 bytes --]

From a855535add82bf0ba4cacf84a526be38f8230440 Mon Sep 17 00:00:00 2001
From: Guillaume Le Vaillant <glv@posteo.net>
Date: Fri, 4 Dec 2020 10:48:41 +0100
Subject: [PATCH 3/6] gnu: clisp: Use system ASDF instead of bundled one.

* gnu/packages/lisp.scm (clisp)[native-inputs]: Add cl-asdf.
  [arguments]: Add 'replace-asdf' phase.
  [native-search-paths]: Add XDG_CONFIG_DIRS and XDG_DATA_DIRS.
---
 gnu/packages/lisp.scm | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm
index a4cbc28ffc..2ec4da8fbb 100644
--- a/gnu/packages/lisp.scm
+++ b/gnu/packages/lisp.scm
@@ -322,6 +322,8 @@ supporting ASDF, Sockets, Gray streams, MOP, and other useful components.")
        (sha256
         (base32 "0k2dmgl0miz3767iks4p0mvp6xw0ysyxhjpklyh11j010rmh6hqb"))))
     (build-system gnu-build-system)
+    (native-inputs
+     `(("cl-asdf" ,cl-asdf)))
     (inputs `(("libffcall" ,libffcall)
               ("ncurses" ,ncurses)
               ("readline" ,readline)
@@ -356,7 +358,24 @@ supporting ASDF, Sockets, Gray streams, MOP, and other useful components.")
                (("/bin/sh") "sh"))
              (substitute* '("src/clisp-link.in")
                (("/bin/pwd") "pwd"))
-             #t)))))
+             #t))
+         (add-after 'unpack 'replace-asdf
+           ;; Use system ASDF instead of bundled one.
+           (lambda* (#:key inputs #:allow-other-keys)
+             (let* ((cl-asdf (assoc-ref inputs "cl-asdf"))
+                    (guix-asdf (string-append
+                                cl-asdf
+                                "/share/common-lisp/source/asdf/asdf.lisp"))
+                    (contrib-asdf "modules/asdf/asdf.lisp"))
+               (delete-file contrib-asdf)
+               (copy-file guix-asdf contrib-asdf)))))))
+    (native-search-paths
+     (list (search-path-specification
+            (variable "XDG_DATA_DIRS")
+            (files '("share")))
+           (search-path-specification
+            (variable "XDG_CONFIG_DIRS")
+            (files '("etc")))))
     (home-page "https://clisp.sourceforge.io/")
     (synopsis "A Common Lisp implementation")
     (description
-- 
2.29.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.5: 0004-gnu-ecl-Simplify-replace-asdf-phase.patch --]
[-- Type: text/x-patch, Size: 1322 bytes --]

From 5b3ae58f494a1728143b85abb5ef5655f04499d7 Mon Sep 17 00:00:00 2001
From: Guillaume Le Vaillant <glv@posteo.net>
Date: Sat, 5 Dec 2020 10:11:38 +0100
Subject: [PATCH 4/6] gnu: ecl: Simplify 'replace-asdf' phase.

* gnu/packages/lisp.scm (ecl)[arguments]: Remove unused 'out' variable in
  'replace-asdf' phase.
---
 gnu/packages/lisp.scm | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm
index 2ec4da8fbb..a540174c88 100644
--- a/gnu/packages/lisp.scm
+++ b/gnu/packages/lisp.scm
@@ -250,12 +250,11 @@ interface to the Tk widget system.")
          (delete 'check)
          (add-after 'unpack 'replace-asdf
            ;; Use system ASDF instead of bundled one.
-           (lambda* (#:key inputs outputs #:allow-other-keys)
+           (lambda* (#:key inputs #:allow-other-keys)
              (let* ((cl-asdf (assoc-ref inputs "cl-asdf"))
                     (guix-asdf (string-append
                                 cl-asdf
                                 "/share/common-lisp/source/asdf/asdf.lisp"))
-                    (out (string-append (assoc-ref outputs "out")))
                     (contrib-asdf "contrib/asdf/asdf.lisp"))
                (copy-file guix-asdf contrib-asdf))
              #t))
-- 
2.29.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.6: 0005-gnu-sbcl-Simplify-replace-asdf-phase.patch --]
[-- Type: text/x-patch, Size: 1423 bytes --]

From 466d7cdbee216df3fa298196228e265d9431dcfa Mon Sep 17 00:00:00 2001
From: Guillaume Le Vaillant <glv@posteo.net>
Date: Sat, 5 Dec 2020 10:22:42 +0100
Subject: [PATCH 5/6] gnu: sbcl: Simplify 'replace-asdf' phase.

* gnu/packages/lisp.scm (sbcl)[arguments]: Remove unused 'out' variable in
  'replace-asdf' phase.
---
 gnu/packages/lisp.scm | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/gnu/packages/lisp.scm b/gnu/packages/lisp.scm
index a540174c88..3d446290a7 100644
--- a/gnu/packages/lisp.scm
+++ b/gnu/packages/lisp.scm
@@ -444,12 +444,11 @@ an interpreter, a compiler, a debugger, and much more.")
            ;; of ASDF we use to build software; therefore, replace the contrib
            ;; ASDF with the version packaged into Guix.
            ;; [1] - https://bugs.launchpad.net/sbcl/+bug/1823442
-           (lambda* (#:key inputs outputs #:allow-other-keys)
+           (lambda* (#:key inputs #:allow-other-keys)
              (let* ((cl-asdf (assoc-ref inputs "cl-asdf"))
                     (guix-asdf (string-append
                                 cl-asdf
                                 "/share/common-lisp/source/asdf/asdf.lisp"))
-                    (out (string-append (assoc-ref outputs "out")))
                     (contrib-asdf "contrib/asdf/asdf.lisp"))
                (copy-file guix-asdf contrib-asdf))
              #t))
-- 
2.29.2


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply related	[flat|nested] 17+ messages in thread

* bug#45017: asdf-build-system packages have priority over user ones
  2020-12-05 10:52           ` Guillaume Le Vaillant
@ 2020-12-05 14:42             ` Pierre Neidhardt
  2020-12-05 15:17               ` Guillaume Le Vaillant
  0 siblings, 1 reply; 17+ messages in thread
From: Pierre Neidhardt @ 2020-12-05 14:42 UTC (permalink / raw)
  To: Guillaume Le Vaillant; +Cc: 45017

[-- Attachment #1: Type: text/plain, Size: 353 bytes --]

Guillaume Le Vaillant <glv@posteo.net> writes:

> Updated patches in attachment.
> Do you see something else to fix or improve?

Tested and approved!

I suggest we merge on master since this is not very disruptive and it
fixes a regression introduced with the build system overhaul.

Thoughts?

-- 
Pierre Neidhardt
https://ambrevar.xyz/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 511 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#45017: asdf-build-system packages have priority over user ones
  2020-12-05 14:42             ` Pierre Neidhardt
@ 2020-12-05 15:17               ` Guillaume Le Vaillant
  2020-12-05 15:19                 ` Pierre Neidhardt
  0 siblings, 1 reply; 17+ messages in thread
From: Guillaume Le Vaillant @ 2020-12-05 15:17 UTC (permalink / raw)
  To: Pierre Neidhardt; +Cc: 45017-done

[-- Attachment #1: Type: text/plain, Size: 448 bytes --]


Pierre Neidhardt <mail@ambrevar.xyz> skribis:

> Guillaume Le Vaillant <glv@posteo.net> writes:
>
>> Updated patches in attachment.
>> Do you see something else to fix or improve?
>
> Tested and approved!
>
> I suggest we merge on master since this is not very disruptive and it
> fixes a regression introduced with the build system overhaul.
>
> Thoughts?

Thanks for the review. Pushed as
031fbebafef81244a72e584a46b3fcc219256fcb and following.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 247 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

* bug#45017: asdf-build-system packages have priority over user ones
  2020-12-05 15:17               ` Guillaume Le Vaillant
@ 2020-12-05 15:19                 ` Pierre Neidhardt
  0 siblings, 0 replies; 17+ messages in thread
From: Pierre Neidhardt @ 2020-12-05 15:19 UTC (permalink / raw)
  To: Guillaume Le Vaillant; +Cc: 45017-done

[-- Attachment #1: Type: text/plain, Size: 63 bytes --]

Thanks a lot!

-- 
Pierre Neidhardt
https://ambrevar.xyz/

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 511 bytes --]

^ permalink raw reply	[flat|nested] 17+ messages in thread

end of thread, other threads:[~2020-12-05 15:20 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-03  9:42 bug#45017: asdf-build-system packages have priority over user ones Pierre Neidhardt
2020-12-03 12:04 ` Guillaume Le Vaillant
2020-12-03 12:40   ` Pierre Neidhardt
2020-12-03 14:29     ` Guillaume Le Vaillant
2020-12-04  8:51       ` Pierre Neidhardt
2020-12-04  9:12         ` Guillaume Le Vaillant
2020-12-04 12:46           ` Pierre Neidhardt
2020-12-04 13:53             ` Guillaume Le Vaillant
2020-12-04 17:30               ` Guillaume Le Vaillant
2020-12-05  8:18               ` Pierre Neidhardt
2020-12-05  9:42                 ` Guillaume Le Vaillant
2020-12-05  9:17       ` Pierre Neidhardt
2020-12-05 10:03         ` Guillaume Le Vaillant
2020-12-05 10:52           ` Guillaume Le Vaillant
2020-12-05 14:42             ` Pierre Neidhardt
2020-12-05 15:17               ` Guillaume Le Vaillant
2020-12-05 15:19                 ` Pierre Neidhardt

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).