John Mercier
John Mercier

Reputation: 1705

How to add linux config in configuration.nix

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?

Upvotes: 0

Views: 373

Answers (1)

Gilly
Gilly

Reputation: 1849

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";
    };
  };

};

Upvotes: 1

Related Questions