1 ;;; GNU Guix --- Functional package management for GNU
2 ;;; Copyright © 2017, 2018 Ludovic Courtès <ludo@gnu.org>
4 ;;; This file is part of GNU Guix.
6 ;;; GNU Guix is free software; you can redistribute it and/or modify it
7 ;;; under the terms of the GNU General Public License as published by
8 ;;; the Free Software Foundation; either version 3 of the License, or (at
9 ;;; your option) any later version.
11 ;;; GNU Guix is distributed in the hope that it will be useful, but
12 ;;; WITHOUT ANY WARRANTY; without even the implied warranty of
13 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 ;;; GNU General Public License for more details.
16 ;;; You should have received a copy of the GNU General Public License
17 ;;; along with GNU Guix. If not, see <http://www.gnu.org/licenses/>.
19 (define-module (guix self)
20 #:use-module (guix config)
21 #:use-module (guix i18n)
22 #:use-module (guix modules)
23 #:use-module (guix gexp)
24 #:use-module (guix store)
25 #:use-module (guix monads)
26 #:use-module (guix discovery)
27 #:use-module (guix packages)
28 #:use-module (guix sets)
29 #:use-module (guix modules)
30 #:use-module ((guix build utils) #:select (find-files))
31 #:use-module ((guix build compile) #:select (%lightweight-optimizations))
32 #:use-module (srfi srfi-1)
33 #:use-module (srfi srfi-9)
34 #:use-module (ice-9 match)
35 #:export (make-config.scm
36 whole-package ;for internal use in 'guix pull'
43 ;;; Dependency handling.
46 (define* (false-if-wrong-guile package
47 #:optional (guile-version (effective-version)))
48 "Return #f if PACKAGE depends on the \"wrong\" major version of Guile (e.g.,
49 2.0 instead of 2.2), otherwise return PACKAGE."
50 (let ((guile (any (match-lambda
51 ((label (? package? dep) _ ...)
52 (and (string=? (package-name dep) "guile")
54 (package-direct-inputs package))))
56 (string-prefix? guile-version
57 (package-version guile)))
60 (define (package-for-guile guile-version . names)
61 "Return the package with one of the given NAMES that depends on
62 GUILE-VERSION (\"2.0\" or \"2.2\"), or #f if none of the packages matches."
63 (let loop ((names names))
68 (match (specification->package name)
72 (or (false-if-wrong-guile package guile-version)
75 (define specification->package
76 ;; Use our own variant of that procedure because that of (gnu packages)
77 ;; would traverse all the .scm files, which is wasteful.
78 (let ((ref (lambda (module variable)
79 (module-ref (resolve-interface module) variable))))
81 ("guile" (ref '(gnu packages commencement) 'guile-final))
82 ("guile-json" (ref '(gnu packages guile) 'guile-json))
83 ("guile-ssh" (ref '(gnu packages ssh) 'guile-ssh))
84 ("guile-git" (ref '(gnu packages guile) 'guile-git))
85 ("guile-sqlite3" (ref '(gnu packages guile) 'guile-sqlite3))
86 ("guile-gcrypt" (ref '(gnu packages gnupg) 'guile-gcrypt))
87 ("gnutls" (ref '(gnu packages tls) 'gnutls))
88 ("zlib" (ref '(gnu packages compression) 'zlib))
89 ("gzip" (ref '(gnu packages compression) 'gzip))
90 ("bzip2" (ref '(gnu packages compression) 'bzip2))
91 ("xz" (ref '(gnu packages compression) 'xz))
92 ("guile2.0-json" (ref '(gnu packages guile) 'guile2.0-json))
93 ("guile2.0-ssh" (ref '(gnu packages ssh) 'guile2.0-ssh))
94 ("guile2.0-git" (ref '(gnu packages guile) 'guile2.0-git))
95 ;; XXX: No "guile2.0-sqlite3".
96 ("guile2.0-gnutls" (ref '(gnu packages tls) 'gnutls/guile-2.0))
97 (_ #f)))) ;no such package
104 ;; Node in a DAG of build tasks. Each node maps to a derivation, but it's
105 ;; easier to express things this way.
106 (define-record-type <node>
107 (node name modules source dependencies compiled)
109 (name node-name) ;string
110 (modules node-modules) ;list of module names
111 (source node-source) ;list of source files
112 (dependencies node-dependencies) ;list of nodes
113 (compiled node-compiled)) ;node -> lowerable object
115 ;; File mappings are essentially an alist as passed to 'imported-files'.
116 (define-record-type <file-mapping>
117 (file-mapping name alist)
119 (name file-mapping-name)
120 (alist file-mapping-alist))
122 (define-gexp-compiler (file-mapping-compiler (mapping <file-mapping>)
124 ;; Here we use 'imported-files', which can arrange to directly import all
125 ;; the files instead of creating a derivation, when possible.
126 (imported-files (map (match-lambda
127 ((destination (? local-file? file))
129 (local-file-absolute-file-name file)))
130 ((destination source)
131 (cons destination source))) ;silliness
132 (file-mapping-alist mapping))
133 #:name (file-mapping-name mapping)
136 (define (node-fold proc init nodes)
137 (let loop ((nodes nodes)
143 (if (set-contains? visited head)
144 (loop tail visited result)
145 (loop tail (set-insert head visited)
146 (proc head result)))))))
148 (define (node-modules/recursive nodes)
149 (node-fold (lambda (node modules)
150 (append (node-modules node) modules))
154 (define* (closure modules #:optional (except '()))
155 (source-module-closure modules
161 (or ('guix _ ...) ('gnu _ ...)))
162 (not (member module except)))
165 (define module->import
166 ;; Return a file-name/file-like object pair for the specified module and
167 ;; suitable for 'imported-files'.
170 (let ((file (module-name->file-name module)))
173 (let ((file (module-name->file-name module)))
175 (local-file (search-path %load-path file)))))))
177 (define* (scheme-node name modules #:optional (dependencies '())
178 #:key (extra-modules '()) (extra-files '())
180 parallel? guile-for-build)
181 "Return a node that builds the given Scheme MODULES, and depends on
182 DEPENDENCIES (a list of nodes). EXTRA-MODULES is a list of additional modules
183 added to the source, and EXTRA-FILES is a list of additional files.
184 EXTENSIONS is a set of full-blown Guile packages (e.g., 'guile-json') that
185 must be present in the search path."
186 (let* ((modules (append extra-modules
188 (node-modules/recursive dependencies))))
189 (module-files (map module->import modules))
190 (source (file-mapping (string-append name "-source")
191 (append module-files extra-files))))
192 (node name modules source dependencies
193 (compiled-modules name source
194 (map car module-files)
195 (map node-source dependencies)
196 (map node-compiled dependencies)
197 #:extensions extensions
198 #:parallel? parallel?
199 #:guile-for-build guile-for-build))))
201 (define (file-imports directory sub-directory pred)
202 "List all the files matching PRED under DIRECTORY/SUB-DIRECTORY. Return a
203 list of file-name/file-like objects suitable as inputs to 'imported-files'."
205 (list (string-drop file (+ 1 (string-length directory)))
206 (local-file file #:recursive? #t)))
207 (find-files (string-append directory "/" sub-directory) pred)))
209 (define* (file-append* item file #:key (recursive? #t))
210 "Return FILE within ITEM, which may be a file name or a file-like object.
211 When ITEM is a plain file name (a string), simply return a 'local-file'
212 record with the new file name."
215 ;; This is the optimal case: we return a new "source". Thus, a
216 ;; derivation that depends on this sub-directory does not depend on ITEM
218 (local-file (string-append item "/" file)
219 #:recursive? recursive?))
220 ;; TODO: Add 'local-file?' case.
222 ;; In this case, anything that refers to the result also depends on ITEM,
223 ;; which isn't great.
224 (file-append item "/" file))))
226 (define* (locale-data source domain
227 #:optional (directory domain))
228 "Return the locale data from 'po/DIRECTORY' in SOURCE, corresponding to
229 DOMAIN, a gettext domain."
231 (module-ref (resolve-interface '(gnu packages gettext))
235 (with-imported-modules '((guix build utils))
237 (use-modules (guix build utils)
239 (ice-9 match) (ice-9 ftw))
242 #+(file-append* source (string-append "po/" directory)))
244 (define (compile language)
245 (let ((gmo (string-append #$output "/" language "/LC_MESSAGES/"
247 (mkdir-p (dirname gmo))
248 (invoke #+(file-append gettext "/bin/msgfmt")
249 "-c" "--statistics" "--verbose"
251 (string-append po-directory "/" language ".po"))))
254 ;; Return the list of languages. Note: don't read 'LINGUAS'
255 ;; because it contains things like 'en@boldquot' that do not have
256 ;; a corresponding .po file.
257 (map (cut basename <> ".po")
258 (scandir po-directory
259 (cut string-suffix? ".po" <>))))
261 (for-each compile (linguas)))))
263 (computed-file (string-append "guix-locale-" domain)
266 (define (info-manual source)
267 "Return the Info manual built from SOURCE."
269 (module-ref (resolve-interface '(gnu packages texinfo))
273 (module-ref (resolve-interface '(gnu packages graphviz))
276 (define documentation
277 (file-append* source "doc"))
280 (file-append* source "gnu/system/examples"))
283 (with-imported-modules '((guix build utils))
285 (use-modules (guix build utils))
289 ;; Create 'version.texi'.
290 ;; XXX: Can we use a more meaningful version string yet one that
291 ;; doesn't change at each commit?
292 (call-with-output-file "version.texi"
294 (let ((version "0.0-git"))
296 @set UPDATED 1 January 1970
297 @set UPDATED-MONTH January 1970
299 @set VERSION ~a\n" version version))))
301 ;; Copy configuration templates that the manual includes.
302 (for-each (lambda (template)
306 (basename template ".tmpl")
308 (find-files #$examples "\\.tmpl$"))
311 (mkdir-p (string-append #$output "/images"))
312 (for-each (lambda (dot-file)
313 (invoke #+(file-append graphviz "/bin/dot")
314 "-Tpng" "-Gratio=.9" "-Gnodesep=.005"
315 "-Granksep=.00005" "-Nfontsize=9"
316 "-Nheight=.1" "-Nwidth=.1"
317 "-o" (string-append #$output "/images/"
318 (basename dot-file ".dot")
321 (find-files (string-append #$documentation "/images")
325 (for-each (lambda (png-file)
326 (install-file png-file
327 (string-append #$output "/images")))
328 (find-files (string-append #$documentation "/images")
331 ;; Finally build the manual. Copy it the Texinfo files to $PWD and
332 ;; add a symlink to the 'images' directory so that 'makeinfo' can
333 ;; see those images and produce image references in the Info output.
334 (copy-recursively #$documentation "."
335 #:log (%make-void-port "w"))
336 (delete-file-recursively "images")
337 (symlink (string-append #$output "/images") "images")
339 (for-each (lambda (texi)
340 (unless (string=? "guix.texi" texi)
341 ;; Create 'version-LL.texi'.
342 (let* ((base (basename texi ".texi"))
343 (dot (string-index base #\.))
344 (tag (string-drop base (+ 1 dot))))
345 (symlink "version.texi"
346 (string-append "version-" tag ".texi"))))
348 (invoke #+(file-append texinfo "/bin/makeinfo")
349 texi "-I" #$documentation
351 "-o" (string-append #$output "/"
352 (basename texi ".texi")
355 (find-files "." "^guix\\.[a-z]{2}\\.texi$"))))))
357 (computed-file "guix-manual" build))
359 (define* (guix-command modules #:optional compiled-modules
360 #:key source (dependencies '())
361 guile (guile-version (effective-version)))
362 "Return the 'guix' command such that it adds MODULES and DEPENDENCIES in its
364 (define source-directories
365 (map (lambda (package)
366 (file-append package "/share/guile/site/"
370 (define object-directories
371 (map (lambda (package)
372 (file-append package "/lib/guile/"
373 guile-version "/site-ccache"))
376 (program-file "guix-command"
379 (append (filter file-exists? '#$source-directories)
382 (set! %load-compiled-path
383 (append (filter file-exists? '#$object-directories)
384 %load-compiled-path))
386 (set! %load-path (cons #$modules %load-path))
387 (set! %load-compiled-path
388 (cons (or #$compiled-modules #$modules)
389 %load-compiled-path))
391 (let ((guix-main (module-ref (resolve-interface '(guix ui))
395 (bindtextdomain "guix"
396 #$(locale-data source "guix"))
397 (bindtextdomain "guix-packages"
398 #$(locale-data source
403 ;; XXX: It would be more convenient to change it to:
404 ;; (exit (apply guix-main (command-line)))
405 (apply guix-main (command-line))))
408 (define (miscellaneous-files source)
409 "Return data files taken from SOURCE."
410 (file-mapping "guix-misc"
411 `(("etc/bash_completion.d/guix"
412 ,(file-append* source "/etc/completion/bash/guix"))
413 ("etc/bash_completion.d/guix-daemon"
414 ,(file-append* source "/etc/completion/bash/guix-daemon"))
415 ("share/zsh/site-functions/_guix"
416 ,(file-append* source "/etc/completion/zsh/_guix"))
417 ("share/fish/vendor_completions.d/guix.fish"
418 ,(file-append* source "/etc/completion/fish/guix.fish"))
419 ("share/guix/hydra.gnu.org.pub"
420 ,(file-append* source
421 "/etc/substitutes/hydra.gnu.org.pub"))
422 ("share/guix/berlin.guixsd.org.pub"
423 ,(file-append* source "/etc/substitutes/berlin.guixsd.org.pub")))))
425 (define* (whole-package name modules dependencies
427 (guile-version (effective-version))
429 info daemon miscellany
431 (command (guix-command modules
432 #:dependencies dependencies
434 #:guile-version guile-version)))
435 "Return the whole Guix package NAME that uses MODULES, a derivation of all
436 the modules, and DEPENDENCIES, a list of packages depended on. COMMAND is the
437 'guix' program to use; INFO is the Info manual. When COMPILED-MODULES is
438 true, it is linked as 'lib/guile/X.Y/site-ccache'; otherwise, .go files are
439 assumed to be part of MODULES."
441 (with-imported-modules '((guix build utils))
443 (use-modules (guix build utils))
445 (mkdir-p (string-append #$output "/bin"))
447 (string-append #$output "/bin/guix"))
450 (symlink (string-append #$daemon "/bin/guix-daemon")
451 (string-append #$output "/bin/guix-daemon")))
453 (let ((modules (string-append #$output
455 (effective-version)))
457 (mkdir-p (dirname modules))
458 (symlink #$modules modules)
461 (string-append #$output
465 (copy-recursively #$miscellany #$output
466 #:log (%make-void-port "w")))
469 (when #$compiled-modules
470 (let ((modules (string-append #$output "/lib/guile/"
473 (mkdir-p (dirname modules))
474 (symlink #$compiled-modules modules)))))))
476 (define* (compiled-guix source #:key (version %guix-version)
478 (name (string-append "guix-" version))
479 (guile-version (effective-version))
480 (guile-for-build (guile-for-build guile-version))
481 (zlib (specification->package "zlib"))
482 (gzip (specification->package "gzip"))
483 (bzip2 (specification->package "bzip2"))
484 (xz (specification->package "xz"))
485 (guix (specification->package "guix")))
486 "Return a file-like object that contains a compiled Guix."
488 (package-for-guile guile-version
493 (package-for-guile guile-version
498 (package-for-guile guile-version
502 (define guile-sqlite3
503 (package-for-guile guile-version
508 (package-for-guile guile-version
512 (package-for-guile guile-version
513 "gnutls" "guile2.0-gnutls"))
516 (match (append-map (lambda (package)
517 (cons (list "x" package)
518 (package-transitive-propagated-inputs package)))
519 (list guile-gcrypt gnutls guile-git guile-json
520 guile-ssh guile-sqlite3))
521 (((labels packages _ ...) ...)
524 (define *core-modules*
525 (scheme-node "guix-core"
532 (guix build-system gnu)
533 (guix build-system trivial)
534 (guix build profiles)
535 (guix build gnu-build-system))
537 ;; Provide a dummy (guix config) with the default version
538 ;; number, storedir, etc. This is so that "guix-core" is the
539 ;; same across all installations and doesn't need to be
540 ;; rebuilt when the version changes, which in turn means we
541 ;; can have substitutes for it.
543 `(((guix config) => ,(make-config.scm)))
545 ;; (guix man-db) is needed at build-time by (guix profiles)
546 ;; but we don't need to compile it; not compiling it allows
547 ;; us to avoid an extra dependency on guile-gdbm-ffi.
549 `(("guix/man-db.scm" ,(local-file "../guix/man-db.scm"))
550 ("guix/store/schema.sql"
551 ,(local-file "../guix/store/schema.sql")))
553 #:extensions (list guile-gcrypt)
554 #:guile-for-build guile-for-build))
556 (define *extra-modules*
557 (scheme-node "guix-extra"
558 (filter-map (match-lambda
559 (('guix 'scripts _ ..1) #f)
562 (scheme-modules* source "guix"))
563 (list *core-modules*)
564 #:extensions dependencies
565 #:guile-for-build guile-for-build))
567 (define *core-package-modules*
568 (scheme-node "guix-packages-base"
571 (list *core-modules* *extra-modules*)
572 #:extensions dependencies
574 ;; Add all the non-Scheme files here. We must do it here so
575 ;; that 'search-patches' & co. can find them. Ideally we'd
576 ;; keep them next to the .scm files that use them but it's
577 ;; difficult to do (XXX).
579 (file-imports source "gnu/packages"
581 (and (eq? 'regular (stat:type stat))
582 (not (string-suffix? ".scm" file))
583 (not (string-suffix? ".go" file))
584 (not (string-prefix? ".#" file))
585 (not (string-suffix? "~" file)))))
586 #:guile-for-build guile-for-build))
588 (define *package-modules*
589 (scheme-node "guix-packages"
590 (scheme-modules* source "gnu/packages")
591 (list *core-modules* *extra-modules* *core-package-modules*)
592 #:extensions dependencies
593 #:guile-for-build guile-for-build))
595 (define *system-modules*
596 (scheme-node "guix-system"
599 ,@(scheme-modules* source "gnu/system")
600 ,@(scheme-modules* source "gnu/services"))
601 (list *core-package-modules* *package-modules*
602 *extra-modules* *core-modules*)
603 #:extensions dependencies
605 (append (file-imports source "gnu/system/examples"
608 ;; Build-side code that we don't build. Some of
609 ;; these depend on guile-rsvg, the Shepherd, etc.
610 (file-imports source "gnu/build" (const #t)))
614 (define *cli-modules*
615 (scheme-node "guix-cli"
616 (scheme-modules* source "/guix/scripts")
617 (list *core-modules* *extra-modules*
618 *core-package-modules* *package-modules*
620 #:extensions dependencies
621 #:guile-for-build guile-for-build))
624 (scheme-node "guix-config"
628 => ,(make-config.scm #:zlib zlib
637 %guix-bug-report-address
639 %guix-home-page-url)))
640 #:guile-for-build guile-for-build))
642 (define (built-modules node-subset)
643 (directory-union (string-append name "-modules")
644 (append-map node-subset
646 ;; Note: *CONFIG* comes first so that it
647 ;; overrides the (guix config) module that
648 ;; comes with *CORE-MODULES*.
653 *core-package-modules*
657 ;; Silently choose the first entry upon collision so that
658 ;; we choose *CONFIG*.
659 #:resolve-collision 'first
661 ;; When we do (add-to-store "utils.scm"), "utils.scm" must
662 ;; be a regular file, not a symlink. Thus, arrange so that
663 ;; regular files appear as regular files in the final
668 ;; Version 0 of 'guix pull' meant we'd just return Scheme modules.
669 ;; Version 1 is when we return the full package.
670 (cond ((= 1 pull-version)
671 ;; The whole package, with a standard file hierarchy.
672 (let* ((modules (built-modules (compose list node-source)))
673 (compiled (built-modules (compose list node-compiled)))
674 (command (guix-command modules compiled
676 #:dependencies dependencies
677 #:guile guile-for-build
678 #:guile-version guile-version)))
679 (whole-package name modules dependencies
680 #:compiled-modules compiled
682 #:guile guile-for-build
684 ;; Include 'guix-daemon'. XXX: Here we inject an
685 ;; older snapshot of guix-daemon, but that's a good
686 ;; enough approximation for now.
687 #:daemon (module-ref (resolve-interface
692 #:info (info-manual source)
693 #:miscellany (miscellaneous-files source)
694 #:guile-version guile-version)))
696 ;; Legacy 'guix pull': return the .scm and .go files as one
698 (built-modules (lambda (node)
699 (list (node-source node)
700 (node-compiled node)))))
702 ;; Unsupported 'guix pull' version.
707 ;;; Generating (guix config).
710 (define %dependency-variables
711 ;; (guix config) variables corresponding to dependencies.
712 '(%libz %xz %gzip %bzip2))
714 (define %persona-variables
715 ;; (guix config) variables that define Guix's persona.
718 %guix-bug-report-address
719 %guix-home-page-url))
721 (define %config-variables
722 ;; (guix config) variables corresponding to Guix configuration.
723 (letrec-syntax ((variables (syntax-rules ()
726 ((_ variable rest ...)
727 (cons `(variable . ,variable)
728 (variables rest ...))))))
729 (variables %localstatedir %storedir %sysconfdir %system)))
731 (define* (make-config.scm #:key zlib gzip xz bzip2
732 (package-name "GNU Guix")
733 (package-version "0")
734 (bug-report-address "bug-guix@gnu.org")
735 (home-page-url "https://gnu.org/s/guix"))
737 ;; Hack so that Geiser is not confused.
738 (define defmod 'define-module)
740 (scheme-file "config.scm"
741 #~(;; The following expressions get spliced.
742 (#$defmod (guix config)
743 #:export (%guix-package-name
745 %guix-bug-report-address
749 %store-database-directory
756 #$@(map (match-lambda
758 #~(define-public #$name #$value)))
761 (define %store-directory
762 (or (and=> (getenv "NIX_STORE_DIR") canonicalize-path)
765 (define %state-directory
766 ;; This must match `NIX_STATE_DIR' as defined in
768 (or (getenv "NIX_STATE_DIR")
769 (string-append %localstatedir "/guix")))
771 (define %store-database-directory
772 (or (getenv "NIX_DB_DIR")
773 (string-append %state-directory "/db")))
775 (define %config-directory
776 ;; This must match `GUIX_CONFIGURATION_DIRECTORY' as
777 ;; defined in `nix/local.mk'.
778 (or (getenv "GUIX_CONFIGURATION_DIRECTORY")
779 (string-append %sysconfdir "/guix")))
781 (define %guix-package-name #$package-name)
782 (define %guix-version #$package-version)
783 (define %guix-bug-report-address #$bug-report-address)
784 (define %guix-home-page-url #$home-page-url)
787 #+(and gzip (file-append gzip "/bin/gzip")))
789 #+(and bzip2 (file-append bzip2 "/bin/bzip2")))
791 #+(and xz (file-append xz "/bin/xz")))
795 (file-append zlib "/lib/libz"))))
797 ;; Guile 2.0 *requires* the 'define-module' to be at the
798 ;; top-level or the 'toplevel-ref' in the resulting .go file are
799 ;; made relative to a nonexistent anonymous module.
808 (define* (compiled-modules name module-tree module-files
811 (dependencies-compiled '())
813 (extensions '()) ;full-blown Guile packages
816 "Build all the MODULE-FILES from MODULE-TREE. MODULE-FILES must be a list
817 like '(\"guix/foo.scm\" \"gnu/bar.scm\") and MODULE-TREE is the directory
818 containing MODULE-FILES and possibly other files as well."
819 ;; This is a non-monadic, enhanced version of 'compiled-file' from (guix
822 (with-imported-modules (source-module-closure
823 '((guix build compile)
826 (use-modules (srfi srfi-26)
833 (define (regular? file)
834 (not (member file '("." ".."))))
836 (define (report-load file total completed)
839 "loading...\t~5,1f% of ~d files" ;FIXME: i18n
840 (* 100. (/ completed total)) total)
843 (define (report-compilation file total completed)
845 (format #t "compiling...\t~5,1f% of ~d files" ;FIXME: i18n
846 (* 100. (/ completed total)) total)
849 (define (process-directory directory files output)
850 ;; Hide compilation warnings.
851 (parameterize ((current-warning-port (%make-void-port "w")))
852 (compile-files directory #$output files
853 #:workers (parallel-job-count)
854 #:report-load report-load
855 #:report-compilation report-compilation)))
857 (setvbuf (current-output-port) _IONBF)
858 (setvbuf (current-error-port) _IONBF)
860 (set! %load-path (cons #+module-tree %load-path))
862 (append '#+dependencies
863 (map (lambda (extension)
864 (string-append extension "/share/guile/site/"
865 (effective-version)))
869 (set! %load-compiled-path
870 (append '#+dependencies-compiled
871 (map (lambda (extension)
872 (string-append extension "/lib/guile/"
876 %load-compiled-path))
878 ;; Load the compiler modules upfront.
882 (chdir #+module-tree)
883 (process-directory "." '#+module-files #$output)
886 (computed-file name build
887 #:guile guile-for-build
889 `(#:local-build? #f ;allow substitutes
891 ;; Don't annoy people about _IONBF deprecation.
892 ;; Initialize 'terminal-width' in (system repl debug)
893 ;; to a large-enough value to make backtrace more
895 #:env-vars (("GUILE_WARN_DEPRECATED" . "no")
896 ("COLUMNS" . "200")))))
903 (define (guile-for-build version)
904 "Return a derivation for Guile 2.0 or 2.2, whichever matches the currently
906 (define canonical-package ;soft reference
907 (module-ref (resolve-interface '(gnu packages base))
912 (canonical-package (module-ref (resolve-interface '(gnu packages guile))
915 (module-ref (resolve-interface '(gnu packages guile))
918 (define* (guix-derivation source version
919 #:optional (guile-version (effective-version))
920 #:key (pull-version 0))
921 "Return, as a monadic value, the derivation to build the Guix from SOURCE
922 for GUILE-VERSION. Use VERSION as the version string. PULL-VERSION specifies
923 the version of the 'guix pull' protocol. Return #f if this PULL-VERSION value
925 (define (shorten version)
926 (if (and (string-every char-set:hex-digit version)
927 (> (string-length version) 9))
928 (string-take version 9) ;Git commit
932 ;; When PULL-VERSION >= 1, produce a self-contained Guix and use Guile 2.2
934 (guile-for-build (if (>= pull-version 1)
939 (set-guile-for-build guile)
940 (let ((guix (compiled-guix source
942 #:name (string-append "guix-"
944 #:pull-version pull-version
945 #:guile-version (if (>= pull-version 1)
947 #:guile-for-build guile)))