-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
1293 lines (1204 loc) · 58 KB
/
flake.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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{
description = "fun with jupyterWith and poetry2nix";
inputs = {
nixpkgs.url = "github:sepiabrown/nixpkgs/pythonRelaxDepsHook";
nixpkgs_2211.url = "github:sepiabrown/nixpkgs/nixos-unstable_pythonRelaxDepsHook";
#nixpkgs.url = "nixpkgs/nixos-22.05";
#nixpkgs_2211.url = "nixpkgs/nixos-unstable";
poetry2nix = {
#url = "github:sepiabrown/poetry2nix/python_overlay_fix";
url = "github:nix-community/poetry2nix";
#url = "github:nix-community/poetry2nix?ref=refs/pull/787/merge";
# https://github.com/nix-community/poetry2nix/issues/810#issuecomment-1312531883
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
jupyterWith = {
url = "github:tweag/jupyterWith/deaa6c66165fd1ebe8617a8f133ad45110ac659c";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs: with inputs;
let
LD_LIBRARY_PATH = ''
${nixpkgs.lib.makeLibraryPath [ self.pkgs.x86_64-linux.cudaPackages.cudatoolkit "${self.pkgs.x86_64-linux.cudaPackages.cudatoolkit}" self.pkgs.x86_64-linux.cudaPackages.cudnn self.pkgs.x86_64-linux.nvidia_custom ]}:$LD_LIBRARY_PATH
'';
pkgs_2211 = import nixpkgs_2211 {
system = "x86_64-linux";
config.allowUnfree = true;
config.cudaSupport = true;
config.mklSupport = true;
#overlays = [ self.overlay ];
#overlays = (builtins.attrValues jupyterWith.overlays) ++ [ self.overlay ]; # [ (import ./haskell-overlay.nix) ];
};
in
{
# Order of overlays matter! Earlier ones get overriden before later ones.
overlay = nixpkgs.lib.composeManyExtensions (
#(builtins.attrValues jupyterWith.overlays) ++
[
#(final: prev: {
# poetry2nix = (poetry2nix.overlay final prev).poetry2nix.overrideScope' (p2nixfinal: p2nixprev: {
# # pyfinal & pyprev refers to python packages
# defaultPoetryOverrides = (p2nixprev.defaultPoetryOverrides.overrideOverlay (pyfinal: pyprev: {
# tensorflow = null;
# tensorflow-gpu = null;
# }));
# });
#})
(final: prev: {
poetry2nix = prev.poetry2nix.overrideScope' (p2nixfinal: p2nixprev: {
# pyfinal & pyprev refers to python packages
defaultPoetryOverrides = (p2nixprev.defaultPoetryOverrides.overrideOverlay (pyfinal: pyprev: {
babel = null;
Babel = null;
babel_ = pyprev.babel;
keras = null;
Keras = null;
keras_ = pyprev.keras;
tensorflow = null;
tensorflow-gpu = null;
})).extend (pyfinal: pyprev: {
babel = pyprev.babel_;
keras = pyprev.keras_;
});
});
})
#(final: prev: {
# poetry2nix = prev.poetry2nix.overrideScope' (p2nixfinal: p2nixprev: {
# # pyfinal & pyprev refers to python packages
# defaultPoetryOverrides = (p2nixprev.defaultPoetryOverrides.extend (pyfinal: pyprev: {
# babel = pyprev.babel_;
# keras = pyprev.keras_;
# }));
# });
#})
(final: prev: {
blas_custom = (prev.blas.override {
blasProvider = final.mkl;
}).overrideAttrs (oldAttrs: {
buildInputs = (oldAttrs.buildInputs or [ ])
++ final.lib.optional final.stdenv.hostPlatform.isDarwin final.fixDarwinDylibNames;
});
cudaPackages = prev.cudaPackages_11_6;
#cudaPackages = prev.cudaPackages_11_3;
lapack_custom = (prev.lapack.override {
lapackProvider = final.mkl;
}).overrideAttrs (oldAttrs: {
buildInputs = (oldAttrs.buildInputs or [ ])
++ final.lib.optional final.stdenv.hostPlatform.isDarwin final.fixDarwinDylibNames;
});
nvidia_custom = prev.linuxPackages.nvidia_x11.overrideAttrs (oldAttrs: rec {
version = "495.29.05";
src = builtins.fetchurl {
url = "https://us.download.nvidia.com/XFree86/Linux-x86_64/${version}/NVIDIA-Linux-x86_64-${version}.run";
sha256 = "sha256-9yVLl9QAxpJQR5ZJb059j2TpOx4xxCeGCk8hmhhvEl4="; #prev.lib.fakeSha256;
};
});
poetry2nix = prev.poetry2nix.overrideScope' (p2nixfinal: p2nixprev: {
# pyfinal & pyprev refers to python packages
defaultPoetryOverrides = (p2nixprev.defaultPoetryOverrides.extend (pyfinal: pyprev:
let
inherit (final.cudaPackages) cudatoolkit cudnn nccl;
cudatoolkit_joined = final.symlinkJoin {
name = "${cudatoolkit.name}-unsplit";
# nccl is here purely for semantic grouping it could be moved to nativeBuildInputs
paths = [ cudatoolkit.out cudatoolkit.lib nccl.dev nccl.out ];
};
brokenArchs = [ "3.0" ]; # this variable is only used as documentation.
cudaCapabilities = rec {
cuda9 = [
"3.5"
"5.0"
"5.2"
"6.0"
"6.1"
"7.0"
"7.0+PTX" # I am getting a "undefined architecture compute_75" on cuda 9
# which leads me to believe this is the final cuda-9-compatible architecture.
];
cuda10 = cuda9 ++ [
"7.5"
"7.5+PTX" # < most recent architecture as of cudatoolkit_10_0 and pytorch-1.2.0
];
cuda11 = cuda10 ++ [
"8.0"
"8.0+PTX" # < CUDA toolkit 11.0
"8.6"
"8.6+PTX" # < CUDA toolkit 11.1
];
};
final_cudaArchList =
if !final.cudaSupport || final.cudaArchList != null
then final.cudaArchList
else cudaCapabilities."cuda${nixpkgs.lib.versions.major cudatoolkit.version}";
# Normally libcuda.so.1 is provided at runtime by nvidia-x11 via
# LD_LIBRARY_PATH=/run/opengl-driver/lib. We only use the stub
# libcuda.so from cudatoolkit for running tests, so that we don’t have
# to recompile pytorch on every update to nvidia-x11 or the kernel.
cudaStub = final.linkFarm "cuda-stub" [{
name = "libcuda.so.1";
path = "${cudatoolkit}/lib/stubs/libcuda.so";
}];
cudaStubEnv = nixpkgs.lib.optionalString cudaSupport
"LD_LIBRARY_PATH=${cudaStub}\${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH ";
in
{
############################################################
### Necessities for solving infinite recursion ###
python_selected = prev.python39Packages;
#setuptools = (pyfinal.python_selected.setuptools.overridePythonAttrs (old: {
setuptools = (pkgs_2211.python39Packages.setuptools.override {
# 65.3.0 : nixos-22.11
inherit (pyfinal)
python
bootstrapped-pip
pipInstallHook
setuptoolsBuildHook
;
}).overridePythonAttrs (old: rec {
#catchConflicts = false;
#format = "other";
});
# With this, skipSetupToolsSCM in mk-poetry-dep.nix is not needed
#setuptools-scm = pyfinal.python_selected.setuptools-scm.override {
setuptools-scm = pkgs_2211.python39Packages.setuptools-scm.override {
# 7.0.5 : nixos-22.11
inherit (pyfinal)
packaging
typing-extensions
tomli
setuptools;
};
#pip = pyfinal.python_selected.pip.override {
pip = pkgs_2211.python39Packages.pip.override {
# 22.2.2 : nixos-22.11
inherit (pyfinal)
bootstrapped-pip
mock
scripttest
virtualenv
pretend
pytest
pip-tools
;
};
### Necessities for solving infinite recursion (end) ###
############################################################
############################################################
### Override python packages if they lack dependencies
#apache-beam = pyprev.apache-beam.overridePythonAttrs (old: rec {
#apache-beam = pyfinal.python_selected.apache-beam.overridePythonAttrs (old: {
#apache-beam = (pkgs_2211.python39Packages.apache-beam.override {
# inherit (pyfinal)
# cloudpickle
# crcmod
# cython
# dill
# fastavro
# freezegun
# grpcio
# grpcio-tools
# hdfs
# httplib2
# mock
# mypy-protobuf
# numpy
# oauth2client
# orjson
# pandas
# parameterized
# proto-plus
# protobuf
# psycopg2
# pyarrow
# pydot
# pyhamcrest
# pymongo
# pytestCheckHook
# python-dateutil
# pythonRelaxDepsHook
# pytz
# pyyaml
# requests
# requests-mock
# scikit-learn
# sqlalchemy
# tenacity
# #testcontainers # doesn't exist in 22.05
# typing-extensions;
#}).overridePythonAttrs (old: {
# version = pyprev.apache-beam.version;
# src = pyprev.apache-beam.src;
#});
cryptography = pyprev.cryptography.overridePythonAttrs (old: rec {
#buildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.buildInputs or [ ]) ++ [ final. ]);
#nativeBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.nativeBuildInputs or [ ]) ++ [ final. ]);
#propagatedBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.propagatedBuildInputs or [ ]) ++ [ pyfinal. ]);
cargoDeps =
prev.rustPlatform.fetchCargoTarball {
src = old.src;
sourceRoot = "${old.pname}-${old.version}/${cargoRoot}";
name = "${old.pname}-${old.version}";
#inherit sha256;
#sha256 = "sha256-lzHLW1N4hZj+nn08NZiPVM/X+SEcIsuZDjEOy0OOkSc=";
sha256 = "sha256-BN0kOblUwgHj5QBf52RY2Jx0nBn03lwoN1O5PEohbwY=";
};
cargoRoot = "src/rust";
});
# = (pyfinal.python_selected..override {
# = (pkgs_2211.python39Packages..override {
## 1.23.0 : nixos-22.05< <22.11
# inherit (pyfinal)
# ;
#}).overridePythonAttrs (old: rec {
# version = pyprev..version;
# src = pyprev..src;
#});
comm = pyprev.comm.overridePythonAttrs (old: rec {
propagatedBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.propagatedBuildInputs or [ ]) ++ [ pyfinal.hatchling ]);
});
contourpy = pyprev.contourpy.overridePythonAttrs (old: rec {
propagatedBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.propagatedBuildInputs or [ ]) ++ [ pyfinal.pybind11 ]);
});
#cython = pyprev.cython.overridePythonAttrs (old: rec {
# propagatedBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.propagatedBuildInputs or [ ]) ++ [ pyfinal.setuptools ]);
#});
# = (pyfinal.python_selected..override {
cython = (pkgs_2211.python39Packages.cython.override {
# 0.29.32 : nixos-22.11
inherit (pyfinal)
python
numpy
;
}).overridePythonAttrs (old: rec {
#version = pyprev.cython.version; # this overrides with poetry2nix version, reverting our override
#src = pyprev.cython.src;
});
Cython = pyfinal.cython;
#dm-sonnet = (pyprev.dm-sonnet.override {
dm-sonnet = (pkgs_2211.python39Packages.dm-sonnet.override {
# 2.0.0 : nixos-22.11
inherit (pyfinal)
absl-py
dm-tree
docutils
numpy
tabulate
tensorflow-datasets
wrapt;
tensorflow = pyfinal.tensorflow-gpu;
}).overridePythonAttrs (old: {
propagatedBuildInputs = [
pyfinal.dm-tree
pkgs_2211.python39Packages.etils
pyfinal.numpy
pyfinal.tabulate
pyfinal.wrapt
pyfinal.absl-py
pyfinal.six
pyfinal.importlib-resources
pyfinal.typing-extensions
pyfinal.zipp
];
#version = pyprev.dm-sonnet.version;
#src = pyprev.dm-sonnet.src;
});
#dm-tree = pyfinal.python_selected.dm-tree.override {
#dm-tree = pyprev.dm-tree.override {
dm-tree = (pkgs_2211.python39Packages.dm-tree.override {
# 0.1.7 : nixos-22.11
inherit (pyfinal)
absl-py
attrs
numpy
pybind11
wrapt;
}).overridePythonAttrs (old: {
version = pyprev.dm-tree.version;
src = pyprev.dm-tree.src;
});
#grpcio-tools = pkgs_2211.python39Packages.grpcio-tools.override {
# inherit (pyfinal)
# protobuf
# grpcio;
#};
# = (pyfinal.python_selected..override {
hatch-nodejs-version = (pkgs_2211.python39Packages.hatch-nodejs-version.override {
# 0.3.0 : nixos-22.11<
inherit (pyfinal)
pytestCheckHook
hatchling
;
}).overridePythonAttrs (old: rec {
#version = pyprev.hatch-nodejs-version.version; # doesn't exist in 22.05
#src = pyprev.hatch-nodejs-version.src;
});
h5py = (pyfinal.python_selected.h5py.override {
# 3.6.0 : nixos-22.05
inherit (pyfinal)
numpy
cython
six
pkgconfig
unittest2
mpi4py
openssh
pytestCheckHook
cached-property
;
}).overridePythonAttrs (old: rec {
#version = pyprev.h5py.version; # format issue
#src = pyprev.h5py.src;
});
idna = pyprev.idna.overridePythonAttrs (old: rec {
propagatedBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.propagatedBuildInputs or [ ]) ++ [ pyfinal.flit-core ]);
});
####
#jax = (pyprev.jax.overridePythonAttrs (old: rec {
#jax = (pyfinal.python_selected.jax.override {
jax = (pkgs_2211.python39Packages.jax.override {
# 0.3.23 : nixos-22.11
inherit (pyfinal)
absl-py
jaxlib
matplotlib
numpy
opt-einsum
pytestCheckHook
pytest-xdist # duplicated packages error
scipy
typing-extensions
;
etils = pkgs_2211.python39Packages.etils;
blas = final.blas_custom;
lapack = final.lapack_custom;
}).overridePythonAttrs (old: rec {
buildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.buildInputs or [ ]) ++ [
#pyfinal.jaxlib
]);
propagatedBuildInputs = [
pyfinal.absl-py
pkgs_2211.python39Packages.etils
pyfinal.numpy
pyfinal.opt-einsum
pyfinal.scipy
pyfinal.typing-extensions
pyfinal.importlib-resources
pyfinal.zipp
];
#version = pyprev.jax.version; # format issue
#src = pyprev.jax.src;
});
####
#jaxlib = (pkgs_2211.python39Packages.jaxlib.override {
##jaxlib = pyprev.jaxlib.override {
jaxlib = (pyfinal.python_selected.jaxlib.override {
# 0.3.20 : nixos-22.05< <nixos-22.11
inherit (pyfinal)
# Build-time dependencies:
python
cython
pybind11
setuptools
wheel
# Python dependencies:
absl-py
flatbuffers
numpy
scipy
six
;
cudaSupport = true;
cudaPackages = final.cudaPackages;
mklSupport = true;
}).overridePythonAttrs (old: rec {
version = pyprev.jaxlib.version;
src = pyprev.jaxlib.src;
});
# = (pyfinal.python_selected..override {
jsonschema = (pkgs_2211.python39Packages.jsonschema.override {
# 4.17.1 : nixos-22.11<
inherit (pyfinal)
attrs
hatch-fancy-pypi-readme
hatch-vcs
hatchling
importlib-metadata
importlib-resources
pyrsistent
twisted
typing-extensions
;
}).overridePythonAttrs (old: rec {
version = pyprev.jsonschema.version;
src = pyprev.jsonschema.src;
});
# = (pyfinal.python_selected..override {
jupyter = (pkgs_2211.python39Packages.jupyter.override {
# 1.0.0 : nixos-22.11<
inherit (pyfinal)
notebook
qtconsole
jupyter_console
nbconvert
ipykernel
ipywidgets
;
}).overridePythonAttrs (old: rec {
#version = pyprev.jupyter.version;
#src = pyprev.jupyter.src;
});
jupyterlab = pyprev.jupyterlab.overridePythonAttrs (oldAttrs: {
makeWrapperArgs = (oldAttrs.makeWrapperArgs or [ ]) ++ [
"--set LD_LIBRARY_PATH"
LD_LIBRARY_PATH
"--set TF_ENABLE_ONEDNN_OPTS 0" # when using GPU, oneDNN off is recommended
"--set XLA_FLAGS --xla_gpu_cuda_data_dir=${cudatoolkit}"
#"--set AESARA_FLAGS device=cuda0,dnn__base_path=${cudnn},blas__ldflags=-lblas,dnn__library_path=${cudnn}/lib,dnn__include_path=${cudnn}/include"#${nixpkgs.lib.makeLibraryPath [ cudnn ]}" #,cuda__root=${cudatoolkit}
#"--set CUDA_HOME ${cudatoolkit}"
#"--set CUDA_INC_DIR ${cudatoolkit}/include"
];
});
# My guess : poetry2nix makes one of duplicated packges to null
# Here, jupyter_core, jupyter-core are duplicated so make jupyter_core null
# Solution : bring jupyter_core back like below
#jupyter_core = pyprev.jupyter-core;
# Nope, below is better
#jupyter_core = (pyfinal.python_selected.jupyter_core.override {
jupyter_core = (pkgs_2211.python39Packages.jupyter_core.override {
# 5.0.0 : nixos-22.11<
inherit (pyfinal)
hatchling
traitlets
pytestCheckHook
;
}).overridePythonAttrs (old: rec {
#version = pyprev.jupyter-core.version;
#src = pyprev.jupyter-core.src;
#version = pyprev.jupyter_core.version;
#src = pyprev.jupyter_core.src;
nativeBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.nativeBuildInputs or [ ]) ++ [ pyfinal.platformdirs ]);
propagatedBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.propagatedBuildInputs or [ ]) ++ [ pyfinal.platformdirs ]);
});
jupyter-core = pyfinal.jupyter_core;
matplotlib = (pyfinal.python_selected.matplotlib.override {
#matplotlib = (pkgs_2211.python39Packages.matplotlib.override {
# 3.6.2 : nixos-22.11<
inherit (pyfinal)
pycairo
cycler
python-dateutil
numpy
pyparsing
sphinx
tornado
kiwisolver
mock
pytz
pygobject3
certifi
pillow
fonttools
setuptools-scm
setuptools-scm-git-archive
packaging
tkinter
pyqt5
;
}).overridePythonAttrs (old: rec {
version = pyprev.matplotlib.version;
src = pyprev.matplotlib.src;
buildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.buildInputs or [ ]) ++ [
final.ghostscript
]);
propagatedBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.propagatedBuildInputs or [ ]) ++ [ pyfinal.contourpy ]);
});
# buildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.buildInputs or [ ]) ++ [ final. ]);
# nativeBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.nativeBuildInputs or [ ]) ++ [ final. ]);
# propagatedBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.propagatedBuildInputs or [ ]) ++ [ pyfinal. ]);
#});
# = (pyfinal.python_selected..override {
#meson-python = (pkgs_2211.python39Packages.meson-python.override {
### 1.23.0 : nixos-22.05< <22.11<
## inherit (pyfinal)
## ;
#}).overridePythonAttrs (old: rec {
# version = pyprev.meson-python.version;
# src = pyprev.meson-python.src;
#});
#nbclient = (pyfinal.python_selected.nbclient.override {
nbclient = (pkgs_2211.python39Packages.nbclient.override {
# 0.7.0 : nixos-22.11<
inherit (pyfinal)
async_generator
ipykernel
ipywidgets
jupyter-client
nbconvert
nbformat
nest-asyncio
pytest-asyncio
pytestCheckHook
traitlets
xmltodict
;
}).overridePythonAttrs (old: rec {
version = pyprev.nbclient.version;
src = pyprev.nbclient.src;
});
#nbdev = pyprev.nbdev.overridePythonAttrs (old: rec {
# # buildInputs, nativeBuildInputs, propagatedNativeBuildInputs doesn't work.
# buildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.buildInputs or [ ]) ++ [
# self.packages.x86_64-linux.quarto
# ]);
# propagatedBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.propagatedBuildInputs or [ ]) ++ [
# pyfinal.twine
# ]);
#});
#nbformat = (pyfinal.python_selected.nbformat.override {
nbformat = (pkgs_2211.python39Packages.nbformat.override {
# 5.7.0 : nixos-22.11
inherit (pyfinal)
hatchling
hatch-nodejs-version
fastjsonschema
jsonschema
jupyter_core
traitlets
pep440
testpath
;
pytestCheckHook = null;
#hatch-nodejs-version = pkgs_2211.python39Packages.hatch-nodejs-version;
}).overridePythonAttrs (old: rec {
version = pyprev.nbformat.version;
src = pyprev.nbformat.src;
});
##numba = pkgs_2211.python39Packages.numba.override {
#numba = pyfinal.python_selected.numba.override {
# inherit (pyfinal)
# numpy
# setuptools
# llvmlite;
# #importlib-metadata;
# python = pyfinal.python_selected;
# cudaPackages = final.cudaPackages;
# cudaSupport = true;
#};
#numpy = (pkgs_2211.python39Packages.numpy.override {
# glibc_2.35 not found
numpy = (pyfinal.python_selected.numpy.override {
# 1.23.0 : nixos-22.05< <22.11
inherit (pyfinal)
python
hypothesis
pytest
#typing-extensions
cython
;
blas = final.blas_custom; # not prev.blas
lapack = final.lapack_custom; # not prev.blas
}).overridePythonAttrs (old: rec {
version = pyprev.numpy.version;
src = pyprev.numpy.src;
});
# poetry.lock : 7.0.0 , nix repl : 8.0.0 because apache-beam (2.40.0) depends on pyarrow (>=0.15.1,<8.0.0)
#pyarrow = pyfinal.python_selected.pyarrow.override {
# inherit (pyfinal)
# cffi
# cloudpickle
# cython
# fsspec
# hypothesis
# numpy
# pandas
# pytestCheckHook
# pytest-lazy-fixture
# scipy
# setuptools-scm
# six;
# python = pyfinal.python_selected;
#};
# = (pyfinal.python_selected..override {
# = (pkgs_2211.python39Packages..override {
## 1.23.0 : nixos-22.05< <22.11<
# inherit (pyfinal)
# ;
#}).overridePythonAttrs (old: rec {
# version = pyprev..version;
# src = pyprev..src;
#});
# = (pyfinal.python_selected..override {
poetry = (pkgs_2211.python39Packages.poetry.override {
# 1.2.2 : nixos-22.05< <22.11<
#inherit (pyfinal)
#;
}).overridePythonAttrs (old: rec {
# version = pyprev..version;
# src = pyprev..src;
});
PyTDC = pyprev.pytdc;
pytorch = pyfinal.torch;
#scipy = pyprev.scipy.overridePythonAttrs (old: rec {
# buildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.buildInputs or [ ]) ++ [ final. ]);
# nativeBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.nativeBuildInputs or [ ]) ++ [ pkgs_2211.python39Packages.meson-python final.pkg-config ]);
# propagatedBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.propagatedBuildInputs or [ ]) ++ [ pyfinal. ]);
#});
#scipy = (pkgs_2211.python39Packages.scipy.override {
scipy = (pyfinal.python_selected.scipy.override {
# 1.9.3 : nixos-22.11< # not working
# 1.9.1 : nixos-22.11 # not working
# 1.8.0 : nixos-22.05
inherit (pyfinal)
python
cython
pythran
#meson-python
nose
pytest
pytest-xdist
numpy
pybind11
;
#meson-python = pkgs_2211.python39Packages.meson-python;
}).overridePythonAttrs (old: rec {
#version = pyprev.scipy.version; # format issue
#src = pyprev.scipy.src;
});
seaborn = pyprev.seaborn.overridePythonAttrs (old: rec {
propagatedBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.propagatedBuildInputs or [ ]) ++ [ pyfinal.flit-core ]);
});
#tensorboard : tensorflow in pyproproject
#tensorflow-gpu = (pkgs_2211.python39Packages.tensorflow.override {
tensorflow-gpu = (pyfinal.python_selected.tensorflowWithCuda.override {
# 2.10.0 : nixos-22.11
# failed :Compiling tensorflow/lite/delegates/telemetry.cc failed: (Exit 1): crosstool_wrapper_driver_is_not_gcc failed:
# 2.8.1 : nixos-22.05
#bazel_5, buildBazelPackage, isPy3k, lib, fetchFromGitHub, symlinkJoin
#which binutils perl
## Common libraries
#jemalloc mpi grpc sqlite boringssl jsoncpp nsync
#curl snappy lmdb-core icu double-conversion libpng libjpeg_turbo giflib;
inherit (pyfinal)
python
pybind11 cython
numpy tensorboard absl-py
#packaging
setuptools wheel keras keras-preprocessing google-pasta
opt-einsum astunparse h5py
termcolor grpcio six wrapt tensorflow-estimator
dill portpicker tblib typing-extensions
gast;
#glibcLocales = pkgs_2211.glibcLocales;
protobuf-python = pyfinal.protobuf;
protobuf-core = final.protobuf;
flatbuffers-python = pyfinal.flatbuffers;
flatbuffers-core = final.flatbuffers;
mklSupport = true;
mkl = final.mkl;
}).overridePythonAttrs (old: {
#nativeBuildInputs = builtins.filter (x: ! builtins.elem (x.name or x.pname or "") [ "hook" ]) ((old.nativeBuildInputs or [ ]) ++ [
#pyfinal.setuptools # for pkgs_2211?
#]);
#dontUsePipInstall = true; # doesn't work
#version = pyprev.tensorflow-gpu.version; # can't read setup.py
#src = pyprev.tensorflow-gpu.src;
});
tensorflow-datasets = pyprev.tensorflow-datasets.overridePythonAttrs (old: rec {
propagatedBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.propagatedBuildInputs or [ ]) ++ [
pyfinal.tensorflow-gpu
]);
});
tensorflow-io-gcs-filesystem = pyprev.tensorflow-io-gcs-filesystem.overridePythonAttrs (old: { propagatedBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.propagatedBuildInputs or [ ]) ++ [ pyfinal.numpy ]); buildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.buildInputs or [ ]) ++ [ final.libtensorflow ]); });
#tensorflow-metadata = (pyfinal.python_selected.tensorflow-metadata.overridePythonAttrs (old: rec {
tensorflow-metadata = pyprev.tensorflow-metadata.overridePythonAttrs (old: rec {
nativeBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.nativeBuildInputs or [ ]) ++ [ pyfinal.pythonRelaxDepsHook ]);
pythonRelaxDeps = [ "protobuf" ];
});
termcolor = pyprev.termcolor.overridePythonAttrs (old: rec {
propagatedBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.propagatedBuildInputs or [ ]) ++ [
pyfinal.hatchling
# 'hatchling.build' has no attribute 'prepare_metadata_for_build_wheel': needs hatch-vcs not importlib-metadata
pyfinal.hatch-vcs
]);
});
torch = (pyprev.torch.override {
inherit cudatoolkit;
#cudatoolkit = final.cudaPackages_11_6.cudatoolkit;
enableCuda = true;
}).overrideAttrs (old: rec {
buildInputs = [
pyfinal.setuptools-scm
pyfinal.typing-extensions
final.linuxPackages.nvidia_x11
final.cudaPackages_11_6.nccl.dev
final.cudaPackages_11_6.nccl.out
];
# nativeBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.nativeBuildInputs or [ ]) ++ [ final. ]);
# propagatedBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.propagatedBuildInputs or [ ]) ++ [ pyfinal. ]);
});
# nixos-22.11 : CHANGES NAME TO pyfinal.python_selected.torch!
#torch = (pyfinal.python_selected.pytorch.override {
#torch = (pkgs_2211.python39Packages.torch.override {
## 1.12.1 : nixos-22.11
# inherit (final)
# magma
# mpi
# cudaPackages
# ;
# inherit (pyfinal)
# # Native build inputs
# pybind11
# # Propagated build inputs
# numpy
# pyyaml
# cffi
# click
# typing-extensions
# # Unit tests
# hypothesis
# psutil
# # dependencies for torch.utils.tensorboard
# pillow
# six
# future
# tensorboard
# protobuf
# ;
# blas = final.blas_custom;
# MPISupport = true;
#}).overridePythonAttrs (old: rec {
# # needed for 22.05 https://github.com/NixOS/nixpkgs/pull/175962
# USE_SYSTEM_BIND11 = true;
# buildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.buildInputs or [ ]) ++ [
# #pyfinal.pybind11
# pyfinal.typing-extensions
# ]);
# #version = pyprev.torch.version;
# #src = pyprev.torch.src;
#});
#cu113 not working : changed to cu116
#torch = (pyfinal.python_selected.pytorch-bin.override {
#torch = (pkgs_2211.python39Packages.torch-bin.override {
## 1.12.1 : nixos-22.11
# inherit (pyfinal)
# python
# future
# numpy
# pyyaml
# requests
# setuptools
# typing-extensions
# ;
#}).overridePythonAttrs (old: rec {
## # needed for 22.05 https://github.com/NixOS/nixpkgs/pull/175962
## USE_SYSTEM_BIND11 = true;
## buildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.buildInputs or [ ]) ++ [
## pyfinal.pybind11
## ]);
# version = pyprev.torch.version;
# src = pyprev.torch.src;
#})
#torch = nixpkgs.lib.makeOverridable
# ({ enableCuda ? true
# , cudatoolkit ? cudatoolkit
# , pkg ? pyprev.torch
# }: pkg.overrideAttrs (old:
# {
# preConfigure =
# if (!enableCuda) then ''
# export USE_CUDA=0
# '' else ''
# export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${cudatoolkit}/targets/x86_64-linux/lib"
# '';
# preFixup = lib.optionalString (!enableCuda) ''
# # For some reason pytorch retains a reference to libcuda even if it
# # is explicitly disabled with USE_CUDA=0.
# find $out -name "*.so" -exec ${pkgs.patchelf}/bin/patchelf --remove-needed libcuda.so.1 {} \;
# '';
# buildInputs =
# (old.buildInputs or [ ])
# ++ [ self.typing-extensions ]
# ++ lib.optionals enableCuda [
# pkgs.linuxPackages.nvidia_x11
# pkgs.nccl.dev
# pkgs.nccl.out
# ];
# propagatedBuildInputs = [
# self.numpy
# self.future
# self.typing-extensions
# ];
# })
# )
# { };
#torch-scatter = pyprev.torch-scatter.overridePythonAttrs (old: rec {
# BUILD_NAMEDTENSOR = "1";
# USE_MKLDNN = "1";
# USE_MKLDNN_CBLAS = "1";
# USE_SYSTEM_BIND11 = "1";
# USE_SYSTEM_NCCL = "1";
# uildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.buildInputs or [ ]) ++ [ cudnn final.magma nccl final.numactl ]);
# nativeBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.nativeBuildInputs or [ ]) ++ [ cudatoolkit_joined ]);
# propagatedBuildInputs = builtins.filter (x: ! builtins.elem x [ ]) ((old.propagatedBuildInputs or [ ]) ++ [ final.mpi ]);
#});
quarto = pyprev.quarto.override {
preferWheel = true;
};
xarray-einstats = pyprev.xarray-einstats.overridePythonAttrs (old: {
buildInputs = (old.buildInputs or [ ]) ++ [ pyfinal.flit-core ];
});
# = (pyfinal.python_selected..override {
xgboost = (pkgs_2211.python39Packages.xgboost.override {
# 1.23.0 : nixos-22.05< <22.11
inherit (pyfinal)
pytestCheckHook
scipy
scikit-learn
pandas
matplotlib
graphviz
datatable
hypothesis
;
}).overridePythonAttrs (old: rec {
version = pyprev.xgboost.version;
src = pyprev.xgboost.src;
});
}));
});
})
] ++ (builtins.attrValues jupyterWith.overlays)
#++ [
#(final: prev: {
# jupyterWith_python_custom = final.jupyterWith.override {
# python3 = self.python_custom.x86_64-linux;
# };
#})
#]
);
} // (flake-utils.lib.eachDefaultSystem (system:
rec
{
#jupyterWith_custom = jupyterWith.;
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
config.cudaSupport = true;
config.mklSupport = true;
overlays = [ self.overlay ];
};
python_custom = pkgs.poetry2nix.mkPoetryEnv rec {
projectDir = ./.;
python = pkgs.python39;
editablePackageSources = {
mypackages = "~/Jupyter_Python"; #./.; not working
};
};
pyproject = builtins.fromTOML (builtins.readFile ./pyproject.toml);
depNames = builtins.attrNames pyproject.tool.poetry.dependencies;
iPythonWithPackages = pkgs.jupyterWith.kernels.iPythonWith {
name = "my-awesome-python-env";
python3 = python_custom;
packages = p:
let
## Building the local package using the standard way.
#myPythonPackage = p.buildPythonPackage {
# pname = "MyPythonPackage";
# version = "1.0";
# src = ./my-python-package;
#};
poetryDeps =
builtins.map (name: builtins.getAttr name p) depNames;
in
poetryDeps; #++ [ myPythonPackage ];
};
jupyterEnvironment = (pkgs.jupyterWith.jupyterlabWith {
kernels = [ iPythonWithPackages ];
#extraPackages = ps: [
#];
});
apps.jupyter-lab = {
type = "app";