[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
07/13: DRAFT gexp: Add 'object-sources'.
From: |
guix-commits |
Subject: |
07/13: DRAFT gexp: Add 'object-sources'. |
Date: |
Thu, 12 Dec 2019 07:49:41 -0500 (EST) |
civodul pushed a commit to branch wip-system-bootstrap
in repository guix.
commit c9a42a4580f6f993a4c8f2e800d8ecaf3428ab38
Author: Ludovic Courtès <address@hidden>
Date: Fri Dec 6 23:20:00 2019 +0100
DRAFT gexp: Add 'object-sources'.
DRAFT: Add tests.
* guix/gexp.scm (<object-sources>): New record type.
(object-sources-compiler): New gexp compiler.
---
guix/gexp.scm | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/guix/gexp.scm b/guix/gexp.scm
index 490679f..7bbee4d 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -84,6 +84,9 @@
raw-derivation-closure
raw-derivation-closure?
+ object-sources
+ object-sources?
+
load-path-expression
gexp-modules
@@ -322,6 +325,57 @@ The expander specifies how an object is converted to its
sexp representation."
(text-file "graph" (object->string refs)))
(return obj))))
+;; Representation of all the sources and fixed-output derivations OBJ refers
+;; to, directly or indirectly.
+(define-record-type <object-sources>
+ (object-sources obj)
+ object-sources?
+ (obj object-sources-object))
+
+(define-gexp-compiler (object-sources-compiler (obj <object-sources>)
+ system target)
+ (define (derivation-fixed-output-requirements drv)
+ (derivation-input-fold (lambda (input result)
+ (let ((drv (derivation-input-derivation input)))
+ (if (fixed-output-derivation? drv)
+ (cons drv result)
+ result)))
+ '()
+ (derivation-inputs drv)
+
+ ;; Skip the dependencies of fixed-output
+ ;; derivations (e.g., 'git' for a 'git-fetch'
+ ;; derivation.)
+ #:skip-dependencies?
+ (compose fixed-output-derivation?
+ derivation-input-derivation)))
+
+ (define (derivation-recursive-sources drv)
+ (delete-duplicates
+ (derivation-input-fold (lambda (input result)
+ (let ((drv (derivation-input-derivation input)))
+ (append (derivation-sources drv)
+ result)))
+ '()
+ (derivation-inputs drv))))
+
+ (mlet %store-monad ((obj (lower-object (object-sources-object obj)
+ system #:target target)))
+ (if (derivation? obj)
+ (let* ((drvs (derivation-fixed-output-requirements obj))
+ (sources (derivation-recursive-sources obj))
+ (pairs (append (map (lambda (drv)
+ `(,(store-path-package-name
+ (derivation-file-name drv))
+ ,drv))
+ drvs)
+ (map (lambda (file)
+ `(,(basename file) ,file))
+ sources)))
+ (union (file-union "sources" pairs)))
+ (lower-object union system #:target target))
+ (return obj))))
+
;;;
;;; File declarations.
- branch wip-system-bootstrap created (now ba36483), guix-commits, 2019/12/12
- 01/13: utils: 'version-compare' delays 'dynamic-link' code., guix-commits, 2019/12/12
- 03/13: store: Add #:cut? parameter to 'topologically-sorted'., guix-commits, 2019/12/12
- 02/13: monads: Add portability to Guile 2.0., guix-commits, 2019/12/12
- 05/13: DRAFT gexp: Add 'raw-derivation-file'., guix-commits, 2019/12/12
- 07/13: DRAFT gexp: Add 'object-sources'.,
guix-commits <=
- 09/13: guile-build-system: Add #:implicit-inputs., guix-commits, 2019/12/12
- 12/13: DRAFT serialization: Avoid 'define-values', for the sake of Guile 2.0., guix-commits, 2019/12/12
- 10/13: gnu: Add guile-hashing., guix-commits, 2019/12/12
- 06/13: DRAFT gexp: Add 'raw-derivation-closure'., guix-commits, 2019/12/12
- 04/13: derivations: Add #:skip-dependencies? parameter to 'derivation-input-fold'., guix-commits, 2019/12/12
- 08/13: DRAFT system: Add (gnu system bootstrap)., guix-commits, 2019/12/12
- 11/13: bootstrap: Add %bootstrap-guile+guild., guix-commits, 2019/12/12
- 13/13: system: bootstrap: Compute and print the result's hash., guix-commits, 2019/12/12