[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
02/02: derivations: Make <derivation> record datatype immutable.
From: |
Mathieu Lirzin |
Subject: |
02/02: derivations: Make <derivation> record datatype immutable. |
Date: |
Wed, 11 Jan 2017 18:07:17 +0000 (UTC) |
mthl pushed a commit to branch master
in repository guix.
commit dc673fa1131fb5d1e5ca29acb4a693cfb906986f
Author: Mathieu Lirzin <address@hidden>
Date: Sat Dec 17 15:12:19 2016 +0100
derivations: Make <derivation> record datatype immutable.
* guix/derivations.scm (<derivation>): Make it immutable.
(derivation): Use generic 'set-field' instead of ad-hoc functional setter.
---
guix/derivations.scm | 17 +++++------------
1 file changed, 5 insertions(+), 12 deletions(-)
diff --git a/guix/derivations.scm b/guix/derivations.scm
index d5e4b57..b712c50 100644
--- a/guix/derivations.scm
+++ b/guix/derivations.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2012, 2013, 2014, 2015, 2016, 2017 Ludovic Courtès
<address@hidden>
+;;; Copyright © 2016, 2017 Mathieu Lirzin <address@hidden>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -120,7 +121,7 @@
;;; Nix derivations, as implemented in Nix's `derivations.cc'.
;;;
-(define-record-type <derivation>
+(define-immutable-record-type <derivation>
(make-derivation outputs inputs sources system builder args env-vars
file-name)
derivation?
@@ -817,14 +818,6 @@ output should not be used."
e
outputs)))
- (define (set-file-name drv file)
- ;; Set FILE as the 'file-name' field of DRV.
- (match drv
- (($ <derivation> outputs inputs sources system builder
- args env-vars)
- (make-derivation outputs inputs sources system builder
- args env-vars file))))
-
(define input->derivation-input
(match-lambda
(((? derivation? drv))
@@ -872,9 +865,9 @@ output should not be used."
(let* ((file (add-text-to-store store (string-append name ".drv")
(derivation->string drv)
(map derivation-input-path inputs)))
- (drv (set-file-name drv file)))
- (hash-set! %derivation-cache file drv)
- drv)))
+ (drv* (set-field drv (derivation-file-name) file)))
+ (hash-set! %derivation-cache file drv*)
+ drv*)))
(define* (map-derivation store drv mapping
#:key (system (%current-system)))