From 14b392a8ad25454cfd3d929d6ae359e369a76cbf Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 10 Apr 2018 14:33:25 +0200 Subject: self: Don't substitute the '-source' derivations. With substitution enabled we would end up downloading 10+ MiB of source that's already available locally on disk. * guix/self.scm (imported-files): Pass #:options to 'computed-file'. --- guix/self.scm | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/self.scm b/guix/self.scm index c9e4a4250e..76cbe2d6e3 100644 --- a/guix/self.scm +++ b/guix/self.scm @@ -463,7 +463,10 @@ list of file-name/file-like objects suitable as inputs to 'imported-files'." (copy-file store-path final-path))) '#$files)))) - (computed-file name build)) + ;; We're just copying files around, no need to substitute or offload it. + (computed-file name build + #:options '(#:local-build? #t + #:substitutable? #f))) (define* (compiled-modules name module-tree modules #:optional -- cgit v1.2.3 From 69447b6393d6f2c3528e3964c7c5f30f710aaa85 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 10 Apr 2018 14:34:59 +0200 Subject: self: Display a new line at the end of module compilation. * guix/self.scm (compiled-modules)[build]: Add a 'newline' call at the end. --- guix/self.scm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/self.scm b/guix/self.scm index 76cbe2d6e3..dbe942cf23 100644 --- a/guix/self.scm +++ b/guix/self.scm @@ -543,7 +543,8 @@ list of file-name/file-like objects suitable as inputs to 'imported-files'." (mkdir #$output) (chdir #+module-tree) - (process-directory "." #$output)))) + (process-directory "." #$output) + (newline)))) (computed-file name build #:guile guile-for-build -- cgit v1.2.3 From e69dd8443ad2b8620c3a3db874dc50e06b0d43d0 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 10 Apr 2018 14:36:18 +0200 Subject: self: Fix package names for compilation with Guile 2.0. Reported by Ricardo Wurmus. * guix/self.scm (specification->package): Add guile2.0-{json,git,ssh}. (guile-for-build): Use 'module-ref' for Guile 2.0. --- guix/self.scm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'guix') diff --git a/guix/self.scm b/guix/self.scm index dbe942cf23..f2e912c85d 100644 --- a/guix/self.scm +++ b/guix/self.scm @@ -88,7 +88,11 @@ GUILE-VERSION (\"2.0\" or \"2.2\"), or #f if none of the packages matches." ("bzip2" (ref '(gnu packages compression) 'bzip2)) ("xz" (ref '(gnu packages compression) 'xz)) ("guix" (ref '(gnu packages package-management) - 'guix-register))))) + 'guix-register)) + ("guile2.0-json" (ref '(gnu packages guile) 'guile2.0-json)) + ("guile2.0-ssh" (ref '(gnu packages ssh) 'guile2.0-ssh)) + ("guile2.0-git" (ref '(gnu packages guile) 'guile2.0-git)) + (_ #f)))) ;no such package ;;; @@ -576,7 +580,8 @@ running Guile." (canonical-package (module-ref (resolve-interface '(gnu packages guile)) 'guile-2.2/fixed))) ("2.0" - (canonical-package (specification->package "guile@2.0"))))) + (module-ref (resolve-interface '(gnu packages guile)) + 'guile-2.0)))) (define* (guix-derivation source version #:optional (guile-version (effective-version))) -- cgit v1.2.3 From 806ff35854b3d5c0a2e906ad8d3af6a95b174de1 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 10 Apr 2018 14:37:36 +0200 Subject: self: Export '%guix-register-program' in generated (guix config). * guix/self.scm (make-config.scm): Export '%guix-register-program'. --- guix/self.scm | 1 + 1 file changed, 1 insertion(+) (limited to 'guix') diff --git a/guix/self.scm b/guix/self.scm index f2e912c85d..23d65e5545 100644 --- a/guix/self.scm +++ b/guix/self.scm @@ -393,6 +393,7 @@ list of file-name/file-like objects suitable as inputs to 'imported-files'." %guix-bug-report-address %guix-home-page-url %sbindir + %guix-register-program %libgcrypt %libz %gzip -- cgit v1.2.3 From 43176dd605ac040a290171dee5a1019cb7c7a1fc Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Tue, 10 Apr 2018 14:38:19 +0200 Subject: self: Don't use deprecated package names. * guix/self.scm (compiled-guix)[guile-json, guile-ssh]: Don't refer t "guile2.2-json" and "guile2.2-ssh", which are deprecated. --- guix/self.scm | 2 -- 1 file changed, 2 deletions(-) (limited to 'guix') diff --git a/guix/self.scm b/guix/self.scm index 23d65e5545..2275ab51a4 100644 --- a/guix/self.scm +++ b/guix/self.scm @@ -203,13 +203,11 @@ list of file-name/file-like objects suitable as inputs to 'imported-files'." (define guile-json (package-for-guile guile-version "guile-json" - "guile2.2-json" "guile2.0-json")) (define guile-ssh (package-for-guile guile-version "guile-ssh" - "guile2.2-ssh" "guile2.0-ssh")) (define guile-git -- cgit v1.2.3 From 63cab4182d60dd228dccc03c149ac01bf100301a Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 11 Apr 2018 00:22:03 +0200 Subject: self: Remove 'eval-when' from in generated (guix config). * guix/self.scm (make-config.scm): Remove unneeded 'eval-when'. --- guix/self.scm | 76 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 37 insertions(+), 39 deletions(-) (limited to 'guix') diff --git a/guix/self.scm b/guix/self.scm index 2275ab51a4..dd61322a54 100644 --- a/guix/self.scm +++ b/guix/self.scm @@ -399,45 +399,43 @@ list of file-name/file-like objects suitable as inputs to 'imported-files'." %xz %nix-instantiate)) - ;; XXX: Work around . - (eval-when (expand load eval) - #$@(map (match-lambda - ((name . value) - #~(define-public #$name #$value))) - %config-variables) - - (define %guix-package-name #$package-name) - (define %guix-version #$package-version) - (define %guix-bug-report-address #$bug-report-address) - (define %guix-home-page-url #$home-page-url) - - (define %sbindir - ;; This is used to define '%guix-register-program'. - ;; TODO: Use a derivation that builds nothing but the - ;; C++ part. - #+(and guix (file-append guix "/sbin"))) - - (define %guix-register-program - (or (getenv "GUIX_REGISTER") - (and %sbindir - (string-append %sbindir "/guix-register")))) - - (define %gzip - #+(and gzip (file-append gzip "/bin/gzip"))) - (define %bzip2 - #+(and bzip2 (file-append bzip2 "/bin/bzip2"))) - (define %xz - #+(and xz (file-append xz "/bin/xz"))) - - (define %libgcrypt - #+(and libgcrypt - (file-append libgcrypt "/lib/libgcrypt"))) - (define %libz - #+(and zlib - (file-append zlib "/lib/libz"))) - - (define %nix-instantiate ;for (guix import snix) - "nix-instantiate"))))) + #$@(map (match-lambda + ((name . value) + #~(define-public #$name #$value))) + %config-variables) + + (define %guix-package-name #$package-name) + (define %guix-version #$package-version) + (define %guix-bug-report-address #$bug-report-address) + (define %guix-home-page-url #$home-page-url) + + (define %sbindir + ;; This is used to define '%guix-register-program'. + ;; TODO: Use a derivation that builds nothing but the + ;; C++ part. + #+(and guix (file-append guix "/sbin"))) + + (define %guix-register-program + (or (getenv "GUIX_REGISTER") + (and %sbindir + (string-append %sbindir "/guix-register")))) + + (define %gzip + #+(and gzip (file-append gzip "/bin/gzip"))) + (define %bzip2 + #+(and bzip2 (file-append bzip2 "/bin/bzip2"))) + (define %xz + #+(and xz (file-append xz "/bin/xz"))) + + (define %libgcrypt + #+(and libgcrypt + (file-append libgcrypt "/lib/libgcrypt"))) + (define %libz + #+(and zlib + (file-append zlib "/lib/libz"))) + + (define %nix-instantiate ;for (guix import snix) + "nix-instantiate")))) -- cgit v1.2.3 From a1639ae9de39d5ce47e6ddfd87e792db52b44bd6 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 11 Apr 2018 00:29:47 +0200 Subject: self: 'package-for-guile' really honors GUILE-VERSION. * guix/self.scm (package-for-guile): Pass GUILE-VERSION to 'false-if-wrong-guile'. --- guix/self.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'guix') diff --git a/guix/self.scm b/guix/self.scm index dd61322a54..0730cd850d 100644 --- a/guix/self.scm +++ b/guix/self.scm @@ -69,7 +69,7 @@ GUILE-VERSION (\"2.0\" or \"2.2\"), or #f if none of the packages matches." (#f (loop rest)) ((? package? package) - (or (false-if-wrong-guile package) + (or (false-if-wrong-guile package guile-version) (loop rest)))))))) (define specification->package -- cgit v1.2.3 From 4fbd1a2b7f0db819e14d7cc862445d9ab3d0d80f Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 11 Apr 2018 00:52:40 +0200 Subject: gexp: 'scheme-file' can splice expressions. * guix/gexp.scm ()[splice?]: New field. (scheme-file): Add #:splice? and pass it to '%scheme-file'. (scheme-file-compiler): Pass SPLICE? to 'gexp->file'. (gexp->file): Add #:splice? and honor it. * tests/gexp.scm ("gexp->file + #:splice?"): New test. ("gexp->derivation & with-imported-module & computed module"): Use #:splice? #t. --- doc/guix.texi | 6 +++++- guix/gexp.scm | 39 ++++++++++++++++++++++++++------------- tests/gexp.scm | 23 +++++++++++++++++++++-- 3 files changed, 52 insertions(+), 16 deletions(-) (limited to 'guix') diff --git a/doc/guix.texi b/doc/guix.texi index 738fdf65ca..d825f39e0e 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -5221,8 +5221,12 @@ This is the declarative counterpart of @code{gexp->script}. @deffn {Monadic Procedure} gexp->file @var{name} @var{exp} @ [#:set-load-path? #t] [#:module-path %load-path] @ + [#:splice? #f] @ [#:guile (default-guile)] Return a derivation that builds a file @var{name} containing @var{exp}. +When @var{splice?} is true, @var{exp} is considered to be a list of +expressions that will be spliced in the resulting file. + When @var{set-load-path?} is true, emit code in the resulting file to set @code{%load-path} and @code{%load-compiled-path} to honor @var{exp}'s imported modules. Look up @var{exp}'s modules in @@ -5232,7 +5236,7 @@ The resulting file holds references to all the dependencies of @var{exp} or a subset thereof. @end deffn -@deffn {Scheme Procedure} scheme-file @var{name} @var{exp} +@deffn {Scheme Procedure} scheme-file @var{name} @var{exp} [#:splice? #f] Return an object representing the Scheme file @var{name} that contains @var{exp}. diff --git a/guix/gexp.scm b/guix/gexp.scm index 448eeed3f1..d26fad7e0b 100644 --- a/guix/gexp.scm +++ b/guix/gexp.scm @@ -406,23 +406,24 @@ This is the declarative counterpart of 'gexp->script'." #:guile (or guile (default-guile)))))) (define-record-type - (%scheme-file name gexp) + (%scheme-file name gexp splice?) scheme-file? (name scheme-file-name) ;string - (gexp scheme-file-gexp)) ;gexp + (gexp scheme-file-gexp) ;gexp + (splice? scheme-file-splice?)) ;Boolean -(define* (scheme-file name gexp) +(define* (scheme-file name gexp #:key splice?) "Return an object representing the Scheme file NAME that contains GEXP. This is the declarative counterpart of 'gexp->file'." - (%scheme-file name gexp)) + (%scheme-file name gexp splice?)) (define-gexp-compiler (scheme-file-compiler (file ) system target) ;; Compile FILE by returning a derivation that builds the file. (match file - (($ name gexp) - (gexp->file name gexp)))) + (($ name gexp splice?) + (gexp->file name gexp #:splice? splice?)))) ;; Appending SUFFIX to BASE's output file name. (define-record-type @@ -1162,18 +1163,26 @@ imported modules in its search path. Look up EXP's modules in MODULE-PATH." (define* (gexp->file name exp #:key (set-load-path? #t) - (module-path %load-path)) - "Return a derivation that builds a file NAME containing EXP. When -SET-LOAD-PATH? is true, emit code in the resulting file to set '%load-path' -and '%load-compiled-path' to honor EXP's imported modules. Lookup EXP's -modules in MODULE-PATH." + (module-path %load-path) + (splice? #f)) + "Return a derivation that builds a file NAME containing EXP. When SPLICE? +is true, EXP is considered to be a list of expressions that will be spliced in +the resulting file. + +When SET-LOAD-PATH? is true, emit code in the resulting file to set +'%load-path' and '%load-compiled-path' to honor EXP's imported modules. +Lookup EXP's modules in MODULE-PATH." (match (if set-load-path? (gexp-modules exp) '()) (() ;zero modules (gexp->derivation name (gexp (call-with-output-file (ungexp output) (lambda (port) - (write '(ungexp exp) port)))) + (for-each (lambda (exp) + (write exp port)) + '(ungexp (if splice? + exp + (gexp ((ungexp exp))))))))) #:local-build? #t #:substitutable? #f)) ((modules ...) @@ -1184,7 +1193,11 @@ modules in MODULE-PATH." (call-with-output-file (ungexp output) (lambda (port) (write '(ungexp set-load-path) port) - (write '(ungexp exp) port)))) + (for-each (lambda (exp) + (write exp port)) + '(ungexp (if splice? + exp + (gexp ((ungexp exp))))))))) #:module-path module-path #:local-build? #t #:substitutable? #f))))) diff --git a/tests/gexp.scm b/tests/gexp.scm index 2f8940e2c6..3c8b4624da 100644 --- a/tests/gexp.scm +++ b/tests/gexp.scm @@ -419,6 +419,24 @@ (call-with-input-file out read)) (equal? (list guile) refs))))) +(test-assertm "gexp->file + #:splice?" + (mlet* %store-monad ((exp -> (list + #~(define foo 'bar) + #~(define guile #$%bootstrap-guile))) + (guile (package-file %bootstrap-guile)) + (drv (gexp->file "splice" exp #:splice? #t)) + (out -> (derivation->output-path drv)) + (done (built-derivations (list drv))) + (refs (references* out))) + (pk 'splice out) + (return (and (equal? `((define foo 'bar) + (define guile ,guile) + ,(call-with-input-string "" read)) + (call-with-input-file out + (lambda (port) + (list (read port) (read port) (read port))))) + (equal? (list guile) refs))))) + (test-assertm "gexp->derivation" (mlet* %store-monad ((file (text-file "foo" "Hello, world!")) (exp -> (gexp @@ -700,11 +718,12 @@ (test-assertm "gexp->derivation & with-imported-module & computed module" (mlet* %store-monad - ((module -> (scheme-file "x" #~(begin + ((module -> (scheme-file "x" #~(;; splice! (define-module (foo bar) #:export (the-answer)) - (define the-answer 42)))) + (define the-answer 42)) + #:splice? #t)) (build -> (with-imported-modules `(((foo bar) => ,module) (guix build utils)) #~(begin -- cgit v1.2.3 From eb72cdf087fe51d85e0c1514ec8e669047b5d6e1 Mon Sep 17 00:00:00 2001 From: Ludovic Courtès Date: Wed, 11 Apr 2018 00:55:13 +0200 Subject: self: Produce a spliced (guix config) to placate Guile 2.0. Fixes 'guix pull' with Guile 2.0. See . * guix/self.scm (make-config.scm): Remove 'begin' in 'scheme-file' argument and pass #:splice? #t. --- guix/self.scm | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'guix') diff --git a/guix/self.scm b/guix/self.scm index 0730cd850d..6220efb397 100644 --- a/guix/self.scm +++ b/guix/self.scm @@ -384,7 +384,7 @@ list of file-name/file-like objects suitable as inputs to 'imported-files'." (define defmod 'define-module) (scheme-file "config.scm" - #~(begin + #~(;; The following expressions get spliced. (#$defmod (guix config) #:export (%guix-package-name %guix-version @@ -435,7 +435,12 @@ list of file-name/file-like objects suitable as inputs to 'imported-files'." (file-append zlib "/lib/libz"))) (define %nix-instantiate ;for (guix import snix) - "nix-instantiate")))) + "nix-instantiate")) + + ;; Guile 2.0 *requires* the 'define-module' to be at the + ;; top-level or it 'toplevel-ref' in the resulting .go file are + ;; made relative to a nonexistent anonymous module. + #:splice? #t)) -- cgit v1.2.3