[Nix-dev] Re: nix-commits Digest, Vol 36, Issue 32 - Removed the "if version == ..." stuff

Marc Weber marco-oweber at gmx.de
Wed Jul 14 14:16:26 CEST 2010


> Author: eelco
> Date: Tue Jul 13 22:35:50 2010
> New Revision: 22592
> URL: https://svn.nixos.org/websvn/nix/?rev=22592&sc=1
> 
> Log:
> * PHP updated to 5.2.13.  Removed the "if version == ..." stuff, it's
>   bad practice.
> -  # choose a different version this way:
> -  # php.merge { version = "5.3.2"; }
> -  version = "5.2.11";
> +  version = "5.2.13";
[..]
>    src = args.fetchurl {
>      url = "http://nl.php.net/get/php-${version}.tar.bz2/from/this/mirror";
> -    md5 = if version == "5.3.2" then "46f500816125202c48a458d0133254a4"
> -          else if version == "5.2.11" then "286bf34630f5643c25ebcedfec5e0a09"
> -          else throw "set md5 sum of php source file" ;
> +    sha256 = "1nzaqwsxah7hc59931dk81n2fxyqaaa3yqyisj6akf9vbr9s4l1b";
>      name = "php-${version}.tar.bz2";
>    };
>  

Hi Eelco, I added the newer version for good reason. XMLRPC calls with
SSL didn't work. Maybe they do now. I didn't check.

Can you elaborate why it is bad style allowing the user choosing one
out of multiple versions? Do you want each user to override the version
in configuration.nix and maybe in ~/.nixpkgs/config.nix?

I don't see it. That's why I'm asking.

Also your description is not  accurate enough:
> * PHP updated to 5.2.13.  Removed the "if version == ..." stuff, it's
>   bad practice.

Would having a switch like statement be less bad style?
In other words: This is the use case why I sent the Nix patch about
allowing arbitrary strings as attr names so that the "version =="
doesn't have to be repeated.
So if the choice which was implemented by "if" was represented by kind of
case would it be acceptable by you then?

The example was given here:
http://thread.gmane.org/gmane.linux.distributions.nixos/4526

Macr Weber



More information about the nix-dev mailing list