aboutsummaryrefslogtreecommitdiff
path: root/shell.nix
blob: 2192c26abe06410e858477fa5a212c7d275947f4 (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
{ pkgs ? import <nixpkgs> { }, ... }:

pkgs.stdenvNoCC.mkDerivation rec {
  name = "pycl-env";
  env = pkgs.buildEnv { name = name; paths = buildInputs; };

  buildInputs = let
    custom-python = let
      packageOverrides = self: super: {
        pyopencl = super.pyopencl.overridePythonAttrs(old: rec {
          buildInputs = with pkgs; [
            opencl-headers ocl-icd
            python3Packages.pybind11
            libGLU libGL
          ];
        # Enable OpenGL integration and fix build
          preBuild = ''
            python configure.py --cl-enable-gl
            echo "CL_PRETEND_VERSION = \"1.2\"" >> siteconf.py
            export HOME=/tmp/pyopencl
          '';
        });

        pyopengl = super.pyopengl.overridePythonAttrs(old:  rec {
          version = "3.1.0";
          src = self.fetchPypi {
            pname = "PyOpenGL";
            inherit version;
            sha256 = "1byxjj6a8rwzhxhjqlc588zdad2qwxdd7vlam2653ylll31waiwv";
          };
        });

      };
    in pkgs.python3.override { inherit packageOverrides; };

    pyevtk = pkgs.python3.pkgs.buildPythonPackage rec {
      pname = "PyEVTK";
      version = "1.2.1";

      src = pkgs.fetchFromGitHub {
        owner  = "paulo-herrera";
        repo   = "PyEVTK";
        rev    = "v1.2.1";
        sha256 = "1p2459dqvgakywvy5d31818hix4kic6ks9j4m582ypxyk5wj1ksz";
      };

      buildInputs = with pkgs.python3Packages; [
        numpy
      ];

      doCheck = false;
    };

    local-python = custom-python.withPackages (python-packages: with python-packages; [
      numpy
      sympy
      pyopencl
      pyopengl
      pyrr
      matplotlib
      Mako
      pyevtk

    # jupyter, optional
      jupyterlab
      ipywidgets
    ]);

  in [
    local-python
    pkgs.opencl-info
  # jupyter dependencies
    pkgs.nodejs

    pkgs.universal-ctags
  ];

  shellHook = ''
    export NIX_SHELL_NAME="${name}"
    export PYOPENCL_COMPILER_OUTPUT=1
    export PYTHONPATH="$PWD:$PYTHONPATH"
  '';
}