unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* bug#27275: [PATCH 0/2] Add (guix git) module.
@ 2017-06-07 12:04 Mathieu Othacehe
  2017-06-07 12:05 ` bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git Mathieu Othacehe
  0 siblings, 1 reply; 10+ messages in thread
From: Mathieu Othacehe @ 2017-06-07 12:04 UTC (permalink / raw)
  To: 27275

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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git.
  2017-06-07 12:04 bug#27275: [PATCH 0/2] Add (guix git) module Mathieu Othacehe
@ 2017-06-07 12:05 ` Mathieu Othacehe
  2017-06-07 12:05   ` bug#27275: [PATCH 2/2] guix: git: Add new module Mathieu Othacehe
  2017-06-07 12:21   ` bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git Ludovic Courtès
  0 siblings, 2 replies; 10+ messages in thread
From: Mathieu Othacehe @ 2017-06-07 12:05 UTC (permalink / raw)
  To: 27275

* 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"))
 \f
 ;; 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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#27275: [PATCH 2/2] guix: git: Add new module.
  2017-06-07 12:05 ` bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git Mathieu Othacehe
@ 2017-06-07 12:05   ` Mathieu Othacehe
  2017-06-07 12:21     ` Ludovic Courtès
  2017-06-07 12:21   ` bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git Ludovic Courtès
  1 sibling, 1 reply; 10+ messages in thread
From: Mathieu Othacehe @ 2017-06-07 12:05 UTC (permalink / raw)
  To: 27275

* 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@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

^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git.
  2017-06-07 12:05 ` bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git Mathieu Othacehe
  2017-06-07 12:05   ` bug#27275: [PATCH 2/2] guix: git: Add new module Mathieu Othacehe
@ 2017-06-07 12:21   ` Ludovic Courtès
  2017-06-07 13:58     ` Mathieu Othacehe
  1 sibling, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2017-06-07 12:21 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 27275

Hi Mathieu!

Mathieu Othacehe <m.othacehe@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’.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#27275: [PATCH 2/2] guix: git: Add new module.
  2017-06-07 12:05   ` bug#27275: [PATCH 2/2] guix: git: Add new module Mathieu Othacehe
@ 2017-06-07 12:21     ` Ludovic Courtès
  0 siblings, 0 replies; 10+ messages in thread
From: Ludovic Courtès @ 2017-06-07 12:21 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 27275

Mathieu Othacehe <m.othacehe@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’.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git.
  2017-06-07 12:21   ` bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git Ludovic Courtès
@ 2017-06-07 13:58     ` Mathieu Othacehe
  2017-06-08 12:06       ` Ludovic Courtès
  0 siblings, 1 reply; 10+ messages in thread
From: Mathieu Othacehe @ 2017-06-07 13:58 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 27275


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

^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git.
  2017-06-07 13:58     ` Mathieu Othacehe
@ 2017-06-08 12:06       ` Ludovic Courtès
  2017-06-08 14:49         ` Mathieu Othacehe
  0 siblings, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2017-06-08 12:06 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 27275

Hello!

Mathieu Othacehe <m.othacehe@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’.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git.
  2017-06-08 12:06       ` Ludovic Courtès
@ 2017-06-08 14:49         ` Mathieu Othacehe
  2017-06-08 20:52           ` Ludovic Courtès
  0 siblings, 1 reply; 10+ messages in thread
From: Mathieu Othacehe @ 2017-06-08 14:49 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 27275

[-- Attachment #1: Type: text/plain, Size: 1778 bytes --]


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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0002-pull-Add-a-dependency-to-guile-git.patch --]
[-- Type: text/x-diff, Size: 3764 bytes --]

From 1130f8eafdb27216fc542bff253a940528bedc6a Mon Sep 17 00:00:00 2001
From: Mathieu Othacehe <m.othacehe@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"))
 \f
 ;; 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


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git.
  2017-06-08 14:49         ` Mathieu Othacehe
@ 2017-06-08 20:52           ` Ludovic Courtès
  2017-06-09  7:51             ` Mathieu Othacehe
  0 siblings, 1 reply; 10+ messages in thread
From: Ludovic Courtès @ 2017-06-08 20:52 UTC (permalink / raw)
  To: Mathieu Othacehe; +Cc: 27275

Hello!

Mathieu Othacehe <m.othacehe@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@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’.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git.
  2017-06-08 20:52           ` Ludovic Courtès
@ 2017-06-09  7:51             ` Mathieu Othacehe
  0 siblings, 0 replies; 10+ messages in thread
From: Mathieu Othacehe @ 2017-06-09  7:51 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 27275-done


Hi,

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

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

Thanks,

Mathieu

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2017-06-09  7:52 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-06-07 12:04 bug#27275: [PATCH 0/2] Add (guix git) module Mathieu Othacehe
2017-06-07 12:05 ` bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git Mathieu Othacehe
2017-06-07 12:05   ` bug#27275: [PATCH 2/2] guix: git: Add new module Mathieu Othacehe
2017-06-07 12:21     ` Ludovic Courtès
2017-06-07 12:21   ` bug#27275: [PATCH 1/2] pull: Add a dependency to guile-git Ludovic Courtès
2017-06-07 13:58     ` Mathieu Othacehe
2017-06-08 12:06       ` Ludovic Courtès
2017-06-08 14:49         ` Mathieu Othacehe
2017-06-08 20:52           ` Ludovic Courtès
2017-06-09  7:51             ` Mathieu Othacehe

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).