[Nix-dev] selectVersion

Eelco Dolstra e.dolstra at tudelft.nl
Thu Jan 29 15:00:24 CET 2009


Hi,

Nicolas Pierron wrote:

>> 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...
> 
> If I understand the point of selectVersion, this was used to override
> the default version number when it is used with composedArgsAndFun.
> So if you need a non-default version, you can just specify which
> version you want.

Ok, thanks.

> look at ltrace to see an example on elfutils.

Which has this line:

  elfutils = elfutils.passthru.function {version = "0.127";};

That seems a very bad idea to me.  You get absolutely no static checking if you
do this.  The "conventional" approach is to say:

  ltrace = ... {
    elfutils = elfutils0127;
  };

  elfutils0127 = import bla/0.127.nix {
    ...
  };

so that if you remove elfutils0127, you get an error message about an undefined
variable.

Also, having a "version" function arguments suggests a false amount of
flexibility.  For instance, what are the valid values for the "version" argument
of a function?

On a related note, a lot of functions seem to use the "version" argument in a
way that seems unsound to me.  For instance, elfutils/0.131.nix looks like this:

  args: with args;

  stdenv.mkDerivation {
    name = "elfutils-"+version;
    src = fetchurl {
      url =
http://ftp.de.debian.org/debian/pool/main/e/elfutils/elfutils_0.131.orig.tar.gz;
      sha256 = "0vqfjpcv81m3q0gsk78qykakhz9rbfwd65i4zsi03xr2lrk9ayll";
    };
    ...
  }

I.e. it uses the version argument in constructing the name, but then it passes a
fixed source tarball in "src".  So it should just be

  name = "elfutils-0.131";

And of course "args: with args;" is evil :-P

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



More information about the nix-dev mailing list