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* (sub-directory item sub-directory)
210 "Return SUB-DIRECTORY within ITEM, which may be a file name or a file-like
214 ;; This is the optimal case: we return a new "source". Thus, a
215 ;; derivation that depends on this sub-directory does not depend on ITEM
217 (local-file (string-append item "/" sub-directory)
219 ;; TODO: Add 'local-file?' case.
221 ;; In this case, anything that refers to the result also depends on ITEM,
222 ;; which isn't great.
223 (file-append item "/" sub-directory))))
225 (define* (locale-data source domain
226 #:optional (directory domain))
227 "Return the locale data from 'po/DIRECTORY' in SOURCE, corresponding to
228 DOMAIN, a gettext domain."
230 (module-ref (resolve-interface '(gnu packages gettext))
234 (with-imported-modules '((guix build utils))
236 (use-modules (guix build utils)
238 (ice-9 match) (ice-9 ftw))
241 #+(sub-directory source (string-append "po/" directory)))
243 (define (compile language)
244 (let ((gmo (string-append #$output "/" language "/LC_MESSAGES/"
246 (mkdir-p (dirname gmo))
247 (invoke #+(file-append gettext "/bin/msgfmt")
248 "-c" "--statistics" "--verbose"
250 (string-append po-directory "/" language ".po"))))
253 ;; Return the list of languages. Note: don't read 'LINGUAS'
254 ;; because it contains things like 'en@boldquot' that do not have
255 ;; a corresponding .po file.
256 (map (cut basename <> ".po")
257 (scandir po-directory
258 (cut string-suffix? ".po" <>))))
260 (for-each compile (linguas)))))
262 (computed-file (string-append "guix-locale-" domain)
265 (define (info-manual source)
266 "Return the Info manual built from SOURCE."
268 (module-ref (resolve-interface '(gnu packages texinfo))
272 (module-ref (resolve-interface '(gnu packages graphviz))
275 (define documentation
276 (sub-directory source "doc"))
279 (sub-directory source "gnu/system/examples"))
282 (with-imported-modules '((guix build utils))
284 (use-modules (guix build utils))
288 ;; Create 'version.texi'.
289 ;; XXX: Can we use a more meaningful version string yet one that
290 ;; doesn't change at each commit?
291 (call-with-output-file "version.texi"
293 (let ((version "0.0-git)"))
295 @set UPDATED 1 January 1970
296 @set UPDATED-MONTH January 1970
298 @set VERSION ~a\n" version version))))
300 ;; Copy configuration templates that the manual includes.
301 (for-each (lambda (template)
305 (basename template ".tmpl")
307 (find-files #$examples "\\.tmpl$"))
310 (mkdir-p (string-append #$output "/images"))
311 (for-each (lambda (dot-file)
312 (invoke #+(file-append graphviz "/bin/dot")
313 "-Tpng" "-Gratio=.9" "-Gnodesep=.005"
314 "-Granksep=.00005" "-Nfontsize=9"
315 "-Nheight=.1" "-Nwidth=.1"
316 "-o" (string-append #$output "/images/"
317 (basename dot-file ".dot")
320 (find-files (string-append #$documentation "/images")
324 (for-each (lambda (png-file)
325 (install-file png-file
326 (string-append #$output "/images")))
327 (find-files (string-append #$documentation "/images")
330 ;; Finally build the manual. Copy it the Texinfo files to $PWD and
331 ;; add a symlink to the 'images' directory so that 'makeinfo' can
332 ;; see those images and produce image references in the Info output.
333 (copy-recursively #$documentation "."
334 #:log (%make-void-port "w"))
335 (delete-file-recursively "images")
336 (symlink (string-append #$output "/images") "images")
338 (for-each (lambda (texi)
339 (unless (string=? "guix.texi" texi)
340 ;; Create 'version-LL.texi'.
341 (let* ((base (basename texi ".texi"))
342 (dot (string-index base #\.))
343 (tag (string-drop base (+ 1 dot))))
344 (symlink "version.texi"
345 (string-append "version-" tag ".texi"))))
347 (invoke #+(file-append texinfo "/bin/makeinfo")
348 texi "-I" #$documentation
350 "-o" (string-append #$output "/"
351 (basename texi ".texi")
354 (find-files "." "^guix\\.[a-z]{2}\\.texi$"))))))
356 (computed-file "guix-manual" build))
358 (define* (guix-command modules #:optional compiled-modules
359 #:key source (dependencies '())
360 guile (guile-version (effective-version)))
361 "Return the 'guix' command such that it adds MODULES and DEPENDENCIES in its
363 (define source-directories
364 (map (lambda (package)
365 (file-append package "/share/guile/site/"
369 (define object-directories
370 (map (lambda (package)
371 (file-append package "/lib/guile/"
372 guile-version "/site-ccache"))
375 (program-file "guix-command"
378 (append (filter file-exists? '#$source-directories)
381 (set! %load-compiled-path
382 (append (filter file-exists? '#$object-directories)
383 %load-compiled-path))
385 (set! %load-path (cons #$modules %load-path))
386 (set! %load-compiled-path
387 (cons (or #$compiled-modules #$modules)
388 %load-compiled-path))
390 (let ((guix-main (module-ref (resolve-interface '(guix ui))
394 (bindtextdomain "guix"
395 #$(locale-data source "guix"))
396 (bindtextdomain "guix-packages"
397 #$(locale-data source
402 ;; XXX: It would be more convenient to change it to:
403 ;; (exit (apply guix-main (command-line)))
404 (apply guix-main (command-line))))
407 (define* (whole-package name modules dependencies
409 (guile-version (effective-version))
412 (command (guix-command modules
413 #:dependencies dependencies
415 #:guile-version guile-version)))
416 "Return the whole Guix package NAME that uses MODULES, a derivation of all
417 the modules, and DEPENDENCIES, a list of packages depended on. COMMAND is the
418 'guix' program to use; INFO is the Info manual. When COMPILED-MODULES is
419 true, it is linked as 'lib/guile/X.Y/site-ccache'; otherwise, .go files are
420 assumed to be part of MODULES."
422 (with-imported-modules '((guix build utils))
424 (use-modules (guix build utils))
425 (mkdir-p (string-append #$output "/bin"))
427 (string-append #$output "/bin/guix"))
430 (symlink (string-append #$daemon "/bin/guix-daemon")
431 (string-append #$output "/bin/guix-daemon")))
433 (let ((modules (string-append #$output
435 (effective-version)))
437 (mkdir-p (dirname modules))
438 (symlink #$modules modules)
441 (string-append #$output
445 (when #$compiled-modules
446 (let ((modules (string-append #$output "/lib/guile/"
449 (mkdir-p (dirname modules))
450 (symlink #$compiled-modules modules)))))))
452 (define* (compiled-guix source #:key (version %guix-version)
454 (name (string-append "guix-" version))
455 (guile-version (effective-version))
456 (guile-for-build (guile-for-build guile-version))
457 (zlib (specification->package "zlib"))
458 (gzip (specification->package "gzip"))
459 (bzip2 (specification->package "bzip2"))
460 (xz (specification->package "xz"))
461 (guix (specification->package "guix")))
462 "Return a file-like object that contains a compiled Guix."
464 (package-for-guile guile-version
469 (package-for-guile guile-version
474 (package-for-guile guile-version
478 (define guile-sqlite3
479 (package-for-guile guile-version
484 (package-for-guile guile-version
488 (package-for-guile guile-version
489 "gnutls" "guile2.0-gnutls"))
492 (match (append-map (lambda (package)
493 (cons (list "x" package)
494 (package-transitive-propagated-inputs package)))
495 (list guile-gcrypt gnutls guile-git guile-json
496 guile-ssh guile-sqlite3))
497 (((labels packages _ ...) ...)
500 (define *core-modules*
501 (scheme-node "guix-core"
508 (guix build-system gnu)
509 (guix build-system trivial)
510 (guix build profiles)
511 (guix build gnu-build-system))
513 ;; Provide a dummy (guix config) with the default version
514 ;; number, storedir, etc. This is so that "guix-core" is the
515 ;; same across all installations and doesn't need to be
516 ;; rebuilt when the version changes, which in turn means we
517 ;; can have substitutes for it.
519 `(((guix config) => ,(make-config.scm)))
521 ;; (guix man-db) is needed at build-time by (guix profiles)
522 ;; but we don't need to compile it; not compiling it allows
523 ;; us to avoid an extra dependency on guile-gdbm-ffi.
525 `(("guix/man-db.scm" ,(local-file "../guix/man-db.scm"))
526 ("guix/store/schema.sql"
527 ,(local-file "../guix/store/schema.sql")))
529 #:extensions (list guile-gcrypt)
530 #:guile-for-build guile-for-build))
532 (define *extra-modules*
533 (scheme-node "guix-extra"
534 (filter-map (match-lambda
535 (('guix 'scripts _ ..1) #f)
538 (scheme-modules* source "guix"))
539 (list *core-modules*)
540 #:extensions dependencies
541 #:guile-for-build guile-for-build))
543 (define *core-package-modules*
544 (scheme-node "guix-packages-base"
547 (list *core-modules* *extra-modules*)
548 #:extensions dependencies
550 ;; Add all the non-Scheme files here. We must do it here so
551 ;; that 'search-patches' & co. can find them. Ideally we'd
552 ;; keep them next to the .scm files that use them but it's
553 ;; difficult to do (XXX).
555 (file-imports source "gnu/packages"
557 (and (eq? 'regular (stat:type stat))
558 (not (string-suffix? ".scm" file))
559 (not (string-suffix? ".go" file))
560 (not (string-prefix? ".#" file))
561 (not (string-suffix? "~" file)))))
562 #:guile-for-build guile-for-build))
564 (define *package-modules*
565 (scheme-node "guix-packages"
566 (scheme-modules* source "gnu/packages")
567 (list *core-modules* *extra-modules* *core-package-modules*)
568 #:extensions dependencies
569 #:guile-for-build guile-for-build))
571 (define *system-modules*
572 (scheme-node "guix-system"
575 ,@(scheme-modules* source "gnu/system")
576 ,@(scheme-modules* source "gnu/services"))
577 (list *core-package-modules* *package-modules*
578 *extra-modules* *core-modules*)
579 #:extensions dependencies
581 (append (file-imports source "gnu/system/examples"
584 ;; Build-side code that we don't build. Some of
585 ;; these depend on guile-rsvg, the Shepherd, etc.
586 (file-imports source "gnu/build" (const #t)))
590 (define *cli-modules*
591 (scheme-node "guix-cli"
592 (scheme-modules* source "/guix/scripts")
593 (list *core-modules* *extra-modules*
594 *core-package-modules* *package-modules*
596 #:extensions dependencies
597 #:guile-for-build guile-for-build))
600 (scheme-node "guix-config"
604 => ,(make-config.scm #:zlib zlib
613 %guix-bug-report-address
615 %guix-home-page-url)))
616 #:guile-for-build guile-for-build))
618 (define (built-modules node-subset)
619 (directory-union (string-append name "-modules")
620 (append-map node-subset
622 ;; Note: *CONFIG* comes first so that it
623 ;; overrides the (guix config) module that
624 ;; comes with *CORE-MODULES*.
629 *core-package-modules*
633 ;; Silently choose the first entry upon collision so that
634 ;; we choose *CONFIG*.
635 #:resolve-collision 'first
637 ;; When we do (add-to-store "utils.scm"), "utils.scm" must
638 ;; be a regular file, not a symlink. Thus, arrange so that
639 ;; regular files appear as regular files in the final
644 ;; Version 0 of 'guix pull' meant we'd just return Scheme modules.
645 ;; Version 1 is when we return the full package.
646 (cond ((= 1 pull-version)
647 ;; The whole package, with a standard file hierarchy.
648 (let* ((modules (built-modules (compose list node-source)))
649 (compiled (built-modules (compose list node-compiled)))
650 (command (guix-command modules compiled
652 #:dependencies dependencies
653 #:guile guile-for-build
654 #:guile-version guile-version)))
655 (whole-package name modules dependencies
656 #:compiled-modules compiled
658 #:guile guile-for-build
660 ;; Include 'guix-daemon'. XXX: Here we inject an
661 ;; older snapshot of guix-daemon, but that's a good
662 ;; enough approximation for now.
663 #:daemon (module-ref (resolve-interface
668 #:info (info-manual source)
669 #:guile-version guile-version)))
671 ;; Legacy 'guix pull': return the .scm and .go files as one
673 (built-modules (lambda (node)
674 (list (node-source node)
675 (node-compiled node)))))
677 ;; Unsupported 'guix pull' version.
682 ;;; Generating (guix config).
685 (define %dependency-variables
686 ;; (guix config) variables corresponding to dependencies.
687 '(%libz %xz %gzip %bzip2))
689 (define %persona-variables
690 ;; (guix config) variables that define Guix's persona.
693 %guix-bug-report-address
694 %guix-home-page-url))
696 (define %config-variables
697 ;; (guix config) variables corresponding to Guix configuration.
698 (letrec-syntax ((variables (syntax-rules ()
701 ((_ variable rest ...)
702 (cons `(variable . ,variable)
703 (variables rest ...))))))
704 (variables %localstatedir %storedir %sysconfdir %system)))
706 (define* (make-config.scm #:key zlib gzip xz bzip2
707 (package-name "GNU Guix")
708 (package-version "0")
709 (bug-report-address "bug-guix@gnu.org")
710 (home-page-url "https://gnu.org/s/guix"))
712 ;; Hack so that Geiser is not confused.
713 (define defmod 'define-module)
715 (scheme-file "config.scm"
716 #~(;; The following expressions get spliced.
717 (#$defmod (guix config)
718 #:export (%guix-package-name
720 %guix-bug-report-address
724 %store-database-directory
731 #$@(map (match-lambda
733 #~(define-public #$name #$value)))
736 (define %store-directory
737 (or (and=> (getenv "NIX_STORE_DIR") canonicalize-path)
740 (define %state-directory
741 ;; This must match `NIX_STATE_DIR' as defined in
743 (or (getenv "NIX_STATE_DIR")
744 (string-append %localstatedir "/guix")))
746 (define %store-database-directory
747 (or (getenv "NIX_DB_DIR")
748 (string-append %state-directory "/db")))
750 (define %config-directory
751 ;; This must match `GUIX_CONFIGURATION_DIRECTORY' as
752 ;; defined in `nix/local.mk'.
753 (or (getenv "GUIX_CONFIGURATION_DIRECTORY")
754 (string-append %sysconfdir "/guix")))
756 (define %guix-package-name #$package-name)
757 (define %guix-version #$package-version)
758 (define %guix-bug-report-address #$bug-report-address)
759 (define %guix-home-page-url #$home-page-url)
762 #+(and gzip (file-append gzip "/bin/gzip")))
764 #+(and bzip2 (file-append bzip2 "/bin/bzip2")))
766 #+(and xz (file-append xz "/bin/xz")))
770 (file-append zlib "/lib/libz"))))
772 ;; Guile 2.0 *requires* the 'define-module' to be at the
773 ;; top-level or the 'toplevel-ref' in the resulting .go file are
774 ;; made relative to a nonexistent anonymous module.
783 (define* (compiled-modules name module-tree module-files
786 (dependencies-compiled '())
788 (extensions '()) ;full-blown Guile packages
791 "Build all the MODULE-FILES from MODULE-TREE. MODULE-FILES must be a list
792 like '(\"guix/foo.scm\" \"gnu/bar.scm\") and MODULE-TREE is the directory
793 containing MODULE-FILES and possibly other files as well."
794 ;; This is a non-monadic, enhanced version of 'compiled-file' from (guix
797 (with-imported-modules (source-module-closure
798 '((guix build compile)
801 (use-modules (srfi srfi-26)
808 (define (regular? file)
809 (not (member file '("." ".."))))
811 (define (report-load file total completed)
814 "loading...\t~5,1f% of ~d files" ;FIXME: i18n
815 (* 100. (/ completed total)) total)
818 (define (report-compilation file total completed)
820 (format #t "compiling...\t~5,1f% of ~d files" ;FIXME: i18n
821 (* 100. (/ completed total)) total)
824 (define (process-directory directory files output)
825 ;; Hide compilation warnings.
826 (parameterize ((current-warning-port (%make-void-port "w")))
827 (compile-files directory #$output files
828 #:workers (parallel-job-count)
829 #:report-load report-load
830 #:report-compilation report-compilation)))
832 (setvbuf (current-output-port) _IONBF)
833 (setvbuf (current-error-port) _IONBF)
835 (set! %load-path (cons #+module-tree %load-path))
837 (append '#+dependencies
838 (map (lambda (extension)
839 (string-append extension "/share/guile/site/"
840 (effective-version)))
844 (set! %load-compiled-path
845 (append '#+dependencies-compiled
846 (map (lambda (extension)
847 (string-append extension "/lib/guile/"
851 %load-compiled-path))
853 ;; Load the compiler modules upfront.
857 (chdir #+module-tree)
858 (process-directory "." '#+module-files #$output)
861 (computed-file name build
862 #:guile guile-for-build
864 `(#:local-build? #f ;allow substitutes
866 ;; Don't annoy people about _IONBF deprecation.
867 ;; Initialize 'terminal-width' in (system repl debug)
868 ;; to a large-enough value to make backtrace more
870 #:env-vars (("GUILE_WARN_DEPRECATED" . "no")
871 ("COLUMNS" . "200")))))
878 (define (guile-for-build version)
879 "Return a derivation for Guile 2.0 or 2.2, whichever matches the currently
881 (define canonical-package ;soft reference
882 (module-ref (resolve-interface '(gnu packages base))
887 ;; Gross hack to avoid ABI incompatibilities (see
888 ;; <https://bugs.gnu.org/29570>.)
889 (module-ref (resolve-interface '(gnu packages guile))
892 ;; Use the latest version, which has fixes for
893 ;; <https://bugs.gnu.org/30602> and VM stack-marking issues.
894 (canonical-package (module-ref (resolve-interface '(gnu packages guile))
897 (module-ref (resolve-interface '(gnu packages guile))
900 (define* (guix-derivation source version
901 #:optional (guile-version (effective-version))
902 #:key (pull-version 0))
903 "Return, as a monadic value, the derivation to build the Guix from SOURCE
904 for GUILE-VERSION. Use VERSION as the version string. PULL-VERSION specifies
905 the version of the 'guix pull' protocol. Return #f if this PULL-VERSION value
907 (define (shorten version)
908 (if (and (string-every char-set:hex-digit version)
909 (> (string-length version) 9))
910 (string-take version 9) ;Git commit
914 ;; When PULL-VERSION >= 1, produce a self-contained Guix and use Guile 2.2
916 (guile-for-build (if (>= pull-version 1)
921 (set-guile-for-build guile)
922 (let ((guix (compiled-guix source
924 #:name (string-append "guix-"
926 #:pull-version pull-version
927 #:guile-version (if (>= pull-version 1)
932 #:guile-for-build guile)))