diff mbox series

[bug#43064,v2] gexp: computed-file: Prevent mistakenly overriding default option values.

Message ID 20200831043744.11165-1-maxim.cournoyer@gmail.com
State Accepted
Headers show
Series [bug#43064,v2] gexp: computed-file: Prevent mistakenly overriding default option values. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git branch success View Git branch
cbaines/applying patch success View Laminar job

Commit Message

Maxim Cournoyer Aug. 31, 2020, 4:37 a.m. UTC
In order to do so, default to an empty options list, and expose options whose
default values are sensitive directly as keyword arguments.

* guix/gexp.scm (computed-file): Extract the LOCAL-BUILD? parameter from the
OPTIONS parameter to make it a stand-alone keyword argument.  Introduce an
OPTIONS* binding which is obtained by combining the LOCAL-BUILD? keyword and
its value with OPTIONS.

Suggested-by: Ludovic Courtès <ludo@gnu.org>
---
 guix/gexp.scm | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

Comments

Ludovic Courtès Aug. 31, 2020, 1:34 p.m. UTC | #1
Hi,

Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:

> In order to do so, default to an empty options list, and expose options whose
> default values are sensitive directly as keyword arguments.
>
> * guix/gexp.scm (computed-file): Extract the LOCAL-BUILD? parameter from the
> OPTIONS parameter to make it a stand-alone keyword argument.  Introduce an
> OPTIONS* binding which is obtained by combining the LOCAL-BUILD? keyword and
> its value with OPTIONS.
>
> Suggested-by: Ludovic Courtès <ludo@gnu.org>

[...]

>  (define* (computed-file name gexp
> -                        #:key guile (options '(#:local-build? #t)))
> +                        #:key guile (local-build? #t) (options '()))
>    "Return an object representing the store item NAME, a file or directory
> -computed by GEXP.  OPTIONS is a list of additional arguments to pass
> -to 'gexp->derivation'.
> +computed by GEXP.  When LOCAL-BUILD? is #t (the default), it ensures the
> +corresponding derivation is built locally.  OPTIONS may be used to pass
> +additional arguments to 'gexp->derivation'.
>  
>  This is the declarative counterpart of 'gexp->derivation'."

Please update doc/guix.texi as well.

Otherwise LGTM, thanks!

Ludo’.
Maxim Cournoyer Sept. 1, 2020, 1 p.m. UTC | #2
Ludovic Courtès <ludo@gnu.org> writes:

> Hi,
>
> Maxim Cournoyer <maxim.cournoyer@gmail.com> skribis:
>
>> In order to do so, default to an empty options list, and expose options whose
>> default values are sensitive directly as keyword arguments.
>>
>> * guix/gexp.scm (computed-file): Extract the LOCAL-BUILD? parameter from the
>> OPTIONS parameter to make it a stand-alone keyword argument.  Introduce an
>> OPTIONS* binding which is obtained by combining the LOCAL-BUILD? keyword and
>> its value with OPTIONS.
>>
>> Suggested-by: Ludovic Courtès <ludo@gnu.org>

[...]

> Please update doc/guix.texi as well.
>
> Otherwise LGTM, thanks!
>
> Ludo’.

Done!

Thank you,

Maxim
diff mbox series

Patch

diff --git a/guix/gexp.scm b/guix/gexp.scm
index 67b6121313..9d3c52e783 100644
--- a/guix/gexp.scm
+++ b/guix/gexp.scm
@@ -3,6 +3,7 @@ 
 ;;; Copyright © 2018 Clément Lassieur <clement@lassieur.org>
 ;;; Copyright © 2018 Jan Nieuwenhuizen <janneke@gnu.org>
 ;;; Copyright © 2019, 2020 Mathieu Othacehe <m.othacehe@gmail.com>
+;;; Copyright © 2020 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -504,13 +505,15 @@  This is the declarative counterpart of 'text-file'."
   (options    computed-file-options))             ;list of arguments
 
 (define* (computed-file name gexp
-                        #:key guile (options '(#:local-build? #t)))
+                        #:key guile (local-build? #t) (options '()))
   "Return an object representing the store item NAME, a file or directory
-computed by GEXP.  OPTIONS is a list of additional arguments to pass
-to 'gexp->derivation'.
+computed by GEXP.  When LOCAL-BUILD? is #t (the default), it ensures the
+corresponding derivation is built locally.  OPTIONS may be used to pass
+additional arguments to 'gexp->derivation'.
 
 This is the declarative counterpart of 'gexp->derivation'."
-  (%computed-file name gexp guile options))
+  (let ((options* `(#:local-build? ,local-build? ,@options)))
+    (%computed-file name gexp guile options*)))
 
 (define-gexp-compiler (computed-file-compiler (file <computed-file>)
                                               system target)