push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
{
lib,
stdenv,
fetchFromGitHub,
ocaml,
writeText,
}:
lib.throwIfNot (lib.versionAtLeast ocaml.version "4.03")
"camlidl is not available for OCaml ${ocaml.version}"
stdenv.mkDerivation
rec {
pname = "ocaml${ocaml.version}-camlidl";
version = "1.12";
src = fetchFromGitHub {
owner = "xavierleroy";
repo = "camlidl";
rev = "camlidl112";
hash = "sha256-ONPQMDFaU2OzFa5jgMVKx+ZRKk8ZgBZyk42vDvbM7E0=";
};
nativeBuildInputs = [ ocaml ];
# build fails otherwise
enableParallelBuilding = false;
preBuild = ''
mv config/Makefile.unix config/Makefile
substituteInPlace config/Makefile --replace BINDIR=/usr/local/bin BINDIR=$out
substituteInPlace config/Makefile --replace 'OCAMLLIB=$(shell $(OCAMLC) -where)' OCAMLLIB=$out/lib/ocaml/${ocaml.version}/site-lib/camlidl
substituteInPlace config/Makefile --replace CPP=cpp CPP=${stdenv.cc}/bin/cpp
substituteInPlace lib/Makefile --replace '$(OCAMLLIB)/Makefile.config' "${ocaml}/lib/ocaml/Makefile.config"
mkdir -p $out/lib/ocaml/${ocaml.version}/site-lib/camlidl/caml
mkdir -p $out/lib/ocaml/${ocaml.version}/site-lib/camlidl/stublibs
'';
postInstall = ''
cat >$out/lib/ocaml/${ocaml.version}/site-lib/camlidl/META <<EOF
# Courtesy of GODI
description = "Stub generator"
version = "${version}"
archive(byte) = "com.cma"
archive(native) = "com.cmxa"
EOF
mkdir -p $out/bin
ln -s $out/camlidl $out/bin
'';
setupHook = writeText "setupHook.sh" ''
export NIX_CFLAGS_COMPILE+=" -isystem $1/lib/ocaml/${ocaml.version}/site-lib/camlidl"
export NIX_LDFLAGS+=" -L $1/lib/ocaml/${ocaml.version}/site-lib/camlidl"
'';
meta = {
description = "Stub code generator and COM binding for Objective Caml";
mainProgram = "camlidl";
homepage = "https://xavierleroy.org/camlidl/";
license = lib.licenses.lgpl21;
maintainers = [ lib.maintainers.roconnor ];
};
}

View File

@@ -0,0 +1,153 @@
{
lib,
stdenv,
fetchzip,
which,
ocaml,
camlp-streams,
ocamlbuild,
findlib,
}:
if lib.versionAtLeast ocaml.version "5.4" then
throw "camlp4 is not available for OCaml ${ocaml.version}"
else
let
param =
{
"4.02" = {
version = "4.02+6";
sha256 = "06yl4q0qazl7g25b0axd1gdkfd4qpqzs1gr5fkvmkrcbz113h1hj";
};
"4.03" = {
version = "4.03+1";
sha256 = "1f2ndch6f1m4fgnxsjb94qbpwjnjgdlya6pard44y6n0dqxi1wsq";
};
"4.04" = {
version = "4.04+1";
sha256 = "1ad7rygqjxrc1im95gw9lp8q83nhdaf383f2808f1p63yl42xm7k";
};
"4.05" = {
version = "4.05+1";
sha256 = "0wm795hpwvwpib9c9z6p8kw2fh7p7b2hml6g15z8zry3y7w738sv";
};
"4.06" = {
version = "4.06+1";
sha256 = "0fazfw2l7wdmbwnqc22xby5n4ri1wz27lw9pfzhsbcdrighykysf";
};
"4.07" = {
version = "4.07+1";
sha256 = "0cxl4hkqcvspvkx4f2k83217rh6051fll9i2yz7cw6m3bq57mdvl";
};
"4.08" = {
version = "4.08+1";
sha256 = "0qplawvxwai25bi27niw2cgz2al01kcnkj8wxwhxslpi21z6pyx1";
};
"4.09" = {
version = "4.09+1";
sha256 = "1gr33x6xs1rs0bpyq4vzyfxd6vn47jfkg8imi81db2r0cbs0kxx1";
};
"4.10" = {
version = "4.10+1";
sha256 = "093bc1c28wid5li0jwglnd4p3csxw09fmbs9ffybq2z41a5mgay6";
};
"4.11" = {
version = "4.11+1";
sha256 = "0sn7f6im940qh0ixmx1k738xrwwdvy9g7r19bv5218jb6mh0g068";
};
"4.12" = {
version = "4.12+1";
sha256 = "1cfk5ppnd511vzsr9gc0grxbafmh0m3m897aij198rppzxps5kyz";
};
"4.13" = {
version = "4.13+1";
sha256 = "0fzxa1zdhk74mlxpin7p90flks6sp4gkc0mfclmj9zak15rii55n";
};
"4.14" = {
version = "4.14+1";
sha256 = "sha256-cPN3GioZT/Zt6uzbjGUPEGVJcPQdsAnCkU/AQoPfvuo=";
};
"5.0" = {
version = "5.0";
sha256 = "sha256-oZptFNPUEAq5YlcqAoDWfLghGMF9AN7E7hUN55SAX+4=";
};
"5.1" = {
version = "5.1";
sha256 = "sha256-Ubedjg3BeHA0bJbEalQN9eEk5+LRAI/er+8mWfVYchg=";
};
"5.2" = {
version = "5.2";
sha256 = "sha256-lzbc9xsgeYlbVf71O+PWYS14QivAH1aPdnvWhe0HHME=";
};
"5.3" = {
version = "5.3";
sha256 = "sha256-V/kKhTP9U4jWDFuQKuB7BS3XICg1lq/2Avj7UJR55+k=";
};
}
.${ocaml.meta.branch};
in
stdenv.mkDerivation rec {
pname = "camlp4";
inherit (param) version;
src = fetchzip {
url = "https://github.com/ocaml/camlp4/archive/${version}.tar.gz";
inherit (param) sha256;
};
strictDeps = true;
nativeBuildInputs = [
which
ocaml
ocamlbuild
]
++ lib.optionals (lib.versionAtLeast ocaml.version "5.0") [
findlib
];
buildInputs = lib.optionals (lib.versionAtLeast ocaml.version "5.0") [
camlp-streams
ocamlbuild
];
# build fails otherwise
enableParallelBuilding = false;
dontAddPrefix = true;
preConfigure = ''
# increase stack space for spacetime variant of the compiler
# https://github.com/ocaml/ocaml/issues/7435
# but disallowed by darwin sandbox
ulimit -s unlimited || true
configureFlagsArray=(
--bindir=$out/bin
--libdir=$out/lib/ocaml/${ocaml.version}/site-lib
--pkgdir=$out/lib/ocaml/${ocaml.version}/site-lib
)
'';
postConfigure = ''
substituteInPlace camlp4/META.in \
--replace +camlp4 $out/lib/ocaml/${ocaml.version}/site-lib/camlp4
'';
makeFlags = [ "all" ];
installTargets = [
"install"
"install-META"
];
dontStrip = true;
meta = {
description = "Software system for writing extensible parsers for programming languages";
homepage = "https://github.com/ocaml/camlp4";
platforms = ocaml.meta.platforms or [ ];
};
}

View File

@@ -0,0 +1,106 @@
{
lib,
stdenv,
fetchFromGitHub,
ocaml,
findlib,
perl,
makeWrapper,
rresult,
bos,
pcre2,
re,
camlp-streams,
legacy ? false,
}:
if lib.versionOlder ocaml.version "4.02" then
throw "camlp5 is not available for OCaml ${ocaml.version}"
else
let
params =
if lib.versionAtLeast ocaml.version "4.12" && !legacy then
rec {
version = "8.03.02";
src = fetchFromGitHub {
owner = "camlp5";
repo = "camlp5";
rev = version;
hash = "sha256-nz+VfGR/6FdBvMzPPpVpviAXXBWNqM3Ora96Yzx964o=";
};
nativeBuildInputs = [
makeWrapper
ocaml
findlib
perl
];
buildInputs = [
bos
pcre2
re
rresult
];
propagatedBuildInputs = [ camlp-streams ];
postInstall = ''
for prog in camlp5 camlp5o camlp5r camlp5sch mkcamlp5 ocpp5
do
wrapProgram $out/bin/$prog \
--prefix CAML_LD_LIBRARY_PATH : "$CAML_LD_LIBRARY_PATH"
done
'';
}
else
rec {
version = "7.14";
src = fetchFromGitHub {
owner = "camlp5";
repo = "camlp5";
rev = "rel${builtins.replaceStrings [ "." ] [ "" ] version}";
sha256 = "1dd68bisbpqn5lq2pslm582hxglcxnbkgfkwhdz67z4w9d5nvr7w";
};
nativeBuildInputs = [
ocaml
perl
];
};
in
stdenv.mkDerivation (
params
// {
pname = "ocaml${ocaml.version}-camlp5";
strictDeps = true;
prefixKey = "-prefix ";
preConfigure = ''
configureFlagsArray=(--strict --libdir $out/lib/ocaml/${ocaml.version}/site-lib)
patchShebangs ./config/find_stuffversion.pl etc/META.pl
'';
buildFlags = [ "world.opt" ];
dontStrip = true;
meta = with lib; {
description = "Preprocessor-pretty-printer for OCaml";
longDescription = ''
Camlp5 is a preprocessor and pretty-printer for OCaml programs.
It also provides parsing and printing tools.
'';
homepage = "https://camlp5.github.io/";
license = licenses.bsd3;
platforms = ocaml.meta.platforms or [ ];
maintainers = with maintainers; [
maggesi
vbgl
];
};
}
)

View File

@@ -0,0 +1,80 @@
{
lib,
stdenv,
fetchFromGitHub,
ocaml,
findlib,
ocamlbuild,
buildDunePackage,
}:
let
pname = "cppo";
meta = with lib; {
description = "C preprocessor for OCaml";
mainProgram = "cppo";
longDescription = ''
Cppo is an equivalent of the C preprocessor targeted at the OCaml language and its variants.
'';
homepage = "https://github.com/ocaml-community/${pname}";
maintainers = [ maintainers.vbgl ];
license = licenses.bsd3;
};
in
if lib.versionAtLeast ocaml.version "4.02" then
buildDunePackage rec {
inherit pname;
version = "1.8.0";
src = fetchFromGitHub {
owner = "ocaml-community";
repo = pname;
rev = "v${version}";
hash = "sha256-+HnAGM+GddYJK0RCvKrs+baZS+1o8Yq+/cVa3U3nFWg=";
};
doCheck = true;
inherit meta;
}
else
let
version = "1.5.0";
in
stdenv.mkDerivation {
name = "${pname}-${version}";
src = fetchFromGitHub {
owner = "mjambon";
repo = pname;
rev = "v${version}";
sha256 = "1xqldjz9risndnabvadw41fdbi5sa2hl4fnqls7j9xfbby1izbg8";
};
strictDeps = true;
nativeBuildInputs = [
ocaml
findlib
ocamlbuild
];
inherit meta;
createFindlibDestdir = true;
makeFlags = [ "PREFIX=$(out)" ];
preBuild = ''
mkdir -p $out/bin
'';
}

View File

@@ -0,0 +1,25 @@
{
lib,
buildDunePackage,
cppo,
ocamlbuild,
}:
if lib.versionOlder (lib.getVersion cppo) "1.6" then
cppo
else
buildDunePackage {
pname = "cppo_ocamlbuild";
inherit (cppo) version src;
minimalOCamlVersion = "4.03";
duneVersion = "3";
propagatedBuildInputs = [ ocamlbuild ];
meta = cppo.meta // {
description = "Plugin to use cppo with ocamlbuild";
};
}

View File

@@ -0,0 +1,44 @@
{
lib,
buildDunePackage,
fetchurl,
ocaml,
cmdliner,
ptime,
}:
buildDunePackage rec {
pname = "crunch";
version = "4.0.0";
minimalOCamlVersion = "4.08";
src = fetchurl {
url = "https://github.com/mirage/ocaml-crunch/releases/download/v${version}/crunch-${version}.tbz";
sha256 = "sha256-k5uNESntbGNMsPnMxvbUSqFwPNBc5gkfLuKgFilEuJs=";
};
buildInputs = [ cmdliner ];
propagatedBuildInputs = [ ptime ];
outputs = [
"lib"
"bin"
"out"
];
installPhase = ''
dune install --prefix=$bin --libdir=$lib/lib/ocaml/${ocaml.version}/site-lib/
'';
meta = {
homepage = "https://github.com/mirage/ocaml-crunch";
description = "Convert a filesystem into a static OCaml module";
mainProgram = "ocaml-crunch";
license = lib.licenses.isc;
maintainers = [ lib.maintainers.vbgl ];
};
}

View File

@@ -0,0 +1,105 @@
{
lib,
buildDunePackage,
fetchurl,
makeWrapper,
curly,
fmt,
bos,
cmdliner,
re,
rresult,
logs,
fpath,
odoc,
opam-format,
opam-core,
opam-state,
yojson,
astring,
opam,
gitMinimal,
findlib,
mercurial,
bzip2,
gnutar,
coreutils,
alcotest,
}:
# don't include dune as runtime dep, so user can
# choose between dune and dune_2
let
runtimeInputs = [
opam
findlib
gitMinimal
mercurial
bzip2
gnutar
coreutils
];
in
buildDunePackage rec {
pname = "dune-release";
version = "2.1.0";
src = fetchurl {
url = "https://github.com/ocamllabs/${pname}/releases/download/${version}/${pname}-${version}.tbz";
hash = "sha256-bhDf/zb6mnSB53ibb1yb8Yf1TTmVEu8rb8KUnJieCnY=";
};
nativeBuildInputs = [ makeWrapper ] ++ runtimeInputs;
buildInputs = [
curly
fmt
cmdliner
re
opam-format
opam-state
opam-core
rresult
logs
odoc
bos
yojson
astring
fpath
];
nativeCheckInputs = [
odoc
gitMinimal
];
checkInputs = [ alcotest ] ++ runtimeInputs;
doCheck = true;
postPatch = ''
# remove check for curl in PATH, since curly is patched
# to have a fixed path to the binary in nix store
sed -i '/must_exist (Cmd\.v "curl"/d' lib/github.ml
'';
preCheck = ''
export HOME=$TMPDIR
git config --global user.email "nix-builder@nixos.org"
git config --global user.name "Nix Builder"
# it fails when it tries to reference "./make_check_deterministic.exe"
rm -r tests/bin/check
'';
# tool specific env vars have been deprecated, use PATH
preFixup = ''
wrapProgram $out/bin/dune-release \
--prefix PATH : "${lib.makeBinPath runtimeInputs}"
'';
meta = with lib; {
description = "Release dune packages in opam";
mainProgram = "dune-release";
homepage = "https://github.com/ocamllabs/dune-release";
changelog = "https://github.com/tarides/dune-release/blob/${version}/CHANGES.md";
license = licenses.isc;
maintainers = with maintainers; [ sternenseemann ];
};
}

View File

@@ -0,0 +1,46 @@
{
stdenv,
lib,
fetchurl,
ocaml,
findlib,
ncurses,
}:
if lib.versionOlder ocaml.version "4.02" || lib.versionAtLeast ocaml.version "4.12" then
throw "dune 1 is not available for OCaml ${ocaml.version}"
else
stdenv.mkDerivation rec {
pname = "dune";
version = "1.11.4";
src = fetchurl {
url = "https://github.com/ocaml/dune/releases/download/${version}/dune-build-info-${version}.tbz";
sha256 = "1rkc8lqw30ifjaz8d81la6i8j05ffd0whpxqsbg6dci16945zjvp";
};
nativeBuildInputs = [
ocaml
findlib
];
buildInputs = [ ncurses ];
strictDeps = true;
buildFlags = [ "release" ];
makeFlags = [
"PREFIX=${placeholder "out"}"
"LIBDIR=$(OCAMLFIND_DESTDIR)"
];
dontAddPrefix = true;
dontAddStaticConfigureFlags = true;
configurePlatforms = [ ];
meta = with lib; {
homepage = "https://dune.build/";
description = "Composable build system";
maintainers = [ maintainers.vbgl ];
license = licenses.mit;
inherit (ocaml.meta) platforms;
};
}

View File

@@ -0,0 +1,48 @@
{
lib,
stdenv,
fetchurl,
ocaml,
findlib,
}:
if lib.versionOlder ocaml.version "4.08" then
throw "dune 2 is not available for OCaml ${ocaml.version}"
else
stdenv.mkDerivation rec {
pname = "dune";
version = "2.9.3";
src = fetchurl {
url = "https://github.com/ocaml/dune/releases/download/${version}/dune-site-${version}.tbz";
sha256 = "sha256:1ml8bxym8sdfz25bx947al7cvsi2zg5lcv7x9w6xb01cmdryqr9y";
};
nativeBuildInputs = [
ocaml
findlib
];
strictDeps = true;
buildFlags = [ "release" ];
dontAddPrefix = true;
dontAddStaticConfigureFlags = true;
configurePlatforms = [ ];
installFlags = [
"PREFIX=${placeholder "out"}"
"LIBDIR=$(OCAMLFIND_DESTDIR)"
];
meta = {
homepage = "https://dune.build/";
description = "Composable build system";
mainProgram = "dune";
changelog = "https://github.com/ocaml/dune/raw/${version}/CHANGES.md";
maintainers = [ lib.maintainers.vbgl ];
license = lib.licenses.mit;
inherit (ocaml.meta) platforms;
};
}

View File

@@ -0,0 +1,55 @@
{
lib,
stdenv,
fetchurl,
ocaml,
findlib,
ocaml-lsp,
dune-release,
}:
if lib.versionOlder ocaml.version "4.08" then
throw "dune 3 is not available for OCaml ${ocaml.version}"
else
stdenv.mkDerivation rec {
pname = "dune";
version = "3.20.2";
src = fetchurl {
url = "https://github.com/ocaml/dune/releases/download/${version}/dune-${version}.tbz";
hash = "sha256-sahrLWC9tKi5u2hhvfL58opufLXYM86Br+zOue+cpUk=";
};
nativeBuildInputs = [
ocaml
findlib
];
strictDeps = true;
buildFlags = [ "release" ];
dontAddPrefix = true;
dontAddStaticConfigureFlags = true;
configurePlatforms = [ ];
installFlags = [
"PREFIX=${placeholder "out"}"
"LIBDIR=$(OCAMLFIND_DESTDIR)"
];
passthru.tests = {
inherit ocaml-lsp dune-release;
};
meta = {
homepage = "https://dune.build/";
description = "Composable build system";
mainProgram = "dune";
changelog = "https://github.com/ocaml/dune/raw/${version}/CHANGES.md";
maintainers = [ lib.maintainers.vbgl ];
license = lib.licenses.mit;
inherit (ocaml.meta) platforms;
};
}

View File

@@ -0,0 +1,100 @@
{
lib,
stdenv,
fetchurl,
ncurses,
ocaml,
writeText,
}:
stdenv.mkDerivation rec {
pname = "ocaml${ocaml.version}-findlib";
version = "1.9.8";
src = fetchurl {
url = "http://download.camlcity.org/download/findlib-${version}.tar.gz";
hash = "sha256-ZiyRD3dOn+46GcTgV/OAWBqy/E7lLaR2EwSsnDG4hp0=";
};
nativeBuildInputs = [ ocaml ];
buildInputs = lib.optional (lib.versionOlder ocaml.version "4.07") ncurses;
patches = [
./ldconf.patch
./install_topfind.patch
];
dontAddPrefix = true;
dontAddStaticConfigureFlags = true;
configurePlatforms = [ ];
configureFlags = [
"-bindir"
"${placeholder "out"}/bin"
"-mandir"
"${placeholder "out"}/share/man"
"-sitelib"
"${placeholder "out"}/lib/ocaml/${ocaml.version}/site-lib"
"-config"
"${placeholder "out"}/etc/findlib.conf"
];
buildFlags = [
"all"
]
++ lib.optionals ocaml.nativeCompilers [
"opt"
];
setupHook = writeText "setupHook.sh" ''
addOCamlPath () {
if test -d "''$1/lib/ocaml/${ocaml.version}/site-lib"; then
export OCAMLPATH="''${OCAMLPATH-}''${OCAMLPATH:+:}''$1/lib/ocaml/${ocaml.version}/site-lib/"
fi
if test -d "''$1/lib/ocaml/${ocaml.version}/site-lib/stublibs"; then
export CAML_LD_LIBRARY_PATH="''${CAML_LD_LIBRARY_PATH-}''${CAML_LD_LIBRARY_PATH:+:}''$1/lib/ocaml/${ocaml.version}/site-lib/stublibs"
fi
}
exportOcamlDestDir () {
export OCAMLFIND_DESTDIR="''$out/lib/ocaml/${ocaml.version}/site-lib/"
}
createOcamlDestDir () {
if test -n "''${createFindlibDestdir-}"; then
mkdir -p $OCAMLFIND_DESTDIR
fi
}
detectOcamlConflicts () {
local conflict
conflict="$(ocamlfind list |& grep "has multiple definitions" || true)"
if [[ -n "$conflict" ]]; then
echo "Conflicting ocaml packages detected";
echo "$conflict"
echo "Set dontDetectOcamlConflicts to true to disable this check."
exit 1
fi
}
# run for every buildInput
addEnvHooks "$targetOffset" addOCamlPath
# run before installPhase, even without buildInputs, and not in nix-shell
preInstallHooks+=(createOcamlDestDir)
# run even in nix-shell, and even without buildInputs
addEnvHooks "$hostOffset" exportOcamlDestDir
# runs after all calls to addOCamlPath
if [[ -z "''${dontDetectOcamlConflicts-}" ]]; then
postHooks+=("detectOcamlConflicts")
fi
'';
meta = {
description = "O'Caml library manager";
homepage = "http://projects.camlcity.org/projects/findlib.html";
license = lib.licenses.mit;
maintainers = with lib.maintainers; [
maggesi
vbmithr
];
mainProgram = "ocamlfind";
platforms = ocaml.meta.platforms or [ ];
};
}

View File

@@ -0,0 +1,13 @@
--- a/src/findlib/Makefile
+++ b/src/findlib/Makefile
@@ -134,8 +134,8 @@
install: all
$(INSTALLDIR) "$(DESTDIR)$(prefix)$(OCAML_SITELIB)/$(NAME)"
$(INSTALLDIR) "$(DESTDIR)$(prefix)$(OCAMLFIND_BIN)"
- test $(INSTALL_TOPFIND) -eq 0 || $(INSTALLDIR) "$(DESTDIR)$(prefix)$(OCAML_CORE_STDLIB)"
- test $(INSTALL_TOPFIND) -eq 0 || $(CP) topfind "$(DESTDIR)$(prefix)$(OCAML_CORE_STDLIB)/"
+ test $(INSTALL_TOPFIND) -eq 0 || $(INSTALLDIR) "$(DESTDIR)$(prefix)$(OCAML_SITELIB)"
+ test $(INSTALL_TOPFIND) -eq 0 || $(CP) topfind "$(DESTDIR)$(prefix)$(OCAML_SITELIB)/"
files=`$(SH) $(TOP)/tools/collect_files $(TOP)/Makefile.config \
findlib.cmi findlib.mli findlib.cma findlib.cmxa findlib$(LIB_SUFFIX) findlib.cmxs \
findlib_config.cmi findlib_config.ml topfind.cmi topfind.mli \

View File

@@ -0,0 +1,8 @@
Setting paths to search for dnynmic libraries isn't very useful in Nix.
--- findlib-1.2.6/findlib.conf.in 2010-08-17 14:50:28.000000000 -0400
+++ findlib-1.2.6/findlib.conf.in 2010-11-24 09:46:55.179648354 -0500
@@ -1,2 +1,3 @@
destdir="@SITELIB@"
path="@SITELIB@"
+ldconf="ignore"

View File

@@ -0,0 +1,41 @@
{
lib,
buildDunePackage,
binaryen,
cmdliner,
js_of_ocaml-compiler,
menhir,
menhirLib,
ppxlib,
sedlex,
yojson,
}:
buildDunePackage {
pname = "wasm_of_ocaml-compiler";
inherit (js_of_ocaml-compiler) version src;
minimalOCamlVersion = "4.12";
nativeBuildInputs = [
binaryen
menhir
];
buildInputs = [
cmdliner
ppxlib
];
propagatedBuildInputs = [
js_of_ocaml-compiler
menhirLib
sedlex
yojson
];
meta = js_of_ocaml-compiler.meta // {
description = "Compiler from OCaml bytecode to WebAssembly";
mainProgram = "wasm_of_ocaml";
maintainers = [ lib.maintainers.stepbrobd ];
};
}

View File

@@ -0,0 +1,60 @@
{
lib,
fetchurl,
ocaml,
buildDunePackage,
cmdliner,
yojson,
ppxlib,
findlib,
menhir,
menhirLib,
sedlex,
version ?
if lib.versionAtLeast ocaml.version "4.13" then
"6.2.0"
else if lib.versionAtLeast ocaml.version "4.11" then
"6.0.1"
else
"5.8.2",
}:
buildDunePackage {
pname = "js_of_ocaml-compiler";
inherit version;
minimalOCamlVersion = "4.08";
src = fetchurl {
url = "https://github.com/ocsigen/js_of_ocaml/releases/download/${version}/js_of_ocaml-${version}.tbz";
hash =
{
"6.2.0" = "sha256-fMZBd40bFyo1KogzPuDoxiE2WgrPzZuH44v9243Spdo=";
"6.1.1" = "sha256-0x2kGq5hwCqqi01QTk6TcFIz0wPNgaB7tKxe7bA9YBQ=";
"6.0.1" = "sha256-gT2+4rYuFUEEnqI6IOQFzyROJ+v6mFl4XPpT4obSxhQ=";
"5.9.1" = "sha256-aMlcYIcdjpyaVMgvNeLtUEE7y0QPIg0LNRayoe4ccwc=";
"5.8.2" = "sha256-ciAZS9L5sU2VgVOlogZ1A1nXtJ3hL+iNdFDThc7L8Eo=";
}
."${version}";
};
nativeBuildInputs = [ menhir ];
buildInputs = [
cmdliner
ppxlib
];
propagatedBuildInputs = [
menhirLib
yojson
findlib
sedlex
];
meta = {
description = "Compiler from OCaml bytecode to Javascript";
homepage = "https://ocsigen.org/js_of_ocaml/";
license = lib.licenses.gpl2;
maintainers = [ lib.maintainers.vbgl ];
mainProgram = "js_of_ocaml";
};
}

View File

@@ -0,0 +1,17 @@
{
buildDunePackage,
js_of_ocaml-compiler,
ppxlib,
}:
buildDunePackage {
pname = "js_of_ocaml";
inherit (js_of_ocaml-compiler) version src;
buildInputs = [ ppxlib ];
propagatedBuildInputs = [ js_of_ocaml-compiler ];
meta = removeAttrs js_of_ocaml-compiler.meta [ "mainProgram" ];
}

View File

@@ -0,0 +1,21 @@
{
buildDunePackage,
js_of_ocaml-ppx,
js_of_ocaml,
lwt,
lwt_log,
}:
buildDunePackage {
pname = "js_of_ocaml-lwt";
inherit (js_of_ocaml) version src meta;
buildInputs = [ js_of_ocaml-ppx ];
propagatedBuildInputs = [
js_of_ocaml
lwt
lwt_log
];
}

View File

@@ -0,0 +1,27 @@
{
lib,
buildDunePackage,
fetchurl,
ocamlbuild,
}:
buildDunePackage rec {
pname = "js_of_ocaml-ocamlbuild";
version = "5.0";
minimalOCamlVersion = "4.03";
src = fetchurl {
url = "https://github.com/ocsigen/js_of_ocaml-ocamlbuild/releases/download/${version}/js_of_ocaml-ocamlbuild-${version}.tbz";
sha256 = "sha256-qlm8vxzie8sqPrd6iiwf8X6d2+DyQOOhmMoc67ChwHs=";
};
propagatedBuildInputs = [ ocamlbuild ];
meta = {
description = "Ocamlbuild plugin to compile to JavaScript";
homepage = "https://github.com/ocsigen/js_of_ocaml-ocamlbuild";
license = lib.licenses.lgpl2Only;
maintainers = [ lib.maintainers.vbgl ];
};
}

View File

@@ -0,0 +1,14 @@
{
buildDunePackage,
js_of_ocaml,
ppxlib,
}:
buildDunePackage {
pname = "js_of_ocaml-ppx";
inherit (js_of_ocaml) version src meta;
buildInputs = [ js_of_ocaml ];
propagatedBuildInputs = [ ppxlib ];
}

View File

@@ -0,0 +1,16 @@
{
buildDunePackage,
js_of_ocaml,
ppxlib,
}:
buildDunePackage {
pname = "js_of_ocaml-ppx_deriving_json";
inherit (js_of_ocaml) version src meta;
propagatedBuildInputs = [
js_of_ocaml
ppxlib
];
}

View File

@@ -0,0 +1,15 @@
{
buildDunePackage,
js_of_ocaml-compiler,
ppxlib,
}:
buildDunePackage {
pname = "js_of_ocaml-toplevel";
inherit (js_of_ocaml-compiler) src version;
buildInputs = [ ppxlib ];
propagatedBuildInputs = [ js_of_ocaml-compiler ];
meta = js_of_ocaml-compiler.meta // {
mainProgram = "jsoo_mktop";
};
}

View File

@@ -0,0 +1,21 @@
{
buildDunePackage,
js_of_ocaml-ppx,
js_of_ocaml,
reactivedata,
tyxml,
}:
buildDunePackage {
pname = "js_of_ocaml-tyxml";
inherit (js_of_ocaml) version src meta;
buildInputs = [ js_of_ocaml-ppx ];
propagatedBuildInputs = [
js_of_ocaml
reactivedata
tyxml
];
}

View File

@@ -0,0 +1,101 @@
{
buildDunePackage,
cmdliner,
cppo,
dune-build-info,
fetchurl,
fetchpatch,
jq,
lib,
makeWrapper,
menhirLib,
merlin,
nodejs,
ocaml,
ounit2,
ppxlib,
reason,
stdenv,
tree,
}:
let
pname = "melange";
versionHash =
if lib.versionAtLeast ocaml.version "5.3" then
{
version = "5.1.0-53";
hash = "sha256-96rDDzul/v+Dc+IWTNtbOKWUV8rf7HS1ZMK2LQNcpKk=";
}
else if lib.versionAtLeast ocaml.version "5.2" then
{
version = "5.1.0-52";
hash = "sha256-EGIInGCo3JADYyE4mLw5Fzkm4OB+V9yi2ayV0lVq3v0=";
}
else if lib.versionAtLeast ocaml.version "5.1" then
{
version = "5.1.0-51";
hash = "sha256-DIF8vZLEKsFf6m5tl1/T6zqjHyKxDMois2h//tDhsJI=";
}
else if lib.versionAtLeast ocaml.version "5.0" then
throw "melange is not available for OCaml ${ocaml.version}"
else
{
version = "5.1.0-414";
hash = "sha256-Sv1XyOqCNhICTsXzetXh/zqX/tdTupYZ0Q1nZRLfpe0=";
};
version = versionHash.version;
hash = versionHash.hash;
in
buildDunePackage {
inherit pname;
inherit version;
minimalOCamlVersion = "4.14";
src = fetchurl {
url = "https://github.com/melange-re/${pname}/releases/download/${version}/${pname}-${version}.tbz";
inherit hash;
};
patches = lib.optional (lib.versionAtLeast ppxlib.version "0.36") (fetchpatch {
url = "https://patch-diff.githubusercontent.com/raw/melange-re/melange/pull/1352.patch";
hash = "sha256-PMf66nB743nzW4/xblHjNZFv1BS8xC9maD+eCDDUWAY=";
excludes = [
"*.opam"
"*.template"
];
});
nativeBuildInputs = [
cppo
makeWrapper
];
buildInputs = [
cmdliner
dune-build-info
];
propagatedBuildInputs = [
menhirLib
ppxlib
];
doCheck = false;
nativeCheckInputs = [
jq
merlin
nodejs
reason
tree
];
checkInputs = [
ounit2
];
postInstall = ''
wrapProgram "$out/bin/melc" --set MELANGELIB "$OCAMLFIND_DESTDIR/melange/melange:$OCAMLFIND_DESTDIR/melange/js/melange"
'';
meta = {
description = "Toolchain to produce JS from Reason/OCaml";
homepage = "https://melange.re/";
mainProgram = "melc";
license = lib.licenses.lgpl3;
maintainers = [
lib.maintainers.vog
];
};
}

View File

@@ -0,0 +1,106 @@
{
lib,
replaceVars,
fetchurl,
ocaml,
dune_3,
buildDunePackage,
yojson,
csexp,
merlin-lib,
dot-merlin-reader,
jq,
menhir,
menhirLib,
menhirSdk,
# Each releases of Merlin support a limited range of versions of OCaml.
version ?
{
"4.12.0" = "4.7-412";
"4.12.1" = "4.7-412";
"4.13.0" = "4.7-413";
"4.13.1" = "4.7-413";
"4.14.0" = "4.19-414";
"4.14.1" = "4.19-414";
"4.14.2" = "4.19-414";
"5.0.0" = "4.14-500";
"5.1.0" = "4.17.1-501";
"5.1.1" = "4.17.1-501";
"5.2.0" = "5.3-502";
"5.2.1" = "5.3-502";
"5.3.0" = "5.6-503";
}
."${ocaml.version}",
}:
let
hashes = {
"4.7-412" = "sha256-0U3Ia7EblKULNy8AuXFVKACZvGN0arYJv7BWiBRgT0Y=";
"4.7-413" = "sha256-aVmGWS4bJBLuwsxDKsng/n0A6qlyJ/pnDTcYab/5gyU=";
"4.14-500" = "sha256-7CPzJPh1UgzYiX8wPMbU5ZXz1wAJFNQQcp8WuGrR1w4=";
"4.16-414" = "sha256-xekZdfPfVoSeGzBvNWwxcJorE519V2NLjSHkcyZvzy0="; # Used by ocaml-lsp
"4.16-501" = "sha256-2lvzCbBAZFwpKuRXLMagpwDb0rz8mWrBPI5cODbCHiY="; # Used by ocaml-lsp
"4.18-414" = "sha256-9tb3omYUHjWMGoaWEsgTXIWRhdVH6julya17tn/jDME=";
"4.19-414" = "sha256-YKYw9ZIDqc5wR6XwTQ8jmUWWDaxvOBApIuMottJlc4Q=";
"4.17.1-501" = "sha256-N2cHqocfCeljlFbT++S4miHJrXXHdOlMu75n+EKwpQA=";
"5.3-502" = "sha256-LOpG8SOX+m4x7wwNT14Rwc/ZFu5JQgaUAFyV67OqJLw=";
"5.4.1-503" = "sha256-SbO0x3jBISX8dAXnN5CwsxLV15dJ3XPUg4tlYqJTMCI=";
"5.6-503" = "sha256-sNytCSqq96I/ZauaCJ6HYb1mXMcjV5CeCsbCGC9PwtQ=";
};
in
buildDunePackage {
pname = "merlin";
inherit version;
src = fetchurl {
url = "https://github.com/ocaml/merlin/releases/download/v${version}/merlin-${version}.tbz";
sha256 = hashes."${version}";
};
patches =
let
old-patch = lib.versionOlder version "4.17";
in
[
(replaceVars (if old-patch then ./fix-paths.patch else ./fix-paths2.patch) {
dot-merlin-reader = "${dot-merlin-reader}/bin/dot-merlin-reader";
dune = "${dune_3}/bin/dune";
})
];
strictDeps = true;
nativeBuildInputs = [
menhir
jq
];
buildInputs = [
dot-merlin-reader
yojson
(if lib.versionAtLeast version "4.7-414" then merlin-lib else csexp)
menhirSdk
menhirLib
];
doCheck = false;
checkPhase = ''
runHook preCheck
patchShebangs tests/merlin-wrapper
dune runtest # filtering with -p disables tests
runHook postCheck
'';
meta = with lib; {
description = "Editor-independent tool to ease the development of programs in OCaml";
homepage = "https://github.com/ocaml/merlin";
license = licenses.mit;
mainProgram = "ocamlmerlin";
maintainers = [
maintainers.vbgl
maintainers.sternenseemann
];
};
}

View File

@@ -0,0 +1,55 @@
{
lib,
fetchurl,
fetchpatch,
buildDunePackage,
replaceVars,
dot-merlin-reader,
dune_2,
yojson,
csexp,
result,
menhirSdk,
}:
buildDunePackage rec {
pname = "merlin";
version = "3.8.0";
src = fetchurl {
url = "https://github.com/ocaml/merlin/releases/download/v${version}/merlin-${version}.tbz";
sha256 = "sha256-wmBGNwXL3BduF4o1sUXtAOUHJ4xmMvsWAxl/QdNj/28=";
};
minimalOCamlVersion = "4.02.3";
patches = [
(replaceVars ./fix-paths.patch {
dot-merlin-reader = "${dot-merlin-reader}/bin/dot-merlin-reader";
dune = "${dune_2}/bin/dune";
})
# https://github.com/ocaml/merlin/pull/1798
(fetchpatch {
name = "vim-python-12-syntax-warning-fix.patch";
url = "https://github.com/ocaml/merlin/commit/9e0c47b0d5fd0c4edc37c4c7ce927b155877557d.patch";
hash = "sha256-HmdTISE/s45C5cwLgsCHNUW6OAPSsvQ/GcJE6VDEobs=";
})
];
strictDeps = true;
buildInputs = [
dot-merlin-reader
yojson
csexp
result
menhirSdk
];
meta = with lib; {
description = "Editor-independent tool to ease the development of programs in OCaml";
homepage = "https://github.com/ocaml/merlin";
license = licenses.mit;
maintainers = [ maintainers.vbgl ];
};
}

View File

@@ -0,0 +1,40 @@
{
lib,
yojson,
csexp,
findlib,
buildDunePackage,
merlin-lib,
merlin,
result,
}:
buildDunePackage rec {
pname = "dot-merlin-reader";
inherit (merlin) version src;
minimalOCamlVersion = "4.06";
buildInputs = [
findlib
]
++ (
if lib.versionAtLeast version "4.7-414" then
[ merlin-lib ]
else
[
yojson
csexp
result
]
);
meta = with lib; {
description = "Reads config files for merlin";
mainProgram = "dot-merlin-reader";
homepage = "https://github.com/ocaml/merlin";
license = licenses.mit;
maintainers = [ maintainers.hongchangwu ];
};
}

View File

@@ -0,0 +1,15 @@
--- a/src/kernel/mconfig_dot.ml
+++ b/src/kernel/mconfig_dot.ml
@@ -126,10 +126,10 @@ module Configurator = struct
let prog, args =
match cfg with
| Dot_merlin ->
- let prog = "dot-merlin-reader" in
+ let prog = "@dot-merlin-reader@" in
prog, [| prog |]
| Dune ->
- let prog = "dune" in
+ let prog = "@dune@" in
prog, [| prog; "ocaml-merlin"; "--no-print-directory" |]
in
log ~title:"get_config" "Using %s configuration provider." (to_string cfg);

View File

@@ -0,0 +1,17 @@
diff --git a/src/kernel/mconfig_dot.ml b/src/kernel/mconfig_dot.ml
index 0a42a1d3..91997190 100644
--- a/src/kernel/mconfig_dot.ml
+++ b/src/kernel/mconfig_dot.ml
@@ -146,10 +146,10 @@ end = struct
let prog, args =
match cfg with
| Dot_merlin ->
- let prog = "dot-merlin-reader" in
+ let prog = "@dot-merlin-reader@" in
(prog, [| prog |])
| Dune ->
- let prog = "dune" in
+ let prog = "@dune@" in
(prog, [| prog; "ocaml-merlin"; "--no-print-directory" |])
in
let cwd = Sys.getcwd () in

View File

@@ -0,0 +1,18 @@
{
buildDunePackage,
merlin,
csexp,
}:
buildDunePackage {
pname = "merlin-lib";
inherit (merlin) version src;
minimalOCamlVersion = "4.14";
propagatedBuildInputs = [ csexp ];
meta = merlin.meta // {
description = "Merlins libraries";
};
}

View File

@@ -0,0 +1,65 @@
{
lib,
stdenv,
fetchurl,
ocaml,
findlib,
ocamlbuild,
ocamlmod,
ocamlify,
}:
lib.throwIf (lib.versionAtLeast ocaml.version "5.0") "oasis is not available for OCaml 5.0"
stdenv.mkDerivation
{
version = "0.4.11";
pname = "ocaml-oasis";
src = fetchurl {
url = "https://download.ocamlcore.org/oasis/oasis/0.4.11/oasis-0.4.11.tar.gz";
hash = "sha256-GLc97vTtbpqDM38ks7vi3tZSaLP/cwn8wA0l5X4dwS4=";
};
createFindlibDestdir = true;
strictDeps = true;
nativeBuildInputs = [
ocaml
findlib
ocamlbuild
ocamlmod
ocamlify
];
buildInputs = [ ocamlbuild ];
configurePhase = ''
runHook preConfigure
ocaml setup.ml -configure --prefix $out
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
ocaml setup.ml -build
runHook postBuild
'';
installPhase = ''
runHook preInstall
ocaml setup.ml -install
runHook postInstall
'';
meta = with lib; {
description = "Configure, build and install system for OCaml projects";
homepage = "https://github.com/ocaml/oasis";
license = licenses.lgpl21;
maintainers = with maintainers; [
vbgl
maggesi
];
mainProgram = "oasis";
inherit (ocaml.meta) platforms;
};
}

View File

@@ -0,0 +1,30 @@
{
lib,
fetchFromGitHub,
ocamlPackages,
menhir,
}:
ocamlPackages.buildDunePackage rec {
pname = "obelisk";
version = "0.8.1";
src = fetchFromGitHub {
owner = "Lelio-Brun";
repo = pname;
rev = "v${version}";
sha256 = "sha256-JJ8k9/6awKZH87T9Ut8x/hlshiUI6sy2fZtY6x2dIIk=";
};
strictDeps = true;
nativeBuildInputs = [ menhir ];
buildInputs = with ocamlPackages; [ re ];
meta = {
description = "Simple tool which produces pretty-printed output from a Menhir parser file (.mly)";
mainProgram = "obelisk";
license = lib.licenses.mit;
maintainers = [ lib.maintainers.vbgl ];
homepage = "https://github.com/Lelio-Brun/Obelisk";
};
}

View File

@@ -0,0 +1,49 @@
{
lib,
fetchFromGitHub,
ocaml,
buildDunePackage,
fix,
menhirLib,
menhirSdk,
gitUpdater,
}:
lib.throwIf (lib.versionAtLeast ocaml.version "5.0")
"ocaml-recovery-parser is not available for OCaml ${ocaml.version}"
buildDunePackage
rec {
pname = "ocaml-recovery-parser";
version = "0.2.4";
minimalOCamlVersion = "4.08";
duneVersion = "3";
src = fetchFromGitHub {
owner = "serokell";
repo = pname;
rev = version;
sha256 = "gOKvjmlcHDOgsTllj2sPL/qNtW/rlNlEVIrosahNsAQ=";
};
propagatedBuildInputs = [
fix
menhirLib
menhirSdk
];
passthru.updateScript = gitUpdater { };
meta = with lib; {
description = "Simple fork of OCaml parser with support for error recovery";
homepage = "https://github.com/serokell/ocaml-recovery-parser";
license = with licenses; [
lgpl2Only
mit
mpl20
];
maintainers = with maintainers; [ romildo ];
mainProgram = "menhir-recover";
};
}

View File

@@ -0,0 +1,57 @@
{
lib,
stdenv,
fetchFromGitHub,
ocaml,
findlib,
version ? if lib.versionAtLeast ocaml.version "4.08" then "0.16.1" else "0.14.3",
}:
stdenv.mkDerivation (finalAttrs: {
pname = "ocaml${ocaml.version}-ocamlbuild";
inherit version;
src = fetchFromGitHub {
owner = "ocaml";
repo = "ocamlbuild";
rev = finalAttrs.version;
hash =
{
"0.14.3" = "sha256-dfcNu4ugOYu/M0rRQla7lXum/g1UzncdLGmpPYo0QUM=";
"0.16.1" = "sha256-RpHVX0o4QduN73j+omlZlycRJaGZWfwHO5kq/WsEGZE=";
}
."${finalAttrs.version}";
};
createFindlibDestdir = true;
nativeBuildInputs = [
ocaml
findlib
];
strictDeps = true;
# x86_64-unknown-linux-musl-ld: -r and -pie may not be used together
hardeningDisable = lib.optional stdenv.hostPlatform.isStatic "pie";
configurePhase = ''
runHook preConfigure
make -f configure.make Makefile.config \
"OCAMLBUILD_PREFIX=$out" \
"OCAMLBUILD_BINDIR=$out/bin" \
"OCAMLBUILD_MANDIR=$out/share/man" \
"OCAMLBUILD_LIBDIR=$OCAMLFIND_DESTDIR"
runHook postConfigure
'';
meta = with lib; {
description = "Build system with builtin rules to easily build most OCaml projects";
homepage = "https://github.com/ocaml/ocamlbuild/";
license = licenses.lgpl2;
maintainers = with maintainers; [ vbgl ];
mainProgram = "ocamlbuild";
inherit (ocaml.meta) platforms;
};
})

View File

@@ -0,0 +1,33 @@
{
lib,
buildDunePackage,
fetchurl,
camlp-streams,
}:
buildDunePackage (finalAttrs: {
pname = "ocamlify";
version = "0.1.0";
src = fetchurl {
url = "https://github.com/gildor478/ocamlify/releases/download/v${finalAttrs.version}/ocamlify-${finalAttrs.version}.tbz";
hash = "sha256-u0pGiwLR/5N0eRv+eSkdR71snyiSDPwh8JwuxbcXIGA=";
};
propagatedBuildInputs = [
camlp-streams
];
doCheck = true;
dontStrip = true;
meta = {
homepage = "https://github.com/gildor478/ocamlify";
description = "Include files in OCaml code";
license = lib.licenses.lgpl21;
maintainers = with lib.maintainers; [
maggesi
];
mainProgram = "ocamlify";
};
})

View File

@@ -0,0 +1,33 @@
{
lib,
ocaml,
buildDunePackage,
fetchurl,
ounit2,
}:
buildDunePackage (finalAttrs: {
pname = "ocamlmod";
version = "0.1.1";
minimalOCamlVersion = "4.03";
src = fetchurl {
url = "https://github.com/gildor478/ocamlmod/releases/download/v${finalAttrs.version}/ocamlmod-${finalAttrs.version}.tbz";
hash = "sha256-qMG+y/iS+L4qtKiJX01pTTAdQuGLoIA+so1fqY9bm8o=";
};
doCheck = lib.versionAtLeast ocaml.version "4.08";
checkInputs = [ ounit2 ];
dontStrip = true;
meta = {
homepage = "https://github.com/gildor478/ocamlmod";
description = "Generate OCaml modules from source files";
maintainers = with lib.maintainers; [
maggesi
];
mainProgram = "ocamlmod";
};
})

View File

@@ -0,0 +1,67 @@
diff --git a/Makefile b/Makefile
index 894e94d..9adc44b 100644
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,7 @@ ifndef BINDIR
endif
export BINDIR
-PACKS = unix str
+PACKS = unix str findlib
# PP = camlp4o -I . -parser pa_opt.cmo
# export PP
diff --git a/main.ml b/main.ml
index 288526a..b67c5e9 100644
--- a/main.ml
+++ b/main.ml
@@ -247,6 +247,11 @@ let write_header ~pos ~source ~source_option ~verbose ~prog_file lines =
Sys.getcwd ())
| `File script_name -> "", get_dir script_name in
+ let findlibdir =
+ Filename.(
+ concat (Findlib.package_directory "findlib") parent_dir_name
+ ) in
+
let file, oc = Filename.open_temp_file "meta" ".ml" in
fprintf oc "\
#%i %S;;
@@ -255,6 +260,7 @@ let () =
try Topdirs.dir_directory (Sys.getenv \"OCAML_TOPLEVEL_PATH\")
with Not_found -> ()
;;
+#directory \"%s\";;
#use \"topfind\";;
#require \"ocamlscript\";;
Ocamlscript.Common.verbose := %s;;
@@ -263,7 +269,7 @@ Ocamlscript.Common.script_dir := %S;;
open Ocamlscript;;
open Utils;;
#%i %S;;\n"
- pos source verbose script_dir extra_args trash pos source;
+ pos source findlibdir verbose script_dir extra_args trash pos source;
List.iter (output_line oc) lines;
@@ -550,6 +556,7 @@ let main () =
exit compilation_status
let _ =
+ Findlib.init ();
try main ()
with Failure s ->
eprintf "ocamlscript: %s\n%!" s;
diff --git a/ocaml.ml b/ocaml.ml
index a1824c6..b8f287e 100644
--- a/ocaml.ml
+++ b/ocaml.ml
@@ -14,7 +14,7 @@ let ocamlfind = ref "ocamlfind"
let packs = ref [] (* findlib packages *)
let sources = ref [] (* extra sources *)
let use_ocamllex = ref false (* preprocess with ocamllex before camlp4 *)
-let use_camlp4 = ref true (* by default camlp4 is used *)
+let use_camlp4 = ref false (* by default camlp4 is not used *)
let use_ocamlc = ref false (* by default we want native code *)
let use_ocamlfind = ref false (* used only if necessary *)
let revised = ref false (* use this to use the revised syntax *)

View File

@@ -0,0 +1,44 @@
{
lib,
stdenv,
fetchFromGitHub,
ocaml,
findlib,
}:
lib.throwIfNot (lib.versionAtLeast ocaml.version "4.08")
"ocamlscript is not available for OCaml ${ocaml.version}"
stdenv.mkDerivation
rec {
pname = "ocaml${ocaml.version}-ocamlscript";
version = "3.0.0";
src = fetchFromGitHub {
owner = "mjambon";
repo = "ocamlscript";
rev = "v${version}";
sha256 = "sha256:10xz8jknlmcgnf233nahd04q98ijnxpijhpvb8hl7sv94dgkvpql";
};
nativeBuildInputs = [
ocaml
findlib
];
patches = [ ./Makefile.patch ];
buildFlags = [ "PREFIX=$(out)" ];
installFlags = [ "PREFIX=$(out)" ];
preInstall = "mkdir -p $out/bin";
createFindlibDestdir = true;
meta = with lib; {
inherit (src.meta) homepage;
license = licenses.boost;
inherit (ocaml.meta) platforms;
description = "Natively-compiled OCaml scripts";
maintainers = [ maintainers.vbgl ];
mainProgram = "ocamlscript";
};
}

View File

@@ -0,0 +1,64 @@
{
lib,
stdenv,
fetchFromGitHub,
fetchpatch,
ocaml,
findlib,
ncurses,
cmdliner_1_0,
re,
}:
lib.throwIf (lib.versionAtLeast ocaml.version "5.0")
"ocp-build is not available for OCaml ${ocaml.version}"
stdenv.mkDerivation
rec {
pname = "ocaml${ocaml.version}-ocp-build";
version = "1.99.21";
src = fetchFromGitHub {
owner = "OCamlPro";
repo = "ocp-build";
rev = "v${version}";
sha256 = "1641xzik98c7xnjwxpacijd6d9jzx340fmdn6i372z8h554jjlg9";
};
patches = [
# Fix compilation with OCaml 4.12
(fetchpatch {
url = "https://github.com/OCamlPro/ocp-build/commit/104e4656ca6dba9edb03b62539c9f1e10abcaae8.patch";
sha256 = "0sbyi4acig9q8x1ky4hckfg5pm2nad6zasi51ravaf1spgl148c2";
})
];
strictDeps = true;
nativeBuildInputs = [
ocaml
findlib
];
buildInputs = [
cmdliner_1_0
re
];
propagatedBuildInputs = [ ncurses ];
preInstall = "mkdir -p $out/bin";
meta = with lib; {
description = "Build tool for OCaml";
longDescription = ''
ocp-build is a build system for OCaml application, based on simple
descriptions of packages. ocp-build combines the descriptions of
packages, and optimize the parallel compilation of files depending on
the number of cores and the automatically-inferred dependencies
between source files.
'';
homepage = "https://www.typerex.org/ocp-build.html";
license = licenses.gpl3;
maintainers = [ maintainers.jirkamarsik ];
mainProgram = "ocp-build";
inherit (ocaml.meta) platforms;
};
}

View File

@@ -0,0 +1,32 @@
{
lib,
fetchFromGitHub,
buildDunePackage,
cmdliner,
findlib,
}:
buildDunePackage rec {
version = "1.9.0";
pname = "ocp-indent";
src = fetchFromGitHub {
owner = "OCamlPro";
repo = "ocp-indent";
tag = version;
hash = "sha256-71dbZ8c842MYZfHad6RT0E48JlgzJSHnQgLVA5dGLv8=";
};
minimalOCamlVersion = "4.08";
buildInputs = [ cmdliner ];
propagatedBuildInputs = [ findlib ];
meta = with lib; {
homepage = "https://www.typerex.org/ocp-indent.html";
description = "Customizable tool to indent OCaml code";
mainProgram = "ocp-indent";
license = licenses.gpl3;
maintainers = [ maintainers.jirkamarsik ];
};
}

View File

@@ -0,0 +1,39 @@
{
lib,
fetchFromGitHub,
buildDunePackage,
cppo,
ocp-indent,
cmdliner,
re,
}:
buildDunePackage rec {
pname = "ocp-index";
version = "1.4.0";
minimalOCamlVersion = "4.08";
src = fetchFromGitHub {
owner = "OCamlPro";
repo = "ocp-index";
rev = version;
hash = "sha256-pv6aBJjRkibISpZEnlfyn72smcYEbZoPQoQH2p/JwH0=";
};
nativeBuildInputs = [ cppo ];
buildInputs = [
cmdliner
re
];
propagatedBuildInputs = [ ocp-indent ];
meta = {
homepage = "https://www.typerex.org/ocp-index.html";
description = "Simple and light-weight documentation extractor for OCaml";
changelog = "https://github.com/OCamlPro/ocp-index/raw/${version}/CHANGES.md";
license = lib.licenses.lgpl3;
maintainers = with lib.maintainers; [ vbgl ];
};
}

View File

@@ -0,0 +1,77 @@
{
stdenv,
lib,
fetchurl,
makeWrapper,
getconf,
ocaml,
unzip,
ncurses,
curl,
bubblewrap,
}:
assert lib.versionAtLeast ocaml.version "4.08.0";
stdenv.mkDerivation (finalAttrs: {
pname = "opam";
version = "2.4.1";
src = fetchurl {
url = "https://github.com/ocaml/opam/releases/download/${finalAttrs.version}/opam-full-${finalAttrs.version}.tar.gz";
hash = "sha256-xNBTApeTxxTk5zQLEVdCjA+QeDWF+xfzUVgkemQEZ9k=";
};
strictDeps = true;
nativeBuildInputs = [
makeWrapper
unzip
ocaml
curl
];
buildInputs = [
ncurses
getconf
]
++ lib.optionals stdenv.hostPlatform.isLinux [ bubblewrap ];
patches = [ ./opam-shebangs.patch ];
configureFlags = [
"--with-vendored-deps"
"--with-mccs"
];
outputs = [
"out"
"installer"
];
setOutputFlags = false;
postInstall = ''
wrapProgram $out/bin/opam \
--suffix PATH : ${
lib.makeBinPath (
[
curl
getconf
unzip
]
++ lib.optionals stdenv.hostPlatform.isLinux [ bubblewrap ]
)
}
$out/bin/opam-installer --prefix=$installer opam-installer.install
'';
doCheck = false;
meta = {
description = "Package manager for OCaml";
homepage = "https://opam.ocaml.org/";
changelog = "https://github.com/ocaml/opam/raw/${finalAttrs.version}/CHANGES";
maintainers = [ ];
license = lib.licenses.lgpl21Only;
platforms = lib.platforms.all;
};
})

View File

@@ -0,0 +1,21 @@
{ opam, ocamlPackages }:
ocamlPackages.buildDunePackage {
pname = "opam-installer";
inherit (opam) version src;
configureFlags = [
"--disable-checks"
"--prefix=$out"
];
buildInputs = with ocamlPackages; [
opam-format
cmdliner
];
meta = opam.meta // {
description = "Handle (un)installation from opam install files";
mainProgram = "opam-installer";
};
}

View File

@@ -0,0 +1,130 @@
diff --git a/src/client/opamInitDefaults.ml b/src/client/opamInitDefaults.ml
index eca13a7c..1fd66f43 100644
--- a/src/client/opamInitDefaults.ml
+++ b/src/client/opamInitDefaults.ml
@@ -38,6 +38,9 @@ let eval_variables =
let os_filter os =
FOp (FIdent ([], OpamVariable.of_string "os", None), `Eq, FString os)
+let os_distribution_filter distro =
+ FOp (FIdent ([], OpamVariable.of_string "os-distribution", None), `Eq, FString distro)
+
let linux_filter = os_filter "linux"
let macos_filter = os_filter "macos"
let openbsd_filter = os_filter "openbsd"
@@ -51,6 +54,7 @@ let win32_filter = os_filter "win32"
let not_win32_filter =
FOp (FIdent ([], OpamVariable.of_string "os", None), `Neq, FString "win32")
let sandbox_filter = FOr (linux_filter, macos_filter)
+let nixos_filter = os_distribution_filter "nixos"
let gtar_filter = openbsd_filter
let tar_filter = FNot gtar_filter
@@ -69,6 +73,11 @@ let sandbox_wrappers =
let wrappers ~sandboxing () =
let w = OpamFile.Wrappers.empty in
+ let w = { w with
+ OpamFile.Wrappers.
+ pre_build = [[CString "%{hooks}%/shebangs.sh", None], Some nixos_filter];
+ }
+ in
if sandboxing then
List.fold_left OpamFile.Wrappers.(fun w -> function
| `build wrap_build -> { w with wrap_build }
@@ -147,6 +156,7 @@ let required_packages_for_cygwin =
let init_scripts () = [
("sandbox.sh", OpamScript.bwrap), Some bwrap_filter;
("sandbox.sh", OpamScript.sandbox_exec), Some macos_filter;
+ ("shebangs.sh", OpamScript.patch_shebangs), Some nixos_filter;
]
module I = OpamFile.InitConfig
diff --git a/src/state/opamScript.mli b/src/state/opamScript.mli
index 03449970..83de0b53 100644
--- a/src/state/opamScript.mli
+++ b/src/state/opamScript.mli
@@ -20,3 +20,4 @@ val env_hook : string
val env_hook_zsh : string
val env_hook_csh : string
val env_hook_fish : string
+val patch_shebangs : string
diff --git a/src/state/shellscripts/patch_shebangs.sh b/src/state/shellscripts/patch_shebangs.sh
new file mode 100755
index 00000000..3ea84e2d
--- /dev/null
+++ b/src/state/shellscripts/patch_shebangs.sh
@@ -0,0 +1,73 @@
+#!/usr/bin/env bash
+# This setup hook causes the fixup phase to rewrite all script
+# interpreter file names (`#! /path') to paths found in $PATH. E.g.,
+# /bin/sh will be rewritten to /nix/store/<hash>-some-bash/bin/sh.
+# /usr/bin/env gets special treatment so that ".../bin/env python" is
+# rewritten to /nix/store/<hash>/bin/python. Interpreters that are
+# already in the store are left untouched.
+
+header() { echo "$1"; }
+stopNest() { true; }
+
+fixupOutputHooks+=('if [ -z "${dontPatchShebangs-}" -a -e "$prefix" ]; then patchShebangs "$prefix"; fi')
+
+patchShebangs() {
+ local dir="$1"
+ header "patching script interpreter paths in $dir"
+ local f
+ local oldPath
+ local newPath
+ local arg0
+ local args
+ local oldInterpreterLine
+ local newInterpreterLine
+
+ find "$dir" -type f -perm -0100 | while read f; do
+ if [ "$(head -1 "$f" | head -c+2)" != '#!' ]; then
+ # missing shebang => not a script
+ continue
+ fi
+
+ oldInterpreterLine=$(head -1 "$f" | tail -c+3)
+ read -r oldPath arg0 args <<< "$oldInterpreterLine"
+
+ if $(echo "$oldPath" | grep -q "/bin/env$"); then
+ # Check for unsupported 'env' functionality:
+ # - options: something starting with a '-'
+ # - environment variables: foo=bar
+ if $(echo "$arg0" | grep -q -- "^-.*\|.*=.*"); then
+ echo "unsupported interpreter directive \"$oldInterpreterLine\" (set dontPatchShebangs=1 and handle shebang patching yourself)"
+ exit 1
+ fi
+ newPath="$(command -v "$arg0" || true)"
+ else
+ if [ "$oldPath" = "" ]; then
+ # If no interpreter is specified linux will use /bin/sh. Set
+ # oldpath="/bin/sh" so that we get /nix/store/.../sh.
+ oldPath="/bin/sh"
+ fi
+ newPath="$(command -v "$(basename "$oldPath")" || true)"
+ args="$arg0 $args"
+ fi
+
+ # Strip trailing whitespace introduced when no arguments are present
+ newInterpreterLine="$(echo "$newPath $args" | sed 's/[[:space:]]*$//')"
+
+ if [ -n "$oldPath" -a "${oldPath:0:${#NIX_STORE}}" != "$NIX_STORE" ]; then
+ if [ -n "$newPath" -a "$newPath" != "$oldPath" ]; then
+ echo "$f: interpreter directive changed from \"$oldInterpreterLine\" to \"$newInterpreterLine\""
+ # escape the escape chars so that sed doesn't interpret them
+ escapedInterpreterLine=$(echo "$newInterpreterLine" | sed 's|\\|\\\\|g')
+ # Preserve times, see: https://github.com/NixOS/nixpkgs/pull/33281
+ touch -r "$f" "$f.timestamp"
+ sed -i -e "1 s|.*|#\!$escapedInterpreterLine|" "$f"
+ touch -r "$f.timestamp" "$f"
+ rm "$f.timestamp"
+ fi
+ fi
+ done
+
+ stopNest
+}
+
+patchShebangs .

View File

@@ -0,0 +1,35 @@
{
lib,
ocaml,
buildDunePackage,
fetchFromGitHub,
cppo,
}:
lib.throwIf (lib.versionAtLeast ocaml.version "5.3")
"reanalyze is not available for OCaml ${ocaml.version}"
buildDunePackage
rec {
pname = "reanalyze";
version = "2.25.1";
minimalOCamlVersion = "4.08";
src = fetchFromGitHub {
owner = "rescript-lang";
repo = "reanalyze";
tag = "v${version}";
hash = "sha256-cM39Gk4Ko7o/DyhrzgEHilobaB3h91Knltkcv2sglFw=";
};
nativeBuildInputs = [ cppo ];
meta = {
description = "Program analysis for ReScript and OCaml projects";
homepage = "https://github.com/rescript-lang/reanalyze/";
changelog = "https://github.com/rescript-lang/reanalyze/blob/v${version}/Changes.md";
license = lib.licenses.mit;
maintainers = [ lib.maintainers.vbgl ];
};
}

View File

@@ -0,0 +1,96 @@
{
lib,
stdenv,
fetchurl,
ocaml,
findlib,
lambda-term,
cppo,
makeWrapper,
buildDunePackage,
xdg,
zed,
logs,
}:
buildDunePackage rec {
pname = "utop";
version = "2.16.0";
propagatedBuildInputs = [
findlib
lambda-term
xdg
zed
logs
];
minimalOCamlVersion = "4.11";
src = fetchurl {
url = "https://github.com/ocaml-community/utop/releases/download/${version}/utop-${version}.tbz";
hash = "sha256-C595E10hMvshHL6ImUHP0NVMx7uAYrigRD44xUC4x2M=";
};
nativeBuildInputs = [
makeWrapper
cppo
];
postFixup =
let
path = "etc/utop/env";
# derivation of just runtime deps so env vars created by
# setup-hooks can be saved for use at runtime
runtime = stdenv.mkDerivation {
pname = "utop-runtime-env";
inherit version;
buildInputs = [ findlib ] ++ propagatedBuildInputs;
dontUnpack = true;
installPhase = ''
mkdir -p "$out"/${path}
for e in OCAMLPATH CAML_LD_LIBRARY_PATH; do
[[ -v "$e" ]] || continue
printf %s "''${!e}" > "$out"/${path}/$e
done
'';
};
get = key: ''$(cat "${runtime}/${path}/${key}")'';
in
''
for prog in "$out"/bin/*
do
# Note: wrapProgram by default calls 'exec -a $0 ...', but this
# breaks utop on Linux with OCaml 4.04, and is disabled with
# '--argv0 ""' flag. See https://github.com/NixOS/nixpkgs/issues/24496
wrapProgram "$prog" \
--argv0 "" \
--prefix CAML_LD_LIBRARY_PATH ":" "${get "CAML_LD_LIBRARY_PATH"}" \
--prefix OCAMLPATH ":" "${get "OCAMLPATH"}" \
--prefix OCAMLPATH ":" $(unset OCAMLPATH; addOCamlPath "$out"; printf %s "$OCAMLPATH") \
--add-flags "-I ${findlib}/lib/ocaml/${lib.getVersion ocaml}/site-lib"
done
'';
meta = {
description = "Universal toplevel for OCaml";
longDescription = ''
utop is an improved toplevel for OCaml. It can run in a terminal or in Emacs. It supports line edition, history, real-time and context sensitive completion, colors, and more.
It integrates with the tuareg mode in Emacs.
'';
homepage = "https://github.com/ocaml-community/utop";
changelog = "https://github.com/ocaml-community/utop/blob/${version}/CHANGES.md";
license = lib.licenses.bsd3;
platforms = ocaml.meta.platforms or [ ];
maintainers = [
lib.maintainers.gal_bolle
];
};
}