Subject: Attempts to fix bootstrap Guile bug

From: Andy Wingo <[email-masked]>
Date: Tue, 21 Feb 2017 09:52:09 +0100

Hi,

It seems that this bug is related to the introduction of
url-fetch/reset-patch-level.  It takes a #:guile kwarg but defaults to
#f; if not given #:guile, that #f propagates through instead of a
package object.

So one fix is here:

  diff --git a/gnu/packages/bootstrap.scm b/gnu/packages/bootstrap.scm
  index c8d94c8..d070cca 100644
  --- a/gnu/packages/bootstrap.scm
  +++ b/gnu/packages/bootstrap.scm
  @@ -76,8 +76,10 @@
   
     (let ((orig-method (origin-method source)))
       (origin (inherit source)
  -      (method (cond ((eq? orig-method url-fetch)
  -                     (boot url-fetch))
  +      (method (cond ((or (eq? orig-method url-fetch)
  +                         (eq? orig-method
  +                              (@@ (gnu packages bash) url-fetch/reset-patch-level)))
  +                     (boot orig-method))
                       (else orig-method)))
         (patch-guile %bootstrap-guile)
         (patch-inputs %bootstrap-patch-inputs)

I think anyway.  If you look at this code, the "boot" helper decorates
the url-fetch call with a #:guile.  But I don't think this function is
called for bash because I still see an error.

Another fix is here I think:

  diff --git a/gnu/packages/bash.scm b/gnu/packages/bash.scm
  index c121fd8..fdb3aa8 100644
  --- a/gnu/packages/bash.scm
  +++ b/gnu/packages/bash.scm
  @@ -250,7 +250,8 @@ can apply to a patch-level 0 Bash."
                          (patch (url-fetch url hash-algo hash
                                            (string-append name ".orig")
                                            #:system system
  -                                         #:guile guile)))
  +                                         #:guile guile))
  +                       (guile (package->derivation guile system)))
       (gexp->derivation name
                         (with-imported-modules '((guix build utils))
                           #~(begin

Here this "guile" propagates below to #:guile-for-build, which AFAIU
should be a derivation, not a package.

But even with this, I still get an error.  Add (unless guile (error
"what")) to the top of url-fetch/reset-patch-level, and I get:

  [6h8mzf08ld7r69yy9gdbxw9vba0l9sr2-profile] wingo@clucks:~/src/guix$ guix build guile-next
  Backtrace:
  In srfi/srfi-1.scm:
   575: 19 [map #<procedure 1a7fb40 at guix/scripts/build.scm:629:16 (expr)> (#)]
  In guix/scripts/build.scm:
   634: 18 [#<procedure 1a7fb40 at guix/scripts/build.scm:629:16 (expr)> #]
  In guix/packages.scm:
   786: 17 [cache! #<weak-key-hash-table 18a8a40 318/443> # # ...]
  1095: 16 [thunk]
   982: 15 [bag-grafts # #]
   966: 14 [fold-bag-dependencies #<procedure 501b0a0 at guix/packages.scm:982:29 (package grafts)> ...]
   983: 13 [#<procedure 501b0a0 at guix/packages.scm:982:29 (package grafts)> # #]
   786: 12 [cache! #<weak-key-hash-table 18a8600 3/223> # "x86_64-linux" ...]
   910: 11 [thunk]
   786: 10 [cache! #<weak-key-hash-table 18a8a40 318/443> # # ...]
  1092: 9 [thunk]
  1024: 8 [bag->derivation # # #]
  In srfi/srfi-1.scm:
   575: 7 [map #<procedure 4bce810 at guix/packages.scm:1026:30 (t-32174)> #]
  In guix/packages.scm:
   846: 6 [expand-input # # # ...]
  In guix/store.scm:
  1249: 5 [run-with-store # ...]
  In guix/packages.scm:
  1200: 4 [#<procedure 4cee600 at guix/packages.scm:1194:5 (state)> #]
   486: 3 [patch-and-repack # # # ...]
  In srfi/srfi-1.scm:
   575: 2 [map #<procedure instantiate-patch (expr)> (#)]
  In gnu/packages/bash.scm:
   249: 1 [url-fetch/reset-patch-level "mirror://gnu/bash/bash-4.4-patches/bash44-007" ...]
  In unknown file:
     ?: 0 [scm-error misc-error #f "~A" ("what") #f]

  ERROR: In procedure scm-error:
  ERROR: what

That indicates to me that somehow the origin for this bash (or is it
bash/fixed?) isn't getting its url-fetch call appropriately decorated.

I think in the meantime it would be acceptable to insert an

  (unless guile
    (error "update your guix daemon from git and restart it (#25775)"))

to url-fetch/reset-patch-level, or something like that.  WDYT?

Andy