Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib
2, stdenv
3, buildDunePackage
4, fetchFromGitHub
5, fetchpatch
6, cmdliner
7, ctypes
8, dune-configurator
9, npy
10, ocaml-compiler-libs
11, ppx_custom_printf
12, ppx_expect
13, ppx_sexp_conv
14, sexplib
15, stdio
16, torch
17}:
18
19buildDunePackage rec {
20 pname = "torch";
21 version = "0.17";
22
23 duneVersion = "3";
24 minimalOCamlVersion = "4.08";
25
26 src = fetchFromGitHub {
27 owner = "LaurentMazare";
28 repo = "ocaml-${pname}";
29 rev = version;
30 hash = "sha256-z/9NUBjeFWE63Z/e8OyzDiy8hrn6qzjaiBH8G9MPeos=";
31 };
32
33 patches = [
34 # Pytorch 2.0 support. Drop when it reaches a release
35 (fetchpatch {
36 url = "https://github.com/LaurentMazare/ocaml-torch/commit/ef7ef30cafecb09e45ec1ed8ce4bedae5947cfa5.patch";
37 hash = "sha256-smdwKy40iIISp/25L2J4az6KmqFS1soeChBElUyhl5A=";
38 })
39 ];
40
41 buildInputs = [ dune-configurator ];
42
43 propagatedBuildInputs = [
44 cmdliner
45 ctypes
46 npy
47 ocaml-compiler-libs
48 ppx_custom_printf
49 ppx_expect
50 ppx_sexp_conv
51 sexplib
52 stdio
53 torch
54 torch.dev
55 ];
56
57 preBuild = "export LIBTORCH=${torch.dev}/";
58
59 doCheck = !stdenv.isAarch64;
60 checkPhase = "dune runtest";
61
62 meta = with lib; {
63 inherit (src.meta) homepage;
64 description = "Ocaml bindings to Pytorch";
65 maintainers = [ maintainers.bcdarwin ];
66 license = licenses.asl20;
67 };
68}