GNU bug report logs - #27275
[PATCH 0/2] Add (guix git) module.

Previous Next

Package: guix-patches;

Reported by: Mathieu Othacehe <m.othacehe <at> gmail.com>

Date: Wed, 7 Jun 2017 12:05:02 UTC

Severity: normal

Tags: patch

Done: Mathieu Othacehe <m.othacehe <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 27275 in the body.
You can then email your comments to 27275 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#27275; Package guix-patches. (Wed, 07 Jun 2017 12:05:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Mathieu Othacehe <m.othacehe <at> gmail.com>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Wed, 07 Jun 2017 12:05:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Othacehe <m.othacehe <at> gmail.com>
To: guix-patches <at> gnu.org
Cc: Mathieu Othacehe <m.othacehe <at> gmail.com>
Subject: [PATCH 0/2] Add (guix git) module.
Date: Wed,  7 Jun 2017 14:04:05 +0200
Hi,

This serie un-reverts the (guix git) module.
A new patch is included to add guile-git as a dependency
of guix pull.

Thanks,

Mathieu

Mathieu Othacehe (2):
  pull: Add a dependency to guile-git.
  guix: git: Add new module.

 Makefile.am                         |   7 ++
 build-aux/build-self.scm            |  19 ++++++
 configure.ac                        |   4 ++
 gnu/packages/guile.scm              |   8 +++
 gnu/packages/package-management.scm |   3 +
 guix/git.scm                        | 123 ++++++++++++++++++++++++++++++++++++
 6 files changed, 164 insertions(+)
 create mode 100644 guix/git.scm

-- 
2.13.0





Information forwarded to guix-patches <at> gnu.org:
bug#27275; Package guix-patches. (Wed, 07 Jun 2017 12:07:02 GMT) Full text and rfc822 format available.

Message #8 received at 27275 <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Othacehe <m.othacehe <at> gmail.com>
To: 27275 <at> debbugs.gnu.org
Cc: Mathieu Othacehe <m.othacehe <at> gmail.com>
Subject: [PATCH 1/2] pull: Add a dependency to guile-git.
Date: Wed,  7 Jun 2017 14:05:52 +0200
* build-aux/build-self.scm (guile-git, guile-bytestructures): New
  variables.
  (build): Add guile-git and guile-bytestructures to %load-path and
  %load-compiled-path.
* gnu/packages/guile.scm (guile2.2-bytestructures, guile2.2-git): New
  variables.
* gnu/packages/package-management.scm (guix)[propagated-inputs]: Add
  guile-git.
  [wrap-program]: Add guile-git to path.
---
 build-aux/build-self.scm            | 19 +++++++++++++++++++
 gnu/packages/guile.scm              |  8 ++++++++
 gnu/packages/package-management.scm |  3 +++
 3 files changed, 30 insertions(+)

diff --git a/build-aux/build-self.scm b/build-aux/build-self.scm
index a1335fea1..b1c8afcb2 100644
--- a/build-aux/build-self.scm
+++ b/build-aux/build-self.scm
@@ -97,6 +97,15 @@ Guile major version (2.0 or 2.2), or #f if none of the packages matches."
                              "guile2.2-ssh"
                              "guile2.0-ssh"))
 
+(define guile-git
+  ;; TODO: Add guile2.0-git.
+  (package-for-current-guile "guile-git"
+                             "guile2.2-git"))
+
+(define guile-bytestructures
+  ;; TODO: Add guile2.0-bytestructures.
+  (package-for-current-guile "guile-bytestructures"
+                             "guile2.2-bytestructures"))
 
 ;; The actual build procedure.
 
@@ -152,11 +161,21 @@ files."
                                    #$(effective-version))))
           (set! %load-path
             (cons* json
+                   (string-append #$guile-git "/share/guile/site/"
+                                  #$(effective-version))
+                   (string-append #$guile-bytestructures "/share/guile/site/"
+                                  #$(effective-version))
                    (string-append #$guile-ssh "/share/guile/site/"
                                   #$(effective-version))
                    %load-path))
           (set! %load-compiled-path
             (cons* json
+                   (string-append #$guile-git "/lib/guile/"
+                                  #$(effective-version)
+                                  "/site-ccache")
+                   (string-append #$guile-bytestructures "/lib/guile/"
+                                  #$(effective-version)
+                                  "/site-ccache")
                    (string-append #$guile-ssh "/lib/guile/"
                                   #$(effective-version)
                                   "/site-ccache")
diff --git a/gnu/packages/guile.scm b/gnu/packages/guile.scm
index 5b85a61c1..b12ba1cad 100644
--- a/gnu/packages/guile.scm
+++ b/gnu/packages/guile.scm
@@ -1593,6 +1593,10 @@ an abstraction over raw memory.  It's also more powerful than the C
 type system, elevating types to first-class status.")
     (license license:gpl3+)))
 
+;; TODO: Add guile2.0-bytestructures.
+(define-public guile2.2-bytestructures
+  (deprecated-package "guile2.2-bytestructures" guile-bytestructures))
+
 (define-public guile-aspell
   (package
     (name "guile-aspell")
@@ -1803,6 +1807,10 @@ is not available for Guile 2.0.")
 manipulate repositories of the Git version control system.")
       (license license:gpl3+))))
 
+;; TODO: Add guile2.0-git.
+(define-public guile2.2-git
+  (deprecated-package "guile2.2-git" guile-git))
+
 (define-public guile-syntax-highlight
   (let ((commit "a047675e66861b647426372aa2ba7820f749616d")
         (revision "0"))
diff --git a/gnu/packages/package-management.scm b/gnu/packages/package-management.scm
index 12e1f9e6c..f47e78459 100644
--- a/gnu/packages/package-management.scm
+++ b/gnu/packages/package-management.scm
@@ -185,6 +185,7 @@
                         (let* ((out    (assoc-ref outputs "out"))
                                (guile  (assoc-ref inputs "guile"))
                                (json   (assoc-ref inputs "guile-json"))
+                               (git    (assoc-ref inputs "guile-git"))
                                (ssh    (assoc-ref inputs "guile-ssh"))
                                (gnutls (assoc-ref inputs "gnutls"))
                                (effective
@@ -195,6 +196,7 @@
                                (path   (string-append
                                         json "/share/guile/site/" effective ":"
                                         ssh "/share/guile/site/" effective ":"
+                                        git "/share/guile/site/" effective ":"
                                         gnutls "/share/guile/site/" effective)))
 
                           (wrap-program (string-append out "/bin/guix")
@@ -250,6 +252,7 @@
       (propagated-inputs
        `(("gnutls" ,gnutls/guile-2.2)             ;for 'guix download' & co.
          ("guile-json" ,guile-json)
+         ("guile-git" ,guile-git)
          ("guile-ssh" ,guile-ssh)))
 
       (home-page "https://www.gnu.org/software/guix/")
-- 
2.13.0





Information forwarded to guix-patches <at> gnu.org:
bug#27275; Package guix-patches. (Wed, 07 Jun 2017 12:07:03 GMT) Full text and rfc822 format available.

Message #11 received at 27275 <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Othacehe <m.othacehe <at> gmail.com>
To: 27275 <at> debbugs.gnu.org
Cc: Mathieu Othacehe <m.othacehe <at> gmail.com>
Subject: [PATCH 2/2] guix: git: Add new module.
Date: Wed,  7 Jun 2017 14:05:53 +0200
* guix/git.scm: New file.
* configure.ac: Check for (guile git).
* Makefile.am: Build guix/git.scm if (guile git) is available.
---
 Makefile.am  |   7 ++++
 configure.ac |   4 ++
 guix/git.scm | 123 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 134 insertions(+)
 create mode 100644 guix/git.scm

diff --git a/Makefile.am b/Makefile.am
index 3925f3e2d..1be09d763 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -201,6 +201,13 @@ MODULES +=					\
 
 endif HAVE_GUILE_SSH
 
+if HAVE_GUILE_GIT
+
+MODULES +=					\
+  guix/git.scm
+
+endif HAVE_GUILE_GIT
+
 if BUILD_DAEMON_OFFLOAD
 
 MODULES +=					\
diff --git a/configure.ac b/configure.ac
index dc3d8f377..c937e948d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -104,6 +104,10 @@ dnl Guile-JSON is used in various places.
 GUILE_MODULE_AVAILABLE([have_guile_json], [(json)])
 AM_CONDITIONAL([HAVE_GUILE_JSON], [test "x$have_guile_json" = "xyes"])
 
+dnl Check for Guile-Git.
+GUILE_MODULE_AVAILABLE([have_guile_git], [(git)])
+AM_CONDITIONAL([HAVE_GUILE_GIT], [test "x$have_guile_git" = "xyes"])
+
 dnl Make sure we have a full-fledged Guile.
 GUIX_ASSERT_GUILE_FEATURES([regex posix socket net-db threads])
 
diff --git a/guix/git.scm b/guix/git.scm
new file mode 100644
index 000000000..17a6784ae
--- /dev/null
+++ b/guix/git.scm
@@ -0,0 +1,123 @@
+;;; GNU Guix --- Functional package management for GNU
+;;; Copyright © 2017 Mathieu Othacehe <m.othacehe <at> gmail.com>
+;;;
+;;; This file is part of GNU Guix.
+;;;
+;;; GNU Guix is free software; you can redistribute it and/or modify it
+;;; under the terms of the GNU General Public License as published by
+;;; the Free Software Foundation; either version 3 of the License, or (at
+;;; your option) any later version.
+;;;
+;;; GNU Guix is distributed in the hope that it will be useful, but
+;;; WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+;;; GNU General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with GNU Guix.  If not, see <http://www.gnu.org/licenses/>.
+
+(define-module (guix git)
+  #:use-module (git)
+  #:use-module (git object)
+  #:use-module (guix base32)
+  #:use-module (guix hash)
+  #:use-module (guix build utils)
+  #:use-module (guix store)
+  #:use-module (guix utils)
+  #:use-module (rnrs bytevectors)
+  #:use-module (ice-9 match)
+  #:use-module (srfi srfi-1)
+  #:export (%repository-cache-directory
+            latest-repository-commit))
+
+(define %repository-cache-directory
+  (make-parameter "/var/cache/guix/checkouts"))
+
+(define-syntax-rule (with-libgit2 thunk ...)
+  (dynamic-wind
+    (lambda ()
+      (libgit2-init!))
+    (lambda ()
+      thunk ...)
+    (lambda ()
+      (libgit2-shutdown))))
+
+(define* (url-cache-directory url
+                              #:optional (cache-directory
+                                          (%repository-cache-directory)))
+  "Return the directory associated to URL in %repository-cache-directory."
+  (string-append
+   cache-directory "/"
+   (bytevector->base32-string (sha256 (string->utf8 url)))))
+
+(define (clone* url directory)
+  "Clone git repository at URL into DIRECTORY.  Upon failure,
+make sure no empty directory is left behind."
+  (with-throw-handler #t
+    (lambda ()
+      (mkdir-p directory)
+      (clone url directory))
+    (lambda _
+      (false-if-exception (rmdir directory)))))
+
+(define (repository->head-sha1 repo)
+  "Return the sha1 of the HEAD commit in REPOSITORY as a string."
+  (let ((oid (reference-target (repository-head repo))))
+    (oid->string (commit-id (commit-lookup repo oid)))))
+
+(define (url+commit->name url sha1)
+  "Return the string \"<REPO-NAME>-<SHA1:7>\" where REPO-NAME is the name of
+the git repository, extracted from URL and SHA1:7 the seven first digits
+of SHA1 string."
+  (string-append
+   (string-replace-substring
+    (last (string-split url #\/)) ".git" "")
+   "-" (string-take sha1 7)))
+
+(define* (copy-to-store store cache-directory #:key url repository)
+  "Copy items in cache-directory to store.  URL and REPOSITORY are used
+to forge store directory name."
+  (let* ((commit (repository->head-sha1 repository))
+         (name   (url+commit->name url commit)))
+    (values (add-to-store store name #t "sha256" cache-directory) commit)))
+
+(define (switch-to-ref repository ref)
+  "Switch to REPOSITORY's branch, commit or tag specified by REF."
+  (let* ((oid (match ref
+                (('branch . branch)
+                 (reference-target
+                  (branch-lookup repository branch BRANCH-REMOTE)))
+                (('commit . commit)
+                 (string->oid commit))
+                (('tag    . tag)
+                 (reference-name->oid repository
+                                      (string-append "refs/tags/" tag)))))
+         (obj (object-lookup repository oid)))
+    (reset repository obj RESET_HARD)))
+
+(define* (latest-repository-commit store url
+                                   #:key
+                                   (cache-directory
+                                    (%repository-cache-directory))
+                                   (ref '(branch . "origin/master")))
+  "Return two values: the content of the git repository at URL copied into a
+store directory and the sha1 of the top level commit in this directory.  The
+reference to be checkout, once the repository is fetched, is specified by REF.
+REF is pair whose key is [branch | commit | tag] and value the associated
+data, respectively [<branch name> | <sha1> | <tag name>].
+
+Git repositories are kept in the cache directory specified by
+%repository-cache-directory parameter."
+  (with-libgit2
+   (let* ((cache-dir     (url-cache-directory url cache-directory))
+          (cache-exists? (openable-repository? cache-dir))
+          (repository    (if cache-exists?
+                             (repository-open cache-dir)
+                             (clone* url cache-dir))))
+     ;; Only fetch remote if it has not been cloned just before.
+     (when cache-exists?
+       (remote-fetch (remote-lookup repository "origin")))
+     (switch-to-ref repository ref)
+     (copy-to-store store cache-dir
+                    #:url url
+                    #:repository repository))))
-- 
2.13.0





Information forwarded to guix-patches <at> gnu.org:
bug#27275; Package guix-patches. (Wed, 07 Jun 2017 12:22:01 GMT) Full text and rfc822 format available.

Message #14 received at 27275 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Mathieu Othacehe <m.othacehe <at> gmail.com>
Cc: 27275 <at> debbugs.gnu.org
Subject: Re: bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git.
Date: Wed, 07 Jun 2017 14:21:07 +0200
Hi Mathieu!

Mathieu Othacehe <m.othacehe <at> gmail.com> skribis:

> * build-aux/build-self.scm (guile-git, guile-bytestructures): New
>   variables.
>   (build): Add guile-git and guile-bytestructures to %load-path and
>   %load-compiled-path.
> * gnu/packages/guile.scm (guile2.2-bytestructures, guile2.2-git): New
>   variables.
> * gnu/packages/package-management.scm (guix)[propagated-inputs]: Add
>   guile-git.
>   [wrap-program]: Add guile-git to path.

[...]

> +(define guile-git
> +  ;; TODO: Add guile2.0-git.
> +  (package-for-current-guile "guile-git"
> +                             "guile2.2-git"))
> +
> +(define guile-bytestructures
> +  ;; TODO: Add guile2.0-bytestructures.
> +  (package-for-current-guile "guile-bytestructures"
> +                             "guile2.2-bytestructures"))

You can add the “guile2.0-” names too in the arguments to
‘package-for-current-guile’.  It doesn’t hurt, and if/when we add them,
they’ll automatically be picked up.

You can also remove the TODOs.

>            (set! %load-path
>              (cons* json
> +                   (string-append #$guile-git "/share/guile/site/"
> +                                  #$(effective-version))
> +                   (string-append #$guile-bytestructures "/share/guile/site/"
> +                                  #$(effective-version))
>                     (string-append #$guile-ssh "/share/guile/site/"
>                                    #$(effective-version))
>                     %load-path))
>            (set! %load-compiled-path
>              (cons* json
> +                   (string-append #$guile-git "/lib/guile/"
> +                                  #$(effective-version)-
> +                                  "/site-ccache")

‘guile-git’ can be #f so you have to account for that.

> --- a/gnu/packages/guile.scm
> +++ b/gnu/packages/guile.scm
> @@ -1593,6 +1593,10 @@ an abstraction over raw memory.  It's also more powerful than the C
>  type system, elevating types to first-class status.")
>      (license license:gpl3+)))
>  
> +;; TODO: Add guile2.0-bytestructures.
> +(define-public guile2.2-bytestructures
> +  (deprecated-package "guile2.2-bytestructures" guile-bytestructures))
> +
>  (define-public guile-aspell
>    (package
>      (name "guile-aspell")
> @@ -1803,6 +1807,10 @@ is not available for Guile 2.0.")
>  manipulate repositories of the Git version control system.")
>        (license license:gpl3+))))
>  
> +;; TODO: Add guile2.0-git.
> +(define-public guile2.2-git
> +  (deprecated-package "guile2.2-git" guile-git))

These aliases are unneeded: we’ll just use the names without “2.2” by
default, no problem.

> --- a/gnu/packages/package-management.scm
> +++ b/gnu/packages/package-management.scm
> @@ -185,6 +185,7 @@
>                          (let* ((out    (assoc-ref outputs "out"))
>                                 (guile  (assoc-ref inputs "guile"))
>                                 (json   (assoc-ref inputs "guile-json"))
> +                               (git    (assoc-ref inputs "guile-git"))
>                                 (ssh    (assoc-ref inputs "guile-ssh"))
>                                 (gnutls (assoc-ref inputs "gnutls"))
>                                 (effective
> @@ -195,6 +196,7 @@
>                                 (path   (string-append
>                                          json "/share/guile/site/" effective ":"
>                                          ssh "/share/guile/site/" effective ":"
> +                                        git "/share/guile/site/" effective ":"
>                                          gnutls "/share/guile/site/" effective)))
>  
>                            (wrap-program (string-append out "/bin/guix")
> @@ -250,6 +252,7 @@
>        (propagated-inputs
>         `(("gnutls" ,gnutls/guile-2.2)             ;for 'guix download' & co.
>           ("guile-json" ,guile-json)
> +         ("guile-git" ,guile-git)

I think this breaks the ‘guile2.0-guix’ package.  I hope to remove it
soonish (when the guile-ssh bug is fixed), but for now, we have to live
with it.

So I would suggest simply leaving this file unchanged.  We can always
add the ‘guile-git’ dependency there later on.

WDYT?

With these changes it looks good to me!

Thanks,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#27275; Package guix-patches. (Wed, 07 Jun 2017 12:22:02 GMT) Full text and rfc822 format available.

Message #17 received at 27275 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Mathieu Othacehe <m.othacehe <at> gmail.com>
Cc: 27275 <at> debbugs.gnu.org
Subject: Re: bug#27275: [PATCH 2/2] guix: git: Add new module.
Date: Wed, 07 Jun 2017 14:21:39 +0200
Mathieu Othacehe <m.othacehe <at> gmail.com> skribis:

> * guix/git.scm: New file.
> * configure.ac: Check for (guile git).
> * Makefile.am: Build guix/git.scm if (guile git) is available.

Perfect, nothing to add here.  :-)

Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#27275; Package guix-patches. (Wed, 07 Jun 2017 13:59:02 GMT) Full text and rfc822 format available.

Message #20 received at 27275 <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Othacehe <m.othacehe <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 27275 <at> debbugs.gnu.org
Subject: Re: bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git.
Date: Wed, 07 Jun 2017 15:58:56 +0200
Hi Ludo,

Thanks for the fast review :)

>>            (set! %load-compiled-path
>>              (cons* json
>> +                   (string-append #$guile-git "/lib/guile/"
>> +                                  #$(effective-version)-
>> +                                  "/site-ccache")
>
> ‘guile-git’ can be #f so you have to account for that.

Just on question about that. The easier I come up with is something like
:
 
--8<---------------cut here---------------start------------->8---
(set! %load-path
      (append
       `(,@(if
               (and #$guile-git #$guile-bytestructures)
               (list
                (string-append #$guile-git "/share/guile/site/"
                               #$(effective-version))
                (string-append #$guile-bytestructures "/share/guile/site/"
                               #$(effective-version)))
             '()))
       (cons* json
              (string-append #$guile-ssh "/share/guile/site/"
                             #$(effective-version))
              %load-path)))
--8<---------------cut here---------------end--------------->8---

Any idea on how to write that smoothly ?

Thanks,

Mathieu




Information forwarded to guix-patches <at> gnu.org:
bug#27275; Package guix-patches. (Thu, 08 Jun 2017 12:07:02 GMT) Full text and rfc822 format available.

Message #23 received at 27275 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Mathieu Othacehe <m.othacehe <at> gmail.com>
Cc: 27275 <at> debbugs.gnu.org
Subject: Re: bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git.
Date: Thu, 08 Jun 2017 14:06:09 +0200
Hello!

Mathieu Othacehe <m.othacehe <at> gmail.com> skribis:

>>>            (set! %load-compiled-path
>>>              (cons* json
>>> +                   (string-append #$guile-git "/lib/guile/"
>>> +                                  #$(effective-version)-
>>> +                                  "/site-ccache")
>>
>> ‘guile-git’ can be #f so you have to account for that.
>
> Just on question about that. The easier I come up with is something like
> :
>  
>
> (set! %load-path
>       (append
>        `(,@(if
>                (and #$guile-git #$guile-bytestructures)
>                (list
>                 (string-append #$guile-git "/share/guile/site/"
>                                #$(effective-version))
>                 (string-append #$guile-bytestructures "/share/guile/site/"
>                                #$(effective-version)))
>              '()))
>        (cons* json
>               (string-append #$guile-ssh "/share/guile/site/"
>                              #$(effective-version))
>               %load-path)))
>
> Any idea on how to write that smoothly ?

Maybe with a macro along these lines:

--8<---------------cut here---------------start------------->8---
(letrec-syntax ((maybe-load-path
                 (syntax-rules ()
                   ((_ item rest ...)
                    (let ((tail (maybe-load-path rest ...)))
                      (if (string? item)
                          (cons (string-append item
                                               "/share/guile/site/"
                                               (effective-version))
                                tail)
                          tail)))
                   ((_)
                    '()))))
  (set! %load-path
    (maybe-load-path json guile-git guile-bytestructures)))
--8<---------------cut here---------------end--------------->8---

HTH,
Ludo’.




Information forwarded to guix-patches <at> gnu.org:
bug#27275; Package guix-patches. (Thu, 08 Jun 2017 14:50:01 GMT) Full text and rfc822 format available.

Message #26 received at 27275 <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Othacehe <m.othacehe <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 27275 <at> debbugs.gnu.org
Subject: Re: bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git.
Date: Thu, 08 Jun 2017 16:49:15 +0200
[Message part 1 (text/plain, inline)]
Hi Ludo !

> Maybe with a macro along these lines:

Nice, thanks !

I attached the patch I come up with. It's working ok :)
I have a shorter version using match :

--8<---------------cut here---------------start------------->8---
(letrec-syntax ((maybe-load-paths
                 (syntax-rules ()
                   ((_ item rest ...)
                    (let ((tail (maybe-load-paths rest ...)))
                      (if (string? item)
                          (match tail
                            ((load-path load-compiled-path)
                            (list
                             (cons (string-append item
                                                  "/share/guile/site/"
                                                  #$(effective-version))
                                   load-path)
                             (cons (string-append item
                                                  "/lib/guile/"
                                                  #$(effective-version)
                                                  "/site-ccache")
                                   load-compiled-path))))
                          tail)))
                   ((_)
                    '(() ())))))
  (match (maybe-load-paths #$guile-json #$guile-ssh
                           #$guile-git #$guile-bytestructures)
    ((module-load-path module-load-compiled-path)
     (set! %load-path (append module-load-path %load-path)
     (set! %load-compiled-path (append module-load-compiled-path %load-compiled-path))))))
--8<---------------cut here---------------end--------------->8---

It might seems preferable but I can't get guix-latest derivation to
include (ice-9 match), maybe because of #:module-path in
"(gexp->derivation "guix-latest" ...".

Mathieu
[0002-pull-Add-a-dependency-to-guile-git.patch (text/x-diff, inline)]
From 1130f8eafdb27216fc542bff253a940528bedc6a Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <m.othacehe <at> gmail.com>
Date: Wed, 7 Jun 2017 13:44:47 +0200
Subject: [PATCH 2/2] pull: Add a dependency to guile-git.

* build-aux/build-self.scm (guile-git, guile-bytestructures): New
  variables.
  (build): Add guile-git and guile-bytestructures to %load-path and
  %load-compiled-path.
---
 build-aux/build-self.scm | 52 ++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 41 insertions(+), 11 deletions(-)

diff --git a/build-aux/build-self.scm b/build-aux/build-self.scm
index a1335fea1..8fb9af23c 100644
--- a/build-aux/build-self.scm
+++ b/build-aux/build-self.scm
@@ -97,6 +97,13 @@ Guile major version (2.0 or 2.2), or #f if none of the packages matches."
                              "guile2.2-ssh"
                              "guile2.0-ssh"))
 
+(define guile-git
+  (package-for-current-guile "guile-git"
+                             "guile2.0-git"))
+
+(define guile-bytestructures
+  (package-for-current-guile "guile-bytestructures"
+                             "guile2.0-bytestructures"))
 
 ;; The actual build procedure.
 
@@ -148,19 +155,42 @@ files."
     #~(begin
         (use-modules (guix build pull))
 
-        (let ((json (string-append #$guile-json "/share/guile/site/"
-                                   #$(effective-version))))
+        (letrec-syntax ((maybe-load-path
+                         (syntax-rules ()
+                           ((_ item rest ...)
+                            (let ((tail (maybe-load-path rest ...)))
+                              (if (string? item)
+                                  (cons (string-append item
+                                                       "/share/guile/site/"
+                                                       #$(effective-version))
+                                        tail)
+                                  tail)))
+                           ((_)
+                            '()))))
           (set! %load-path
-            (cons* json
-                   (string-append #$guile-ssh "/share/guile/site/"
-                                  #$(effective-version))
-                   %load-path))
+                (append
+                 (maybe-load-path #$guile-json #$guile-ssh
+                                  #$guile-git #$guile-bytestructures)
+                 %load-path)))
+
+        (letrec-syntax ((maybe-load-compiled-path
+                         (syntax-rules ()
+                           ((_ item rest ...)
+                            (let ((tail (maybe-load-compiled-path rest ...)))
+                              (if (string? item)
+                                  (cons (string-append item
+                                                       "/lib/guile/"
+                                                       #$(effective-version)
+                                                       "/site-ccache")
+                                        tail)
+                                  tail)))
+                           ((_)
+                            '()))))
           (set! %load-compiled-path
-            (cons* json
-                   (string-append #$guile-ssh "/lib/guile/"
-                                  #$(effective-version)
-                                  "/site-ccache")
-                   %load-compiled-path)))
+                (append
+                 (maybe-load-compiled-path #$guile-json #$guile-ssh
+                                           #$guile-git #$guile-bytestructures)
+                 %load-compiled-path)))
 
         ;; XXX: The 'guile-ssh' package prior to Guix commit 92b7258 was
         ;; broken: libguile-ssh could not be found.  Work around that.
-- 
2.13.1


Information forwarded to guix-patches <at> gnu.org:
bug#27275; Package guix-patches. (Thu, 08 Jun 2017 20:54:01 GMT) Full text and rfc822 format available.

Message #29 received at 27275 <at> debbugs.gnu.org (full text, mbox):

From: ludo <at> gnu.org (Ludovic Courtès)
To: Mathieu Othacehe <m.othacehe <at> gmail.com>
Cc: 27275 <at> debbugs.gnu.org
Subject: Re: bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git.
Date: Thu, 08 Jun 2017 22:52:54 +0200
Hello!

Mathieu Othacehe <m.othacehe <at> gmail.com> skribis:

> I attached the patch I come up with. It's working ok :)
> I have a shorter version using match :
>
> (letrec-syntax ((maybe-load-paths
>                  (syntax-rules ()
>                    ((_ item rest ...)
>                     (let ((tail (maybe-load-paths rest ...)))
>                       (if (string? item)
>                           (match tail
>                             ((load-path load-compiled-path)
>                             (list
>                              (cons (string-append item
>                                                   "/share/guile/site/"
>                                                   #$(effective-version))
>                                    load-path)
>                              (cons (string-append item
>                                                   "/lib/guile/"
>                                                   #$(effective-version)
>                                                   "/site-ccache")
>                                    load-compiled-path))))
>                           tail)))
>                    ((_)
>                     '(() ())))))
>   (match (maybe-load-paths #$guile-json #$guile-ssh
>                            #$guile-git #$guile-bytestructures)
>     ((module-load-path module-load-compiled-path)
>      (set! %load-path (append module-load-path %load-path)
>      (set! %load-compiled-path (append module-load-compiled-path %load-compiled-path))))))
>
> It might seems preferable but I can't get guix-latest derivation to
> include (ice-9 match), maybe because of #:module-path in
> "(gexp->derivation "guix-latest" ...".

Hmm (ice-9 match) should always be found, but don’t add it to the
#:modules argument of ‘gexp->derivation’.

> From 1130f8eafdb27216fc542bff253a940528bedc6a Mon Sep 17 00:00:00 2001
> From: Mathieu Othacehe <m.othacehe <at> gmail.com>
> Date: Wed, 7 Jun 2017 13:44:47 +0200
> Subject: [PATCH 2/2] pull: Add a dependency to guile-git.
>
> * build-aux/build-self.scm (guile-git, guile-bytestructures): New
>   variables.
>   (build): Add guile-git and guile-bytestructures to %load-path and
>   %load-compiled-path.

OK for this or the variant that uses ‘match’.

Thanks!

Ludo’.




Reply sent to Mathieu Othacehe <m.othacehe <at> gmail.com>:
You have taken responsibility. (Fri, 09 Jun 2017 07:52:02 GMT) Full text and rfc822 format available.

Notification sent to Mathieu Othacehe <m.othacehe <at> gmail.com>:
bug acknowledged by developer. (Fri, 09 Jun 2017 07:52:02 GMT) Full text and rfc822 format available.

Message #34 received at 27275-done <at> debbugs.gnu.org (full text, mbox):

From: Mathieu Othacehe <m.othacehe <at> gmail.com>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 27275-done <at> debbugs.gnu.org
Subject: Re: bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git.
Date: Fri, 09 Jun 2017 09:51:23 +0200
Hi,

> OK for this or the variant that uses ‘match’.

Just pushed the two patches as 6b7b3ca98 and 19c90e5f6.

Thanks,

Mathieu




bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Fri, 07 Jul 2017 11:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 8 years and 69 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.