“guix environment -l” does not work with inferior packages

OpenSubmitted by Ricardo Wurmus.
Details
4 participants
  • Brice Waegeneire
  • Ludovic Courtès
  • Ricardo Wurmus
  • zimoun
Owner
unassigned
Severity
important
R
R
Ricardo Wurmus wrote on 28 Apr 2021 18:19
(address . bug-guix@gnu.org)
878s52nzzg.fsf@elephly.net
I wanted to use an environment file that contains a package
definition, and use it with inferiors. Here is the full guix.scm:

Toggle snippet (71 lines)
(use-modules
(guix channels)
(guix inferior)
(guix build-system gnu)
(guix packages)
(guix licenses)
(gnu packages)
(ice-9 match))

(define channels
(list (channel
(name 'guix-bimsb)
(url "https://github.com/BIMSBbioinfo/guix-bimsb.git")
(commit
"be42b099867a29a68a9ffbf304dc7f9137b75fe3"))
(channel
(name 'guix)
(url "https://git.savannah.gnu.org/git/guix.git")
(commit
"01e33a031e493477d930b9383d397fea012a3b1a")
(introduction
(make-channel-introduction
"9edb3f66fd807b096b48283debdcddccfea34bad"
(openpgp-fingerprint
"BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A
54FA"))))))

(define (lookup name)
(specification->package name))

(define (lookup-inferior name)
(define inferior
(inferior-for-channels channels))
(match (lookup-inferior-packages inferior name)
((first . rest) first)
(_ (error
(format #false "Could not find package `~a'.~%" name)))))

(define (p name)
(let* ((how (if (getenv "USE_GUIX_INFERIOR")
lookup-inferior lookup))
(pkg (how name)))
`(,name ,pkg)))

(define %version
(symbol->string (with-input-from-file "VERSION" read)))

(define-public my-package
(package
(name "my-package")
(version %version)
(source
(string-append (getcwd) "/my-package-" version ".tar.gz"))
(build-system gnu-build-system)
(inputs
(map p (list "bwa"
"r-minimal"
"r-rmarkdown"
"python-wrapper"
"python-pyyaml")))
(native-inputs
(map p (list "autoconf"
"automake")))
(home-page "TODO")
(synopsis "TODO")
(description "TODO")
(license gpl3+)))

my-package

The idea was that you would use the provided channels with

USE_GUIX_INFERIOR=t guix environment -l guix.scm

Unfortunately, this does not work, but there also is no error. I
end up in an environment where none of the declared inputs are
available. That’s because (guix scripts environments) has no
facilities to deal with packages that are of type
<inferior-package>.

--
Ricardo
L
L
Ludovic Courtès wrote on 28 Apr 2021 22:47
control message for bug #48082
(address . control@debbugs.gnu.org)
87o8dyqgq1.fsf@gnu.org
severity 48082 important
quit
B
B
Brice Waegeneire wrote on 1 Aug 2021 16:13
Re: bug#48082: “guix environment -l ” does not work with inferior packages
(name . Ricardo Wurmus)(address . rekado@elephly.net)(address . 48082@debbugs.gnu.org)
87mtq1i77q.fsf@waegenei.re
Hello Ricardo,

Ricardo Wurmus <rekado@elephly.net> writes:

Toggle quote (15 lines)
> I wanted to use an environment file that contains a package
> definition, and use it with inferiors. Here is the full guix.scm:
>
> [...]
>
> The idea was that you would use the provided channels with
>
> USE_GUIX_INFERIOR=t guix environment -l guix.scm
>
> Unfortunately, this does not work, but there also is no error. I
> end up in an environment where none of the declared inputs are
> available. That’s because (guix scripts environments) has no
> facilities to deal with packages that are of type
> <inferior-package>.

Unfortunatly the environment file isn't self contained (VERSION and the
package source are missing), so I couldn't reproduce your issue.

I wanted to reproduce it since I think it may be a duplicate of #40272¹,
that is you can't build packages with inputs containing inferior-packages.


Cheers,
- Brice
R
R
Ricardo Wurmus wrote on 1 Aug 2021 18:07
(name . Brice Waegeneire)(address . brice@waegenei.re)(address . 48082@debbugs.gnu.org)
87pmux5esk.fsf@elephly.net
Brice Waegeneire <brice@waegenei.re> writes:

Toggle quote (25 lines)
> Hello Ricardo,
>
> Ricardo Wurmus <rekado@elephly.net> writes:
>
>> I wanted to use an environment file that contains a package
>> definition, and use it with inferiors. Here is the full
>> guix.scm:
>>
>> [...]
>>
>> The idea was that you would use the provided channels with
>>
>> USE_GUIX_INFERIOR=t guix environment -l guix.scm
>>
>> Unfortunately, this does not work, but there also is no error.
>> I
>> end up in an environment where none of the declared inputs are
>> available. That’s because (guix scripts environments) has no
>> facilities to deal with packages that are of type
>> <inferior-package>.
>
> Unfortunatly the environment file isn't self contained (VERSION
> and the
> package source are missing), so I couldn't reproduce your issue.

B
B
Brice Waegeneire wrote on 1 Aug 2021 23:12
[PATCH] environment: Add support for <inferior-package>.
(address . rekado@elephly.net)(address . 48082@debbugs.gnu.org)
20210801211213.7800-1-brice@waegenei.re

* guix/scripts/environment.scm (input->manifest-entry): Add support for
<inferior-package>.
---
guix/scripts/environment.scm | 6 ++++++
1 file changed, 6 insertions(+)

Ricardo, thank you for the links, I managed to reproduce the issue. And fixed
it with the help of Ludovic on IRC.

Toggle diff (33 lines)
diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
index 6958bd6238..c464e7cfb3 100644
--- a/guix/scripts/environment.scm
+++ b/guix/scripts/environment.scm
@@ -2,6 +2,7 @@
 ;;; Copyright © 2014, 2015, 2018 David Thompson <davet@gnu.org>
 ;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
 ;;; Copyright © 2018 Mike Gerwitz <mtg@gnu.org>
+;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -28,6 +29,7 @@
   #:use-module (guix packages)
   #:use-module (guix profiles)
   #:use-module (guix search-paths)
+  #:use-module (guix inferior)
   #:use-module (guix build utils)
   #:use-module (guix monads)
   #:use-module ((guix gexp) #:select (lower-object))
@@ -74,6 +76,10 @@ package."
      (package->manifest-entry package))
     ((_ (? package? package) output)
      (package->manifest-entry package output))
+    ((_ (? inferior-package? package))
+     (inferior-package->manifest-entry package))
+    ((_ (? inferior-package? package) output)
+     (inferior-package->manifest-entry package output))
     (_
      #f)))
 
-- 
2.32.0
Z
Z
zimoun wrote on 17 Aug 2021 12:01
(address . 48082@debbugs.gnu.org)
86wnokcrum.fsf@gmail.com
Hi Brice,

Thanks for the fix. :-)

On Sun, 01 Aug 2021 at 23:12, Brice Waegeneire <brice@waegenei.re> wrote:

Toggle quote (2 lines)
Usually, the commit message is:



Toggle quote (40 lines)
> * guix/scripts/environment.scm (input->manifest-entry): Add support for
> <inferior-package>.
> ---
> guix/scripts/environment.scm | 6 ++++++
> 1 file changed, 6 insertions(+)
>
> Ricardo, thank you for the links, I managed to reproduce the issue. And fixed
> it with the help of Ludovic on IRC.
>
> diff --git a/guix/scripts/environment.scm b/guix/scripts/environment.scm
> index 6958bd6238..c464e7cfb3 100644
> --- a/guix/scripts/environment.scm
> +++ b/guix/scripts/environment.scm
> @@ -2,6 +2,7 @@
> ;;; Copyright © 2014, 2015, 2018 David Thompson <davet@gnu.org>
> ;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès <ludo@gnu.org>
> ;;; Copyright © 2018 Mike Gerwitz <mtg@gnu.org>
> +;;; Copyright © 2021 Brice Waegeneire <brice@waegenei.re>
> ;;;
> ;;; This file is part of GNU Guix.
> ;;;
> @@ -28,6 +29,7 @@
> #:use-module (guix packages)
> #:use-module (guix profiles)
> #:use-module (guix search-paths)
> + #:use-module (guix inferior)
> #:use-module (guix build utils)
> #:use-module (guix monads)
> #:use-module ((guix gexp) #:select (lower-object))
> @@ -74,6 +76,10 @@ package."
> (package->manifest-entry package))
> ((_ (? package? package) output)
> (package->manifest-entry package output))
> + ((_ (? inferior-package? package))
> + (inferior-package->manifest-entry package))
> + ((_ (? inferior-package? package) output)
> + (inferior-package->manifest-entry package output))
> (_
> #f)))

LGTM.


All the best,
simon
?