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 ("gnutls" (ref '(gnu packages tls) 'gnutls))
87 ("libgcrypt" (ref '(gnu packages gnupg) 'libgcrypt))
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 (define (node-fold proc init nodes)
116 (let loop ((nodes nodes)
122 (if (set-contains? visited head)
123 (loop tail visited result)
124 (loop tail (set-insert head visited)
125 (proc head result)))))))
127 (define (node-modules/recursive nodes)
128 (node-fold (lambda (node modules)
129 (append (node-modules node) modules))
133 (define* (closure modules #:optional (except '()))
134 (source-module-closure modules
140 (or ('guix _ ...) ('gnu _ ...)))
141 (not (member module except)))
144 (define module->import
145 ;; Return a file-name/file-like object pair for the specified module and
146 ;; suitable for 'imported-files'.
149 (let ((file (module-name->file-name module)))
152 (let ((file (module-name->file-name module)))
154 (local-file (search-path %load-path file)))))))
156 (define* (scheme-node name modules #:optional (dependencies '())
157 #:key (extra-modules '()) (extra-files '())
159 parallel? guile-for-build)
160 "Return a node that builds the given Scheme MODULES, and depends on
161 DEPENDENCIES (a list of nodes). EXTRA-MODULES is a list of additional modules
162 added to the source, and EXTRA-FILES is a list of additional files.
163 EXTENSIONS is a set of full-blown Guile packages (e.g., 'guile-json') that
164 must be present in the search path."
165 (let* ((modules (append extra-modules
167 (node-modules/recursive dependencies))))
168 (module-files (map module->import modules))
169 (source (imported-files (string-append name "-source")
170 (append module-files extra-files))))
171 (node name modules source dependencies
172 (compiled-modules name source
173 (map car module-files)
174 (map node-source dependencies)
175 (map node-compiled dependencies)
176 #:extensions extensions
177 #:parallel? parallel?
178 #:guile-for-build guile-for-build))))
180 (define (file-imports directory sub-directory pred)
181 "List all the files matching PRED under DIRECTORY/SUB-DIRECTORY. Return a
182 list of file-name/file-like objects suitable as inputs to 'imported-files'."
184 (list (string-drop file (+ 1 (string-length directory)))
185 (local-file file #:recursive? #t)))
186 (find-files (string-append directory "/" sub-directory) pred)))
188 (define (scheme-modules* directory sub-directory)
189 "Return the list of module names found under SUB-DIRECTORY in DIRECTORY."
190 (let ((prefix (string-length directory)))
192 (file-name->module-name (string-drop file prefix)))
193 (scheme-files (string-append directory "/" sub-directory)))))
195 (define* (sub-directory item sub-directory)
196 "Return SUB-DIRECTORY within ITEM, which may be a file name or a file-like
200 ;; This is the optimal case: we return a new "source". Thus, a
201 ;; derivation that depends on this sub-directory does not depend on ITEM
203 (local-file (string-append item "/" sub-directory)
205 ;; TODO: Add 'local-file?' case.
207 ;; In this case, anything that refers to the result also depends on ITEM,
208 ;; which isn't great.
209 (file-append item "/" sub-directory))))
211 (define* (locale-data source domain
212 #:optional (directory domain))
213 "Return the locale data from 'po/DIRECTORY' in SOURCE, corresponding to
214 DOMAIN, a gettext domain."
216 (module-ref (resolve-interface '(gnu packages gettext))
220 (with-imported-modules '((guix build utils))
222 (use-modules (guix build utils)
224 (ice-9 match) (ice-9 ftw))
227 #+(sub-directory source (string-append "po/" directory)))
229 (define (compile language)
230 (let ((gmo (string-append #$output "/" language "/LC_MESSAGES/"
232 (mkdir-p (dirname gmo))
233 (invoke #+(file-append gettext "/bin/msgfmt")
234 "-c" "--statistics" "--verbose"
236 (string-append po-directory "/" language ".po"))))
239 ;; Return the list of languages. Note: don't read 'LINGUAS'
240 ;; because it contains things like 'en@boldquot' that do not have
241 ;; a corresponding .po file.
242 (map (cut basename <> ".po")
243 (scandir po-directory
244 (cut string-suffix? ".po" <>))))
246 (for-each compile (linguas)))))
248 (computed-file (string-append "guix-locale-" domain)
251 (define (info-manual source)
252 "Return the Info manual built from SOURCE."
254 (module-ref (resolve-interface '(gnu packages texinfo))
258 (module-ref (resolve-interface '(gnu packages graphviz))
261 (define documentation
262 (sub-directory source "doc"))
265 (sub-directory source "gnu/system/examples"))
268 (with-imported-modules '((guix build utils))
270 (use-modules (guix build utils))
274 ;; Create 'version.texi'.
275 ;; XXX: Can we use a more meaningful version string yet one that
276 ;; doesn't change at each commit?
277 (call-with-output-file "version.texi"
279 (let ((version "0.0-git)"))
281 @set UPDATED 1 January 1970
282 @set UPDATED-MONTH January 1970
284 @set VERSION ~a\n" version version))))
286 ;; Copy configuration templates that the manual includes.
287 (for-each (lambda (template)
291 (basename template ".tmpl")
293 (find-files #$examples "\\.tmpl$"))
296 (mkdir-p (string-append #$output "/images"))
297 (for-each (lambda (dot-file)
298 (invoke #+(file-append graphviz "/bin/dot")
299 "-Tpng" "-Gratio=.9" "-Gnodesep=.005"
300 "-Granksep=.00005" "-Nfontsize=9"
301 "-Nheight=.1" "-Nwidth=.1"
302 "-o" (string-append #$output "/images/"
303 (basename dot-file ".dot")
306 (find-files (string-append #$documentation "/images")
310 (for-each (lambda (png-file)
311 (install-file png-file
312 (string-append #$output "/images")))
313 (find-files (string-append #$documentation "/images")
316 ;; Finally build the manual. Copy it the Texinfo files to $PWD and
317 ;; add a symlink to the 'images' directory so that 'makeinfo' can
318 ;; see those images and produce image references in the Info output.
319 (copy-recursively #$documentation "."
320 #:log (%make-void-port "w"))
321 (delete-file-recursively "images")
322 (symlink (string-append #$output "/images") "images")
324 (for-each (lambda (texi)
325 (unless (string=? "guix.texi" texi)
326 ;; Create 'version-LL.texi'.
327 (let* ((base (basename texi ".texi"))
328 (dot (string-index base #\.))
329 (tag (string-drop base (+ 1 dot))))
330 (symlink "version.texi"
331 (string-append "version-" tag ".texi"))))
333 (invoke #+(file-append texinfo "/bin/makeinfo")
334 texi "-I" #$documentation
336 "-o" (string-append #$output "/"
337 (basename texi ".texi")
340 (find-files "." "^guix\\.[a-z]{2}\\.texi$"))))))
342 (computed-file "guix-manual" build))
344 (define* (guix-command modules #:optional compiled-modules
345 #:key source (dependencies '())
346 (guile-version (effective-version)))
347 "Return the 'guix' command such that it adds MODULES and DEPENDENCIES in its
349 (program-file "guix-command"
352 (append '#$(map (lambda (package)
359 (set! %load-compiled-path
360 (append '#$(map (lambda (package)
361 (file-append package "/lib/guile/"
365 %load-compiled-path))
367 (set! %load-path (cons #$modules %load-path))
368 (set! %load-compiled-path
369 (cons (or #$compiled-modules #$modules)
370 %load-compiled-path))
372 (let ((guix-main (module-ref (resolve-interface '(guix ui))
376 (bindtextdomain "guix"
377 #$(locale-data source "guix"))
378 (bindtextdomain "guix-packages"
379 #$(locale-data source
384 ;; XXX: It would be more convenient to change it to:
385 ;; (exit (apply guix-main (command-line)))
386 (apply guix-main (command-line))))))
388 (define* (whole-package name modules dependencies
390 (guile-version (effective-version))
393 (command (guix-command modules
394 #:dependencies dependencies
395 #:guile-version guile-version)))
396 "Return the whole Guix package NAME that uses MODULES, a derivation of all
397 the modules, and DEPENDENCIES, a list of packages depended on. COMMAND is the
398 'guix' program to use; INFO is the Info manual. When COMPILED-MODULES is
399 true, it is linked as 'lib/guile/X.Y/site-ccache'; otherwise, .go files are
400 assumed to be part of MODULES."
402 (with-imported-modules '((guix build utils))
404 (use-modules (guix build utils))
405 (mkdir-p (string-append #$output "/bin"))
407 (string-append #$output "/bin/guix"))
410 (symlink (string-append #$daemon "/bin/guix-daemon")
411 (string-append #$output "/bin/guix-daemon")))
413 (let ((modules (string-append #$output
415 (effective-version)))
417 (mkdir-p (dirname modules))
418 (symlink #$modules modules)
421 (string-append #$output
425 (when #$compiled-modules
426 (let ((modules (string-append #$output "/lib/guile/"
429 (mkdir-p (dirname modules))
430 (symlink #$compiled-modules modules)))))))
432 (define* (compiled-guix source #:key (version %guix-version)
434 (name (string-append "guix-" version))
435 (guile-version (effective-version))
436 (guile-for-build (guile-for-build guile-version))
437 (libgcrypt (specification->package "libgcrypt"))
438 (zlib (specification->package "zlib"))
439 (gzip (specification->package "gzip"))
440 (bzip2 (specification->package "bzip2"))
441 (xz (specification->package "xz"))
442 (guix (specification->package "guix")))
443 "Return a file-like object that contains a compiled Guix."
445 (package-for-guile guile-version
450 (package-for-guile guile-version
455 (package-for-guile guile-version
459 (define guile-sqlite3
460 (package-for-guile guile-version
465 (package-for-guile guile-version
466 "gnutls" "guile2.0-gnutls"))
469 (match (append-map (lambda (package)
470 (cons (list "x" package)
471 (package-transitive-propagated-inputs package)))
472 (list gnutls guile-git guile-json
473 guile-ssh guile-sqlite3))
474 (((labels packages _ ...) ...)
477 (define *core-modules*
478 (scheme-node "guix-core"
485 (guix build-system gnu)
486 (guix build-system trivial)
487 (guix build profiles)
488 (guix build gnu-build-system))
490 ;; Provide a dummy (guix config) with the default version
491 ;; number, storedir, etc. This is so that "guix-core" is the
492 ;; same across all installations and doesn't need to be
493 ;; rebuilt when the version changes, which in turn means we
494 ;; can have substitutes for it.
497 => ,(make-config.scm #:libgcrypt
498 (specification->package
501 ;; (guix man-db) is needed at build-time by (guix profiles)
502 ;; but we don't need to compile it; not compiling it allows
503 ;; us to avoid an extra dependency on guile-gdbm-ffi.
505 `(("guix/man-db.scm" ,(local-file "../guix/man-db.scm"))
506 ("guix/store/schema.sql"
507 ,(local-file "../guix/store/schema.sql")))
509 #:guile-for-build guile-for-build))
511 (define *extra-modules*
512 (scheme-node "guix-extra"
513 (filter-map (match-lambda
514 (('guix 'scripts _ ..1) #f)
517 (scheme-modules* source "guix"))
518 (list *core-modules*)
519 #:extensions dependencies
520 #:guile-for-build guile-for-build))
522 (define *core-package-modules*
523 (scheme-node "guix-packages-base"
526 (list *core-modules* *extra-modules*)
527 #:extensions dependencies
529 ;; Add all the non-Scheme files here. We must do it here so
530 ;; that 'search-patches' & co. can find them. Ideally we'd
531 ;; keep them next to the .scm files that use them but it's
532 ;; difficult to do (XXX).
534 (file-imports source "gnu/packages"
536 (and (eq? 'regular (stat:type stat))
537 (not (string-suffix? ".scm" file))
538 (not (string-suffix? ".go" file))
539 (not (string-prefix? ".#" file))
540 (not (string-suffix? "~" file)))))
541 #:guile-for-build guile-for-build))
543 (define *package-modules*
544 (scheme-node "guix-packages"
545 (scheme-modules* source "gnu/packages")
546 (list *core-modules* *extra-modules* *core-package-modules*)
547 #:extensions dependencies
548 #:guile-for-build guile-for-build))
550 (define *system-modules*
551 (scheme-node "guix-system"
554 ,@(scheme-modules* source "gnu/system")
555 ,@(scheme-modules* source "gnu/services"))
556 (list *core-package-modules* *package-modules*
557 *extra-modules* *core-modules*)
558 #:extensions dependencies
560 (append (file-imports source "gnu/system/examples"
563 ;; Build-side code that we don't build. Some of
564 ;; these depend on guile-rsvg, the Shepherd, etc.
565 (file-imports source "gnu/build" (const #t)))
569 (define *cli-modules*
570 (scheme-node "guix-cli"
571 (scheme-modules* source "/guix/scripts")
572 (list *core-modules* *extra-modules*
573 *core-package-modules* *package-modules*
575 #:extensions dependencies
576 #:guile-for-build guile-for-build))
579 (scheme-node "guix-config"
583 => ,(make-config.scm #:libgcrypt libgcrypt
593 %guix-bug-report-address
595 %guix-home-page-url)))
596 #:guile-for-build guile-for-build))
598 (define (built-modules node-subset)
599 (directory-union (string-append name "-modules")
600 (append-map node-subset
602 ;; Note: *CONFIG* comes first so that it
603 ;; overrides the (guix config) module that
604 ;; comes with *CORE-MODULES*.
609 *core-package-modules*
613 ;; Silently choose the first entry upon collision so that
614 ;; we choose *CONFIG*.
615 #:resolve-collision 'first
617 ;; When we do (add-to-store "utils.scm"), "utils.scm" must
618 ;; be a regular file, not a symlink. Thus, arrange so that
619 ;; regular files appear as regular files in the final
624 ;; Version 0 of 'guix pull' meant we'd just return Scheme modules.
625 ;; Version 1 is when we return the full package.
626 (cond ((= 1 pull-version)
627 ;; The whole package, with a standard file hierarchy.
628 (let* ((modules (built-modules (compose list node-source)))
629 (compiled (built-modules (compose list node-compiled)))
630 (command (guix-command modules compiled
632 #:dependencies dependencies
633 #:guile-version guile-version)))
634 (whole-package name modules dependencies
635 #:compiled-modules compiled
638 ;; Include 'guix-daemon'. XXX: Here we inject an
639 ;; older snapshot of guix-daemon, but that's a good
640 ;; enough approximation for now.
641 #:daemon (module-ref (resolve-interface
646 #:info (info-manual source)
647 #:guile-version guile-version)))
649 ;; Legacy 'guix pull': return the .scm and .go files as one
651 (built-modules (lambda (node)
652 (list (node-source node)
653 (node-compiled node)))))
655 ;; Unsupported 'guix pull' version.
660 ;;; Generating (guix config).
663 (define %dependency-variables
664 ;; (guix config) variables corresponding to dependencies.
665 '(%libgcrypt %libz %xz %gzip %bzip2))
667 (define %persona-variables
668 ;; (guix config) variables that define Guix's persona.
671 %guix-bug-report-address
672 %guix-home-page-url))
674 (define %config-variables
675 ;; (guix config) variables corresponding to Guix configuration.
676 (letrec-syntax ((variables (syntax-rules ()
679 ((_ variable rest ...)
680 (cons `(variable . ,variable)
681 (variables rest ...))))))
682 (variables %localstatedir %storedir %sysconfdir %system)))
684 (define* (make-config.scm #:key libgcrypt zlib gzip xz bzip2
685 (package-name "GNU Guix")
686 (package-version "0")
687 (bug-report-address "bug-guix@gnu.org")
688 (home-page-url "https://gnu.org/s/guix"))
690 ;; Hack so that Geiser is not confused.
691 (define defmod 'define-module)
693 (scheme-file "config.scm"
694 #~(;; The following expressions get spliced.
695 (#$defmod (guix config)
696 #:export (%guix-package-name
698 %guix-bug-report-address
702 %store-database-directory
710 #$@(map (match-lambda
712 #~(define-public #$name #$value)))
715 (define %store-directory
716 (or (and=> (getenv "NIX_STORE_DIR") canonicalize-path)
719 (define %state-directory
720 ;; This must match `NIX_STATE_DIR' as defined in
722 (or (getenv "NIX_STATE_DIR")
723 (string-append %localstatedir "/guix")))
725 (define %store-database-directory
726 (or (getenv "NIX_DB_DIR")
727 (string-append %state-directory "/db")))
729 (define %config-directory
730 ;; This must match `GUIX_CONFIGURATION_DIRECTORY' as
731 ;; defined in `nix/local.mk'.
732 (or (getenv "GUIX_CONFIGURATION_DIRECTORY")
733 (string-append %sysconfdir "/guix")))
735 (define %guix-package-name #$package-name)
736 (define %guix-version #$package-version)
737 (define %guix-bug-report-address #$bug-report-address)
738 (define %guix-home-page-url #$home-page-url)
741 #+(and gzip (file-append gzip "/bin/gzip")))
743 #+(and bzip2 (file-append bzip2 "/bin/bzip2")))
745 #+(and xz (file-append xz "/bin/xz")))
749 (file-append libgcrypt "/lib/libgcrypt")))
752 (file-append zlib "/lib/libz"))))
754 ;; Guile 2.0 *requires* the 'define-module' to be at the
755 ;; top-level or the 'toplevel-ref' in the resulting .go file are
756 ;; made relative to a nonexistent anonymous module.
765 (define (imported-files name files)
766 ;; This is a non-monadic, simplified version of 'imported-files' from (guix
770 (((file1 . _) (file2 . _))
771 (string=? file1 file2))))
774 (with-imported-modules (source-module-closure
775 '((guix build utils)))
777 (use-modules (ice-9 match)
780 (mkdir (ungexp output)) (chdir (ungexp output))
781 (for-each (match-lambda
782 ((final-path store-path)
783 (mkdir-p (dirname final-path))
785 ;; Note: We need regular files to be regular files, not
786 ;; symlinks, as this makes a difference for
788 (copy-file store-path final-path)))
789 '#$(delete-duplicates files same-target?)))))
791 ;; We're just copying files around, no need to substitute or offload it.
792 (computed-file name build
793 #:options '(#:local-build? #t
795 #:env-vars (("COLUMNS" . "200")))))
797 (define* (compiled-modules name module-tree module-files
800 (dependencies-compiled '())
802 (extensions '()) ;full-blown Guile packages
805 "Build all the MODULE-FILES from MODULE-TREE. MODULE-FILES must be a list
806 like '(\"guix/foo.scm\" \"gnu/bar.scm\") and MODULE-TREE is the directory
807 containing MODULE-FILES and possibly other files as well."
808 ;; This is a non-monadic, enhanced version of 'compiled-file' from (guix
811 (with-imported-modules (source-module-closure
812 '((guix build compile)
815 (use-modules (srfi srfi-26)
822 (define (regular? file)
823 (not (member file '("." ".."))))
825 (define (report-load file total completed)
828 "loading...\t~5,1f% of ~d files" ;FIXME: i18n
829 (* 100. (/ completed total)) total)
832 (define (report-compilation file total completed)
834 (format #t "compiling...\t~5,1f% of ~d files" ;FIXME: i18n
835 (* 100. (/ completed total)) total)
838 (define (process-directory directory files output)
839 ;; Hide compilation warnings.
840 (parameterize ((current-warning-port (%make-void-port "w")))
841 (compile-files directory #$output files
842 #:workers (parallel-job-count)
843 #:report-load report-load
844 #:report-compilation report-compilation)))
846 (setvbuf (current-output-port) _IONBF)
847 (setvbuf (current-error-port) _IONBF)
849 (set! %load-path (cons #+module-tree %load-path))
851 (append '#+dependencies
852 (map (lambda (extension)
853 (string-append extension "/share/guile/site/"
854 (effective-version)))
858 (set! %load-compiled-path
859 (append '#+dependencies-compiled
860 (map (lambda (extension)
861 (string-append extension "/lib/guile/"
865 %load-compiled-path))
867 ;; Load the compiler modules upfront.
871 (chdir #+module-tree)
872 (process-directory "." '#+module-files #$output)
875 (computed-file name build
876 #:guile guile-for-build
878 `(#:local-build? #f ;allow substitutes
880 ;; Don't annoy people about _IONBF deprecation.
881 ;; Initialize 'terminal-width' in (system repl debug)
882 ;; to a large-enough value to make backtrace more
884 #:env-vars (("GUILE_WARN_DEPRECATED" . "no")
885 ("COLUMNS" . "200")))))
892 (define (guile-for-build version)
893 "Return a derivation for Guile 2.0 or 2.2, whichever matches the currently
895 (define canonical-package ;soft reference
896 (module-ref (resolve-interface '(gnu packages base))
901 ;; Gross hack to avoid ABI incompatibilities (see
902 ;; <https://bugs.gnu.org/29570>.)
903 (module-ref (resolve-interface '(gnu packages guile))
906 (canonical-package (module-ref (resolve-interface '(gnu packages guile))
909 (module-ref (resolve-interface '(gnu packages guile))
912 (define* (guix-derivation source version
913 #:optional (guile-version (effective-version))
914 #:key (pull-version 0))
915 "Return, as a monadic value, the derivation to build the Guix from SOURCE
916 for GUILE-VERSION. Use VERSION as the version string. PULL-VERSION specifies
917 the version of the 'guix pull' protocol. Return #f if this PULL-VERSION value
919 (define (shorten version)
920 (if (and (string-every char-set:hex-digit version)
921 (> (string-length version) 9))
922 (string-take version 9) ;Git commit
926 (guile-for-build guile-version))
929 (set-guile-for-build guile)
930 (let ((guix (compiled-guix source
932 #:name (string-append "guix-"
934 #:pull-version pull-version
935 #:guile-version (match guile-version
938 #:guile-for-build guile)))