summaryrefslogtreecommitdiffstats
path: root/default.nix
blob: 3c2c117a65f6fe12151d05bae271bcebb8390679 (plain)
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
with builtins;
let
  nixpkgs = import <nixpkgs> {};
  version = "3.8.6";
  srcs = {
    mpss-src = fetchTarball {
      url = "http://registrationcenter-download.intel.com/akdlm/irc_nas/15904/mpss-src-${version}.tar";
      sha256 = "017g67yc9zqviilryxvq31vzj9hp0lxxrlir8j9vs9l83sw8dfx5";
    };
  };
  kernel = nixpkgs.linuxPackages_4_4.kernel;

in with nixpkgs;
let
  modules = stdenv.mkDerivation rec {
    name = "mpss-modules";
    inherit version;

    src = "${srcs.mpss-src}/src/mpss-modules-${version}.tar.bz2";
    patches = [
      ./mpss-modules-4.4.patch
    ];

    hardeningDisable = [ "pic" "format" ];
    nativeBuildInputs = kernel.moduleBuildDependencies;
    builtInputs = [ kmod ];
    enableParallelBuilding = true;

    makeFlags = [
      "KERNELRELEASE=${kernel.modDirVersion}"
      "KERNEL_SRC=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
      "DESTDIR=$(out)"
      "MIC_CARD_ARCH=k1om"
    ];

    outputs = [ "out" "dev" ];

    installPhase = ''
      install -m644 -b -D mic.ko $out/lib/modules/${kernel.modDirVersion}/extra/mic.ko
      install -d $dev/include/mic
      install -m644 include/scif_ioctl.h $dev/include
      install -m644 include/mic/io_interface.h $dev/include/mic
      install -m644 include/mic/mic_pm.h $dev/include/mic
      install -m644 ras/micras_api.h $dev/include/mic
      install -m644 ras/micmca_api.h $dev/include/mic
    '';
  };
  metadata = stdenv.mkDerivation rec {
    name = "mpss-metadata";
    inherit version;

    src = "${srcs.mpss-src}/src/mpss-metadata-${version}.tar.bz2";

    installPhase = ''
      mkdir -p $out
      install -m644 -b -D mpss-metadata.c $out/include/mpss-metadata.c
      install -m644 -b -D mpss-metadata.mk $out/include/mpss-metadata.mk
      install -m644 -b -D mpss-metadata.props $out/include/mpss-metadata.props
    '';
  };
  gen-symver-map = stdenv.mkDerivation rec {
    name = "gen-symver-map";
    inherit version;

    src = "${srcs.mpss-src}/src/gen-symver-map-${version}.tar.bz2";
    buildInputs = [
      pkgs.python27
    ];
    installPhase = ''
      mkdir -p $out
      install -m755 -b -D gen-symver-map $out/bin/gen-symver-map
    '';
  };
  libscif = stdenv.mkDerivation rec {
    name = "libscif";
    inherit version;

    nativeBuildInputs = [ gen-symver-map asciidoc-full ];
    buildInputs = [ modules.dev ];
    enableParallelBuilding = true;
    src = "${srcs.mpss-src}/src/libscif-${version}.tar.bz2";
    makeFlags = [
      "-I${metadata}/include"
      "DESTDIR=$(out)"
      "prefix="
    ];
  };
  daemon = stdenv.mkDerivation rec {
    name = "mpss-daemon";
    inherit version;

    patches = [ ./mpss-daemon.patch ];
    buildInputs = [ libscif ];
    enableParallelBuilding = true;
    src = "${srcs.mpss-src}/src/mpss-daemon-${version}.tar.bz2";
    makeFlags = [
      "DESTDIR=$(out)"
      "prefix="
    ];
    preBuild = ''
      makeFlagsArray+=(INSTALL_s="install -m 755")
    '';
  };
in {
  inherit modules daemon libscif metadata gen-symver-map;
}