guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]


From: Ludovic Courtès
Date: Wed, 23 Aug 2023 17:09:08 -0400 (EDT)

branch: master
commit ecc1a1adaf20968b865f02947613917704163d1b
Author: Ludovic Courtès <ludo@gnu.org>
AuthorDate: Wed Aug 23 16:55:37 2023 +0200

    examples: random: Add multiple-output derivations.
    
    * examples/random-manifest.scm (random-computed-file): Add
    'multiple-outputs?' parameter and honor it.
    (unfold): Produce 15 entries; pass 'multiple-outputs?'.
---
 examples/random-manifest.scm | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/examples/random-manifest.scm b/examples/random-manifest.scm
index e8e2d0d..1fc491c 100644
--- a/examples/random-manifest.scm
+++ b/examples/random-manifest.scm
@@ -36,7 +36,8 @@
 (define %state
   (seed->random-state %seed))
 
-(define* (random-computed-file #:optional (suffix ""))
+(define* (random-computed-file #:optional (suffix "")
+                               multiple-outputs?)
   (let ((nonce (random 1e6 %state)))
     (computed-file (string-append "random" suffix)
                    #~(let ((delay #$(random 60 %state))
@@ -49,17 +50,27 @@
                        (when fail?
                          (error "we're faillliiiiing!"))
                        #$nonce
-                       (mkdir #$output)))))
+                       #$(if multiple-outputs?
+                             #~(begin
+                                 (mkdir #$output:first)
+                                 (mkdir #$output:second))
+                             #~(mkdir #$output))))))
 
 
 (when (zero? (random 7 %state))
   (error "Evaluation is failing!"))
 
 (manifest
- (unfold (cut > <> 10)
+ (unfold (cut > <> 15)
          (lambda (i)
-           (let ((suffix (number->string i)))
+           (let* ((multiple-outputs? (zero? (modulo i 5)))
+                  (suffix (string-append
+                           (if multiple-outputs?
+                               "multiple-outputs"
+                               "")
+                           (number->string i))))
              (make-job (string-append "entropy-" suffix)
-                       (random-computed-file suffix))))
+                       (random-computed-file suffix
+                                             multiple-outputs?))))
          1+
          0))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]