[Nix-dev] Re: args: with args

Eelco Dolstra e.dolstra at tudelft.nl
Tue Mar 11 14:44:34 CET 2008


Ludovic Courtès wrote:

>> The parameters fetchurl, stdenv and perl appear three times: two times
>> in the top level file and twice in the other Nix expression. The "args:
>> with args" construction would just weed out one occurence but force me
>> to look at the top level file to see what the parameters were again. So,
>> in my opinion readability (and usability) is actually reduced.
> 
> I have the same feeling.  This construct also makes it easy to implement
> "ambient authority" [0], where you'd just pass anything to the Nix
> expression, making it hard to determine what it really needs.

I agree.  The "args; with args" construct basically says "this function takes an 
arbitrary set of arguments, some of which may or may not be used".  So you don't 
get error messages about missing arguments where you might expect them (at call 
time).  And unnecessary arguments aren't flagged at all.

Another downside to "with" is that it completely makes it impossible to 
determine whether there are undefined variables in an expression.  So statically 
checking Nix expressions for mistyped variable names becomes impossible (at 
least under the "withs").

>> Bigger scope: right now there are quite a few different styles that are
>> used to make expressions. To be honest, I'm not too happy with that
>> either. It looks messy and it is confusing, since it needs quite a few
>> brain twists on my side to see what is going on.
> 
> Agreed.  One thing I don't fully understand is the coexistence of
> `stdenv.mkDerivation' and `builderDefs'.
> 
> There are also stylistic inconsistencies in places (indentation, naming,
> etc.), but these are less disturbing.

Yes, I'll think I'll run expand over the Nix expressions sometime to get rid of 
the tabs :-)

Re builderDefs: I think the idea is to make the stdenv setup script modular so 
that changes in one small part don't trigger rebuilds of everything.  However 
whether this is actually worth it is questionable (a change to the "doConfigure" 
phase will still rebuild pretty much everything, and you can override the stdenv 
setup script on a per-package basis anyway).  And certainly writing

   builder = writeScript (name + "-builder")
     (textClosure localDefs [doConfigure doMakeInstall doForceShare doPropagate]);

for every package is not very appealing.

-- 
Eelco Dolstra | http://www.st.ewi.tudelft.nl/~dolstra/



More information about the nix-dev mailing list