bug#45017: asdf-build-system packages have priority over user ones

2020-12-05 Thread Guillaume Le Vaillant

Pierre Neidhardt  skribis:

> Guillaume Le Vaillant  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.


signature.asc
Description: PGP signature


bug#45017: asdf-build-system packages have priority over user ones

2020-12-05 Thread Guillaume Le Vaillant

Updated patches in attachment.
Do you see something else to fix or improve?
From 757b4f4a84fdbcbd26148f2a170d84ba8c128c7a Mon Sep 17 00:00:00 2001
From: Guillaume Le Vaillant 
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 
---
 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 00..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.0 +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 ( (direction :input))
+-(xdg-config-pathname *output-translations-directory* direction))
+-  (defun system-output-translations-directory-pathname ( (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 ( (direction :input))
++

bug#45017: asdf-build-system packages have priority over user ones

2020-12-05 Thread Guillaume Le Vaillant

Pierre Neidhardt  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 ( (direction :input))
> (xdg-config-pathname *source-registry-directory* direction))
>
> ;...
>
>   (defun xdg-config-pathnames ( 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 ( (direction :input))
> -   (xdg-config-pathname *source-registry-directory* direction))
> + (defun user-source-registry-directory ( (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.


signature.asc
Description: PGP signature


bug#45017: asdf-build-system packages have priority over user ones

2020-12-05 Thread Guillaume Le Vaillant

Pierre Neidhardt  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.


signature.asc
Description: PGP signature


bug#45017: asdf-build-system packages have priority over user ones

2020-12-04 Thread Guillaume Le Vaillant

Guillaume Le Vaillant  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/...".


signature.asc
Description: PGP signature


bug#45017: asdf-build-system packages have priority over user ones

2020-12-04 Thread Guillaume Le Vaillant

Pierre Neidhardt  skribis:

> Guillaume Le Vaillant  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
> #:
>   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.
From 5ce14232fafef61fdd5f9412c50dbfbb90f0d03e Mon Sep 17 00:00:00 2001
From: Guillaume Le Vaillant 
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")))
+   

bug#45017: asdf-build-system packages have priority over user ones

2020-12-04 Thread Pierre Neidhardt
Guillaume Le Vaillant  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
#:
  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/


signature.asc
Description: PGP signature


bug#45017: asdf-build-system packages have priority over user ones

2020-12-04 Thread Guillaume Le Vaillant

Pierre Neidhardt  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.


signature.asc
Description: PGP signature


bug#45017: asdf-build-system packages have priority over user ones

2020-12-03 Thread Guillaume Le Vaillant

Pierre Neidhardt  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?
From cb8d52ec606bb8984622f6b117346b4772bf0d16 Mon Sep 17 00:00:00 2001
From: Guillaume Le Vaillant 
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 00..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.0 +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 ( (direction :input))
+ (xdg-config-pathname *output-translations-directory* direction))
+   (defun system-output-translations-directory-pathname ( (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
++ 

bug#45017: asdf-build-system packages have priority over user ones

2020-12-03 Thread Guillaume Le Vaillant

Pierre Neidhardt  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?


signature.asc
Description: PGP signature


bug#45017: asdf-build-system packages have priority over user ones

2020-12-03 Thread Pierre Neidhardt
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/


signature.asc
Description: PGP signature