[Nix-dev] $out in configureFlags is not expanded

Bjørn Forsman bjorn.forsman at gmail.com
Sun May 19 12:46:37 CEST 2013


On 19 May 2013 12:12, Vladimír Čunát <vcunat at gmail.com> wrote:
> On 05/19/2013 12:05 PM, Bjørn Forsman wrote:
>>
>> On 19 May 2013 09:37, Lluís Batlle i Rossell <viric at viric.name> wrote:
>>>
>>> On Sat, May 18, 2013 at 07:11:32PM +0200, Bjørn Forsman wrote:
>>>>
>>>>     preConfigure = ''configureFlags="--foo=$out/etc/foo.cfg"'';
>>>
>>>
>>> That's what we all end up doing. :)
>>
>>
>> Hehe, Ok I see :-)
>>
>> But how about "eval configureFlags=$configureFlags" (or something like
>> that) in the builder? Wouldn't it solve this issue?
>
>
> I'm not sure if this would preserve spaces as they were before, but on the
> whole I think it would be better to expand vars in configureFlags.

Lists of strings that may contain whitespace is pain in shell (at
least if not using arrays) :-(

Ok, how about this then:

$ configureFlags='--foo=$out/foobar --bar=2'
$ out=/nix/store/HASH
$ configureFlagsExpanded=$(for flag in $configureFlags; do eval
flag="$flag"; printf -- "$flag "; done)
$ echo $configureFlagsExpanded
--foo=/nix/store/HASH/foobar --bar=2

Best regards,
Bjørn Forsman


More information about the nix-dev mailing list