[Nix-dev] Improve docs for overrideDerivation - overridable attributes

Alex Berg chexxor at gmail.com
Thu Jun 30 20:18:45 CEST 2016


I created a new "~/.nixpkgs/config.nix" file to customize the
nix-channel-obtained nixpkgs copy on my system - my goal was to bump the
version of Vim to a specific version.

My first attempt was to override the derivation and simply set the
"version" attribute, like this:

{
  packageOverrides = pkgs: rec {
    vim = pkgs.vim.overrideDerivation (oldAttrs: {
      version = "7.4.1941";
    });
  };
}

But this had zero effect on the name of Vim I saw when using "nix-env -qaP"
to see package details. The Vim package's definition has the "name"
attribute defined like this:

name = "vim-${version}";
version = "7.4.1585";

so I expected my overriding the "version" attribute to affect the package's
name, but it did not.

After asking the #nixos IRC channel, one person suggested the "version"
attribute isn't overridable because it isn't an attribute the *primitive
derivation* set. Based on this guess, I changed my ~/.nixpkgs/config.nix
definition from that to this:

let
  vim-version = "7.4.1941";
in
{
  packageOverrides = pkgs: rec {
    vim = pkgs.vim.overrideDerivation (oldAttrs: {
      name = "vim-${vim-version}";
      src = pkgs.fetchFromGitHub {
        owner = "vim";
        repo = "vim";
        rev = "v${vim-version}";
        sha256 = "0apq7sv1fbyfzqh4q0r2z19bn4gbjlb97wyl80kj7qsqmsy7m1lm";
      };
    });
  };
}

My guess is this works because I'm overriding the "name" attribute.

I read the definition of the "mkDerivation" function
(pkgs/stdenv/generic/default.nix),
but it doesn't have a simple list of attributes that are overridable, but
is rather flexible. Also, that definition doesn't mention a "src"
attribute, but "src" attribute is overridable, so I wonder why overriding
the "src" attribute works.

Where can I find explanation for this? If there is a restriction on which
attributes are overridable, then I'd like to note this in the NixPkgs
manual, here:
https://nixos.org/nixpkgs/manual/index.html#sec-pkg-overrideDerivation
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.science.uu.nl/pipermail/nix-dev/attachments/20160630/ba8a7acd/attachment-0001.html>


More information about the nix-dev mailing list