[Nix-dev] Should I revert my last Eclipse patch or shall I extend the expression?

Tony White tonywhite100 at googlemail.com
Fri Apr 23 23:30:14 CEST 2010


On 23 April 2010 17:30, Marc Weber <marco-oweber at gmx.de> wrote:
> Which is the best way to revert my Eclipse change?
>
> I'd like to introduce this:
>
> { [...], version ? "3.5.0" }: # << adding vesrion defaulting to  3.5.0
>
> let
>  sources = {
>    "3.5.0-i686-linux" = fetchurl ..;
>    "3.5.0-i686-linux" = fetchurl ..;
>
>    # note: not all plugins can be used with this version yet:
>    "3.5.2-x86_64" = fetchurl ..;
>    "3.5.2-x86_64" = fetchurl ..;
>    [..]
>  }
>
> in ... {
>  src =
>    let key = "${version}-{stdenv.system}";
>    stdenv.lib.maybeAttr key (throw "no source given for ${key}") sources;
>  [ ... ]
> }
>
> Then you can override version only to select a specific version.
>
> However the syntax using strings as keys is only possible using
> listToAttr at the moment.
>
> Eelco Dolstra: are you interested in helping me extend Nix allowing
> arbitrary strings as attr names?
>
> I failed in the past. I got a segfault I couldn't cope with.
>
> Marc Weber
> _______________________________________________
> nix-dev mailing list
> nix-dev at cs.uu.nl
> https://mail.cs.uu.nl/mailman/listinfo/nix-dev
>

Hi Marc,
That is way, way to complicated. There is absolutely no need
whatsoever to adopt such a complex approach.

You need to adopt the positive method of : "If it is constant and does
exist, do something else exit."
Not, wild card, haystack, yes/no.

https://svn.nixos.org/websvn/nix/nixpkgs/trunk/pkgs/os-specific/linux/kernel/generic.nix

Does this :

arch =
    if xen then "xen" else
    if userModeLinux then "um" else
    if stdenv.system == "i686-linux" then "i386" else
    if stdenv.system == "x86_64-linux" then "x86_64" else
    if stdenv.system == "armv5tel-linux" then "arm" else
    abort "Platform ${stdenv.system} is not supported.";

To find out the arch. Your system dependent version strings are
constants because you already know which ones won't be there or don't
work, so you don't need to use fetchurl to test if they are there
every time the derivation is built.

Please explain if I "Don't get it" Because I'm writing a lot of code
at the moment and your method appears to be trying to do too much. The
simpler the better; right?

Thanks,
Tony



More information about the nix-dev mailing list