[Nix-dev] selectVersion

Eelco Dolstra e.dolstra at tudelft.nl
Thu Jan 29 15:18:09 CET 2009


Hi,

Marc Weber wrote:

> On Thu, Jan 29, 2009 at 02:24:03PM +0100, Eelco Dolstra wrote:
>> Hi,
>>
>> Can somebody explain what the use of selectVersion in all-packages.nix is?  It's
>> full of calls like
>>
>>   selectVersion ../tools/system/ddrescue "1.8"
>>
>> which seems rather pointless to me, given that you can just as easily say
>> "import ../tools/system/ddrescue/1.8.nix".  I propose a global search/replace to
>> get rid of them...
> 
> He Eelco!
> 
> You've missed a small detail
> I'm laughing now because I remember your statement on irc about all
> those different ways which exist to write derivations :-)

Well yes, I'd like to regularize all-packages.nix a bit :-)

> you can use it this way to override the version selection:
> 
>   fooFun args = selectVersion ../tools/system/ddrescue "1.8" args ;
> 
>   # selects "1.8"
>   foo = foo { inherit:  stdenv ... };
> 
>   # 1.8 is overridden by "newer":
>   fooNewer = foo { version = "newer"; inherit  stdenv ...};

See, I don't understand what the advantage of this is over the old way, e.g.

  bison = bison23;

  bison1875 = import ../development/tools/parsing/bison/bison-1.875.nix {
    inherit fetchurl stdenv m4;
  };

  bison23 = import ../development/tools/parsing/bison/bison-2.3.nix {
    inherit fetchurl stdenv m4;
  };

  bison24 = import ../development/tools/parsing/bison/bison-2.4.nix {
    inherit fetchurl stdenv m4;
  };

Here you get some static checking: if you remove the bison1875 variable, you get
an error message if there are other places in all-packages.nix referring to it.

Also, there is a kind of asymmetry in fooFun/foo/fooNewer: fooFun is "biased"
towards building version 1.8.  This isn't the case with the bison example: for
example, the "bison" variable won't magically build Bison 2.4 if you pass it
just the right arguments.

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



More information about the nix-dev mailing list