-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshell.nix
223 lines (219 loc) · 8.49 KB
/
shell.nix
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
{ withJupyter ? false,
withCuda ? false }:
let
package = import ./default.nix {inherit withCuda;};
# pkgs = builtins.trace package.hsPkgs.ihaskell.components.library.outputs package.pkgs;
# pkgs = builtins.trace (builtins.attrNames package.hsPkgs.ihaskell) package.pkgs;
pkgs = package.pkgs;
gym-shell = import ./gym-haskell/shell.nix { inherit withCuda;
inherit package;
sources = (import gym-haskell/nix/sources.nix {}) // (import nix/sources.nix {}); };
buildInputs = [ pkgs.mesa.osmesa
pkgs.libGL
pkgs.xvfb-run
pkgs.xorg.libXinerama
pkgs.xorg.libXcursor
pkgs.libGLU
pkgs.mesa.drivers
pkgs.mesa
pkgs.mesa.dev
pkgs.python38Packages.matplotlib
pkgs.python38Packages.scipy
pkgs.texlive.combined.scheme-small
pkgs.curl
pkgs.cacert
pkgs.graphviz
pkgs."MagickWand-7.Q16HDRI"
pkgs."MagickCore-7.Q16HDRI"
pkgs.imagemagick.dev
pkgs.imagemagick
pkgs.protobuf
pkgs.hdf5
pkgs.matio
pkgs.c10
pkgs.feh
] ++ (if withJupyter
then [pkgs.python38Packages.jupytext]
else [])
++ gym-shell.buildInputs;
lib = pkgs.lib;
mapPkgs = v: "${lib.concatImapStringsSep ":" (pos: x: x + "/${pkgs.python3.sitePackages}") v}";
jupyterPkgs = package.pkgs.jupyterWith.nixpkgs.python3.pkgs;
jupyterPackages = package.pkgs.jupyterWith.nixpkgs.python38Packages;
# ihaskell = (pkgs.haskell-nix.hackage-package {
# name = "ihaskell";
# version = "0.10.2.1";
# compiler-nix-name = "ghc8107";
# # patches = [ ./patches/ihaskell-fixup-set-0.10.2.1.patch ];
# });
# ihaskell-magic = (pkgs.haskell-nix.hackage-package
# {name = "ihaskell-magic";
# version = "0.3.0.1";
# compiler-nix-name = "ghc8107";
# });
extra-python-packages = pkgs.python38.withPackages (pp: [
pp.matplotlib
pp.gym
package.pkgs.atari-py
package.pkgs.nes-py
package.pkgs.gym-super-mario-bros
package.pkgs.box2d
package.pkgs.box2d-py
package.pkgs.mujoco-py
package.pkgs.mujoco
]);
jupyterEnvironment = (package.pkgs.jupyterWith.jupyterlabWith {
extraPackages = p: [buildInputs] ++ [
(jupyterPkgs.buildPythonPackage rec {
pname = "jupyterthemes";
version = "0.20.0";
propagatedBuildInputs = [ jupyterPackages.notebook
jupyterPackages.matplotlib
(jupyterPkgs.buildPythonPackage rec {
pname = "lesscpy";
version = "0.13.0";
propagatedBuildInputs = [ jupyterPackages.six jupyterPackages.ply ];
doCheck = false;
src = jupyterPkgs.fetchPypi {
inherit pname version;
sha256 = "1bbjag13kawnjdn7q4flfrkd0a21rgn9ycfqsgfdmg658jsx1ipk";
};
# src = pkgs.fetchFromGitHub {
# owner = "lesscpy";
# repo = "lesscpy";
# rev = version;
# sha256 = "1jf5bp4ncvw2gahhkvjy5b0366y9x3ki9r9c5n6hkvifjk3jhmb2";
# };
LC_ALL = "en_US.utf8";
})
];
src = jupyterPkgs.fetchPypi {
inherit pname version;
sha256 = "07mldarwi9wi5m4v4x9s1n9m6grab307yxgip6csn4mjhh6br3ia";
};
})];
extraJupyterPath =
pkgs: "${extra-python-packages}/${extra-python-packages.sitePackages}"
# pkgs:
# mapPkgs (lib.attrVals [
# # matplotlib-related packages
# "matplotlib" "scipy" "numpy" "pillow" "cycler"
# "kiwisolver" "pytz" "cffi" "defusedxml" "certifi" "pyparsing" "six" "mock" "pbr"
# "sniffio" "tkinter" "olefile" "pytz" "anyio" "pyjson5"
# #
# "jupytext"
# #
# "gym"
# ]
# pkgs.python38Packages)
;
kernels = [
(package.pkgs.jupyterWith.kernels.iPythonWith {
name = "python";
packages = p:
((builtins.attrValues (pkgs.haskell-nix.haskellLib.selectLocalPackages package.hsPkgs))
++
buildInputs
);
})
(package.pkgs.jupyterWith.kernels.iHaskellWith {
name = "haskell";
extraIHaskellFlags = "--codemirror Haskell";
customIHaskell = pkgs.symlinkJoin {
name="ihaskell-haskell.nix";
paths=[
# ihaskell.components.exes.ihaskell
# ihaskell.components.library
package.hsPkgs.ihaskell.components.exes.ihaskell
package.hsPkgs.ihaskell.components.library
];
};
packages = p:
((builtins.attrValues (pkgs.haskell-nix.haskellLib.selectLocalPackages package.hsPkgs))
++
[
# ihaskell
# ihaskell-magic
package.hsPkgs.ihaskell
package.hsPkgs.ihaskell-magic
package.hsPkgs.ihaskell-graphviz
package.hsPkgs.ihaskell-juicypixels
# (pkgs.haskell-nix.hackage-package {name = "ihaskell-magic"; version = "0.3.0.1"; compiler-nix-name = "ghc8107";
# pkg-set = package.pkgs;
# })
# package.hsPkgs.ihaskell-magic
]
++
buildInputs
);
haskellPackages = package;
})];
});
mergeEnvs = envs: pkgs.mkShell (builtins.foldl' (a: v: {
buildInputs = a.buildInputs ++ v.buildInputs;
nativeBuildInputs = a.nativeBuildInputs ++ v.nativeBuildInputs;
propagatedBuildInputs = a.propagatedBuildInputs ++ v.propagatedBuildInputs;
propagatedNativeBuildInputs = a.propagatedNativeBuildInputs ++ v.propagatedNativeBuildInputs;
shellHook = a.shellHook + "\n" + v.shellHook;
LD_LIBRARY_PATH =
# builtins.trace v.LD_LIBRARY_PATH v.LD_LIBRARY_PATH
(if builtins.hasAttr "LD_LIBRARY_PATH" a then a.LD_LIBRARY_PATH else "")
+ ":" +
(if builtins.hasAttr "LD_LIBRARY_PATH" v then v.LD_LIBRARY_PATH else "")
;
}) (pkgs.mkShell {}) envs);
in
# jupyterEnvironment.env
# package.hsPkgs.ihaskell.components.exes.ihaskell
# (package.shellFor {
# tools = {
# cabal = { version = "latest"; };
# hpack = { version = "latest"; };
# hlint = { version = "latest"; };
# ormolu = { version = "latest"; };
# haskell-language-server = { version = "latest"; };
# };
# buildInputs = (if withJupyter then [jupyterEnvironment] else []) ++ buildInputs;
# exactDeps = true;
# LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
# })
builtins.trace (builtins.attrNames extra-python-packages)
# (map (x: builtins.attrNames x) pkgs.python38Packages.matplotlib.requiredPythonModules)
# (builtins.attrNames pkgs.python38Packages.matplotlib)
(
mergeEnvs (
[(package.shellFor {
tools = {
cabal = { version = "latest"; };
hpack = { version = "latest"; };
hlint = { version = "latest"; };
ormolu = { version = "latest"; };
haskell-language-server = { version = "latest"; };
};
buildInputs = (if withJupyter then [jupyterEnvironment] else []) ++ buildInputs;
exactDeps = true;
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
})]
++
(if withJupyter then [jupyterEnvironment.env] else [])
++
[gym-shell]
))
# # builtins.trace
# # (
# # builtins.attrNames jupyterEnvironment
# # )
# # (
# package.shellFor {
# tools = {
# cabal = { version = "latest"; };
# hpack = { version = "latest"; };
# hlint = { version = "latest"; };
# ormolu = { version = "latest"; };
# haskell-language-server = { version = "latest"; };
# };
# buildInputs = (if withJupyter then [jupyterEnvironment] else []) ++ buildInputs;
# exactDeps = true;
# LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
# }
# # )