about summary refs log tree commit diff
path: root/pkgs/os-specific/linux/firmware/nvidia/default.nix
blob: 810c7bd60cca78e54677f5fa73ad73c7cc3e61a6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{ stdenv, fetchurl, python2Packages, which, xz }:

let
  extractor = fetchurl {
    url = https://raw.githubusercontent.com/imirkin/re-vp2/master/extract_firmware.py;
    sha256 = "03dd1il0cjs8xi411pkckkfjga348j0cgd6dix20gd4kwmlvyjqm";
  };

  chipModel = [
    # gt200 should be nva0 but we don't have those and all nvaX are links to the same files anyway
    { chip = "nva3"; model = "gt200"; }
    { chip = "nva3"; model = "gt215"; }
    { chip = "nva5"; model = "gt216"; }
    { chip = "nva8"; model = "gt218"; }
    { chip = "nve4"; model = "gk104"; }
    { chip = "nve6"; model = "gk106"; }
    { chip = "nve7"; model = "gk107"; }
  ];

in stdenv.mkDerivation rec {
  name = "linux-firmware-nvidia-${version}";
  version = "325.15";

  src = fetchurl {
    url = "http://us.download.nvidia.com/XFree86/Linux-x86/${version}/NVIDIA-Linux-x86-${version}.run";
    sha256 = "0xc7w2ia2fnkn20s6aq1f4ib2ljxmd2931vnrkvl2injzr5hwy9x";
  };

  phases = [ "installPhase" ];

  nativeBuildInputs = [ which xz ];

  installPhase = ''
    dir=$out/lib/firmware
    ${stdenv.shell} ${src} --extract-only
    ${python2Packages.python.interpreter} ${extractor}

    mkdir -p $dir/{nouveau,nvidia}
    cp -rd nv* vuc-* $dir/nouveau

    ${stdenv.lib.concatStringsSep "\n" (map (entry: ''
      mkdir -p $dir/nvidia/${entry.model}

      ln -rs $dir/nouveau/${entry.chip}_fuc409c $dir/nvidia/${entry.model}/fecs_inst.bin
      ln -rs $dir/nouveau/${entry.chip}_fuc409d $dir/nvidia/${entry.model}/fecs_data.bin
      ln -rs $dir/nouveau/${entry.chip}_fuc41ac $dir/nvidia/${entry.model}/gpccs_inst.bin
      ln -rs $dir/nouveau/${entry.chip}_fuc41ad $dir/nvidia/${entry.model}/gpccs_data.bin
    '') chipModel)}
  '';

  meta = with stdenv.lib; {
    description = "Binary firmware for nVidia cards";
    longDescription = ''
      This package contains proprietary firmware blobs for nVidia graphics cards
      up to and including the "Kepler" range.
s
      If you card is supported but not handled by this package, please find yours
      here https://nouveau.freedesktop.org/wiki/CodeNames/ and let us know.
    '';
    homepage = http://nvidia.com;
    hydraPlatforms = [];
    license = licenses.unfree;
    platforms = platforms.linux;
    maintainers = with maintainers; [ peterhoeg ];
  };
}