guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: --with-source version not honored?


From: Phil Beadling
Subject: Re: --with-source version not honored?
Date: Sun, 24 Oct 2021 13:11:13 +0100

I was able to write a short manifest that avoided the overwriting of the original "foobarpy" package in my case, and instead cleanly replace it with a newer version specified using "with-source".

By setting, for example, GUIX_FOOBAR_VERSION=1.23 and GUIX_TEST_PACKAGE=my-package - I can now create an environment which builds the version of foobarpy I want from an https link generated from GUIX_FOOBAR_VERSION, and then create a modified version of "my-package" with foobarpy replaced, rather than overwritten.

This is much better than my original hack, but it's still not recursive so whilst it does rebuild my-package with the new version of foobarpy as a propagated input, it isn't rebuilding the whole dependency tree - other inputs to my-package could also depend on foobarpy, and should be rebuilt too - so what I've done is more of a graft, buthappens to be good enough for my specific use case (the foobarpy is not used anywhere else in my case).

Anyway thought I'd share this here as a template for simple non-recursive cases.  I suspect it's not a massive effort to make it recursive, when I have a moment I'll have a think about that too.  Any thoughts on how to improve are welcome!

 (use-modules (guix transformations) ;; options->transformation
              (guix packages) ;; package/inherit
              (srfi srfi-1) ;; fold
              (srfi srfi-98)) ;; get-environment-variable


 (define (generate-foobar-link version)
   (string-append "https://packages.foobar.com/"
                  (substring version 0 3) "/foobar"
                  version "_linux64.tar.gz"))

 (define transform
   ;; The package transformation procedure.
   (let* ((foobar-version (get-environment-variable "GUIX_FOOBAR_VERSION"))
          (foobar-link (string-append
                        "foobarpy@" foobar-version
                        "=" (generate-foobar-link foobar-version))))
     (format #t "~%Setting Foobar Version: ~a~%" foobar-version)
     (options->transformation
      `((with-source . ,foobar-link)))))

 (define my-foobar-package (transform (specification->package "foobarpy")))

 (define-public my-package-with-my-foobar
   (let* ((test-package-string (get-environment-variable "GUIX_TEST_PACKAGE"))
          (test-package (specification->package test-package-string)))
     (package/inherit test-package
       (propagated-inputs
        `(("foobarpy" ,my-foobar-package)
          ,@(fold alist-delete (package-propagated-inputs test-package) '("foobarpy")))))))

 (packages->manifest (list my-package-with-my-foobar))



On Sat, 23 Oct 2021 at 11:04, Phil <phil@beadling.co.uk> wrote:
Hi,

Ludovic Courtès writes:

> For historical reasons, ‘--with-source’ only applies to leaf packages,
> unlike most (all?) other transformation inputs.  Concretely, this works:

Yes I think this is what I'm hitting.  I want to reference a package
using --with-source, but then immediately build an environment which
feeds this source as an input into a 2nd package - forcing it to
rebuild.

My hack works but for propagated dependencies in python - but it's not a
proper solution, and is brittle.  I was going to try to improve
it by writing a Guile script to avoid the overwriting - I can post any
solution I find if I get something working.

Currently I can only do 2 things at the command line it seems:

1. I can try package X without writing a package but only in isolation
or as a leaf.

2. I can replace package X as a dependency of package Y, if I write a package
for it.

Being able to combine 1 and 2 at the command line - would be very
useful.

Cheers,
Phil.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]