Functions reference
The nixpkgs repository has several utility functions to manipulate Nix expressions.
pkgs.overridePackages
This function inside the nixpkgs expression (pkgs)
can be used to override the set of packages itself.
Warning: this function is expensive and must not be used from within
the nixpkgs repository.
Example usage:
let
pkgs = import <nixpkgs> {};
newpkgs = pkgs.overridePackages (self: super: {
foo = super.foo.override { ... };
};
in ...
The resulting newpkgs will have the new foo
expression, and all other expressions depending on foo will also
use the new foo expression.
The behavior of this function is similar to config.packageOverrides.
The self parameter refers to the final package set with the
applied overrides. Using this parameter may lead to infinite recursion if not
used consciously.
The super parameter refers to the old package set.
It's equivalent to pkgs in the above example.
<pkg>.override
The function override is usually available for all the
derivations in the nixpkgs expression (pkgs).
It is used to override the arguments passed to a function.
Example usages:
pkgs.foo.override { arg1 = val1; arg2 = val2; ... }pkgs.overridePackages (self: super: {
foo = super.foo.override { barSupport = true ; };
})mypkg = pkgs.callPackage ./mypkg.nix {
mydep = pkgs.mydep.override { ... };
})
In the first example, pkgs.foo is the result of a function call
with some default arguments, usually a derivation.
Using pkgs.foo.override will call the same function with
the given new arguments.