Subject: bug#44525: Derivation of computed-file has no outputs

From: Marius Bakke <[email-masked]>
Date: Sun, 08 Nov 2020 21:44:51 +0100

Stefan <[email-masked]> writes:

> Hi!
>
> I try to use a computed-file as an input to a bootloader profile hook function. Using guix system I get this error message:
>
> guix system: error: reference to invalid output 'out' of derivation '/gnu/store/946szbrwn3ja74yjnibbhjisjflvsk73-test.txt.drv'

>
> This is the simple definition of the computed-file:
>
> (computed-file "test.txt" (with-imported-modules '((guix utils)) #~(%current-system)))

That's expected: this derivation does not produce any outputs.

Assuming you intended to write (%current-system) to test.txt, you can do
something along these lines:

  (computed-file "test.txt"
                 #~(call-with-output-file #$output
                     (lambda (port)
                       (format port #$(%current-system)))))

So I think this is not-a-bug.  WDYT?