0

I currently have this in my nixpkgs.config

packageOverrides = pkgs: rec {
  netbeans81 = pkgs.stdenv.lib.overrideDerivation pkgs.netbeans ( oldAttrs: {
    name = "netbeans-8.1";
    src = pkgs.fetchurl {
      url = http://download.netbeans.org/netbeans/8.1/final/zip/netbeans-8.1-201510222201.zip;
      md5 = "361ce18421761a057bad5cb6cf7b58f4";
    };
  });
};

and I want to add a kernel config. I added this

packageOverrides = pkgs: {
    stdenv = pkgs.stdenv // {
        platform = pkgs.stdenv.platform // {
            kernelExtraConfig = "SND_HDA_PREALLOC_SIZE 4096";
        };
    };
};

but that did not work. The problem is packageOverrides is already defined.

How can I add the kernel configs and my netbeans overrides?

John Mercier
  • 1,637
  • 3
  • 20
  • 44
  • A better name for your question might be "How to add multiple 'packageOverrides' definitions in configuration.nix" – Gilly May 25 '16 at 05:46

1 Answers1

1

In the nix language, braces ({}) indicate attribute sets (not scope like in C++ etc.). You can have multiple items in a single attribute set (attr. sets are like dicts in python). Also, nix is a functional language, which means there is no state. This, in turn, means that you can't redefine a variable in the same scope. In the words of Eminem, "You only get one shot".

Try this:

packageOverrides = pkgs: rec {

  netbeans81 = pkgs.stdenv.lib.overrideDerivation pkgs.netbeans (oldAttrs: {
    name = "netbeans-8.1";
    src = pkgs.fetchurl {
      url = http://download.netbeans.org/netbeans/8.1/final/zip/netbeans-8.1-201510222201.zip;
      md5 = "361ce18421761a057bad5cb6cf7b58f4";
    };
  });

  stdenv = pkgs.stdenv // {
    platform = pkgs.stdenv.platform // {
      kernelExtraConfig = "SND_HDA_PREALLOC_SIZE 4096";
    };
  };

};
Gilly
  • 1,739
  • 22
  • 30
  • 1
    This exactly what I ended up doing after reading some of the nix pills. – John Mercier May 26 '16 at 21:13
  • Yes, the Nix Pills are great. The link, for other visitors, is http://lethalman.blogspot.com.au/2014/07/nix-pill-1-why-you-should-give-it-try.html – Gilly May 27 '16 at 00:11