1{
2 stdenv,
3 lib,
4 fetchurl,
5 makeWrapper,
6 getconf,
7 ocaml,
8 unzip,
9 ncurses,
10 curl,
11 bubblewrap,
12}:
13
14assert lib.versionAtLeast ocaml.version "4.08.0";
15
16stdenv.mkDerivation (finalAttrs: {
17 pname = "opam";
18 version = "2.3.0";
19
20 src = fetchurl {
21 url = "https://github.com/ocaml/opam/releases/download/${finalAttrs.version}/opam-full-${finalAttrs.version}.tar.gz";
22 hash = "sha256-UGunaGXcMVtn35qonnq9XBqJen8KkteyaUl0/cUys0Y=";
23 };
24
25 strictDeps = true;
26
27 nativeBuildInputs = [
28 makeWrapper
29 unzip
30 ocaml
31 curl
32 ];
33 buildInputs = [
34 ncurses
35 getconf
36 ]
37 ++ lib.optionals stdenv.hostPlatform.isLinux [ bubblewrap ];
38
39 patches = [ ./opam-shebangs.patch ];
40
41 preConfigure = ''
42 # Fix opam sandboxing on nixos. Remove after opam >= 2.4.0 is released
43 substituteInPlace src/state/shellscripts/bwrap.sh \
44 --replace-fail 'for dir in /*; do' 'for dir in /{*,run/current-system/sw}; do'
45 '';
46
47 configureFlags = [
48 "--with-vendored-deps"
49 "--with-mccs"
50 ];
51
52 outputs = [
53 "out"
54 "installer"
55 ];
56 setOutputFlags = false;
57
58 postInstall = ''
59 wrapProgram $out/bin/opam \
60 --suffix PATH : ${
61 lib.makeBinPath (
62 [
63 curl
64 getconf
65 unzip
66 ]
67 ++ lib.optionals stdenv.hostPlatform.isLinux [ bubblewrap ]
68 )
69 }
70 $out/bin/opam-installer --prefix=$installer opam-installer.install
71 '';
72
73 doCheck = false;
74
75 meta = {
76 description = "Package manager for OCaml";
77 homepage = "https://opam.ocaml.org/";
78 changelog = "https://github.com/ocaml/opam/raw/${finalAttrs.version}/CHANGES";
79 maintainers = [ ];
80 license = lib.licenses.lgpl21Only;
81 platforms = lib.platforms.all;
82 };
83})