Skip to content

Commit

Permalink
Re-add esy (nix-ocaml#123)
Browse files Browse the repository at this point in the history
* Re-add esy

* fix github info

* Add --print-build-logs to Actions builders

* seems to be working for now

* build it in CI too
  • Loading branch information
anmonteiro authored Nov 17, 2021
1 parent 139403b commit 6131b3f
Show file tree
Hide file tree
Showing 12 changed files with 447 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/pipeline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
- name: Build nix packages
run: |
nix shell -f ./boot.nix nix-build-uncached -c \
nix shell --print-build-logs -f ./boot.nix nix-build-uncached -c \
nix-build-uncached ./ci.nix \
--argstr ocamlVersion ${{ matrix.setup.ocaml-version }} \
--argstr target native \
Expand All @@ -62,7 +62,7 @@ jobs:
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
- name: Build nix packages
run: |
nix shell -f ./boot.nix nix-build-uncached -c \
nix shell --print-build-logs -f ./boot.nix nix-build-uncached -c \
nix-build-uncached ./ci.nix \
--argstr ocamlVersion ${{ matrix.setup.ocaml-version }} \
--argstr target native \
Expand Down Expand Up @@ -93,7 +93,7 @@ jobs:
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
- name: Build nix packages
run: |
nix shell -f ./boot.nix nix-build-uncached -c \
nix shell --print-build-logs -f ./boot.nix nix-build-uncached -c \
nix-build-uncached ./ci.nix \
--argstr ocamlVersion ${{ matrix.setup.ocaml-version }} \
--argstr target ${{ matrix.target }} \
Expand Down
1 change: 1 addition & 0 deletions ci.nix
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ let
otherDrvs = with pkgs; [
cockroachdb-21_x
nixUnstable
esy
];
in
[ drvs ] ++ otherDrvs;
Expand Down
1 change: 1 addition & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ in
opaline = (super.opaline.override {
inherit (self) ocamlPackages;
});
esy = callPackage ./ocaml/esy { };

pkgsCross =
let
Expand Down
191 changes: 191 additions & 0 deletions ocaml/esy/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,191 @@
# nix-build -E \
# 'with import <nixpkgs> { };
# let esy = callPackage ./nix/esy {};
# in
# callPackage esy {
# githubInfo = {
# owner = "anmonteiro";
# rev= "42291a9";
# sha256="0mpjlbplhwgnhd12hykh1m5pjqsclax24dywhyl2nsgqlwchghs3";
# };
# }' \
# --pure

{ callPackage, bash, binutils, coreutils, makeWrapper, lib, fetchFromGitHub, ocamlPackages }:

let
currentVersion = "0.6.11";

githubInfo = {
owner = "esy";
rev = "v${currentVersion}";
sha256 = "sha256-LEfhtz0dBObE+167toMp1mz5onMbp7h2RVB+RgtbahM=";
};

esyVersion = currentVersion;

esyOcamlPkgs = ocamlPackages.overrideScope' (self: super: {
# buildDunePackage = (super.buildDunePackage.override { dune_1 = super.dune_one; });

cmdliner =
super.cmdliner.overrideAttrs (_: {
src = builtins.fetchurl {
url = https://github.com/esy-ocaml/cmdliner/archive/e9316bc.tar.gz;
sha256 = "1g0shk5ahc6byhx79ry6vdyf89a1ncq5bsgykkxa05xabvlr09ji";
};
createFindlibDestdir = true;
});
});
in

with esyOcamlPkgs;

let
esy-solve-cudf = buildDunePackage rec {
pname = "esy-solve-cudf";
version = "0.1.10";
buildInputs = [
ocaml
findlib
dune
];
propagatedBuildInputs = [
cmdliner
cudf
mccs
ocaml_extlib
];
src = fetchFromGitHub {
owner = "andreypopp";
repo = pname;
rev = "v${version}";
sha256 = "1ky2mkyl676bxphyx0d3vqr58za185nq46h0lai89631g94ia1d7";
};

buildPhase = ''
runHook preBuild
dune build -p ${pname}
runHook postBuild
'';

meta = {
homepage = https://github.com/andreypopp/esy-solve-cudf;
description = "package.json workflow for native development with Reason/OCaml";
license = lib.licenses.gpl3;
};
};

# XXX(anmonteiro): The NPM registry doesn't allow us to fetch version
# information for scoped packages, and `@esy-nightly/esy` is scoped. It also
# seems that Esy only uses the `package.json` file to display the version
# information in `esy --version`, so we can kinda ignore this for now. We're
# able to build and install nightly releases but it'll always display the
# current version information.
esyNpm = builtins.fetchurl {
url = "https://registry.npmjs.org/esy/${esyVersion}";
sha256 = "1gnd2saq969nxrxfks257n0hp5s4ywh9r91hwgwyg9misgivd3m7";
};

esySolveCudfNpm = builtins.fetchurl {
url = "https://registry.npmjs.org/esy-solve-cudf/${esy-solve-cudf.version}";
sha256 = "19m793mydd8gcgw1mbn7pd8fw2rhnd00k5wpa4qkx8a3zn6crjjf";
};

in

buildDunePackage {
pname = "esy";
version = esyVersion;

minimumOCamlVersion = "4.06";

src = fetchFromGitHub {
owner = githubInfo.owner;
repo = "esy";
rev = githubInfo.rev;
sha256 = githubInfo.sha256;
};

nativeBuildInputs = [
makeWrapper
dune-configurator
];

propagatedBuildInputs = [
coreutils
bash
];

buildInputs = [
angstrom
cmdliner
reason
bos
fmt
fpath
lambdaTerm
logs
lwt
lwt_ppx
menhir
opam-file-format
ppx_deriving
ppx_deriving_yojson
ppx_expect
ppx_inline_test
ppx_let
ppx_sexp_conv
re
yojson
cudf
dose3
opam-format
opam-core
opam-state
];
doCheck = false;

buildPhase = ''
runHook preBuild
dune build -p esy
runHook postBuild
'';

# |- bin
# |- esy
# |- lib
# |- default
# |- bin
# |- esy.exe
# |- esyInstallRelease.js
# |- esy-build-package
# |- bin
# |- esyBuildPackageCommand.exe
# |- esyRewritePrefixCommand.exe
# |- node_modules
# |- esy-solve-cudf
# |- package.json
# |- esySolveCudfCommand.exe
postInstall = ''
mkdir -p $out/lib/default/bin
mkdir -p $out/lib/default/esy-build-package/bin
mkdir -p $out/lib/node_modules/esy-solve-cudf
mkdir -p $out/lib/esy
# mv $out/bin/esyInstallRelease.js $out/lib/default/bin/
cp ${esyNpm} $out/package.json
# cp ${esySolveCudfNpm} $out/lib/node_modules/esy-solve-cudf/package.json
ln -s ${esy-solve-cudf}/bin/esy-solve-cudf $out/lib/esy/esySolveCudfCommand
ls $out/lib/esy
# wrapProgram \
# $out/bin/esy \
# --set ESY__GLOBAL_PATH /usr/bin:${binutils}/bin:${coreutils}/bin:${bash}/bin
'';

meta = {
homepage = https://github.com/esy/esy;
description = "package.json workflow for native development with Reason/OCaml";
license = lib.licenses.bsd2;
};
}
133 changes: 133 additions & 0 deletions ocaml/esy/patches/0001-Install-mli-cmx-etc.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
From b5314c20d8e3caf62fe0dc96ad937a2950158b23 Mon Sep 17 00:00:00 2001
From: Louis Gesbert <louis.gesbert@ocamlpro.com>
Date: Thu, 2 Mar 2017 12:19:56 +0100
Subject: [PATCH] Install mli, cmx, etc.

---
Makefile | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/Makefile b/Makefile
index 09464ff..5044d7f 100644
--- a/Makefile
+++ b/Makefile
@@ -56,7 +56,7 @@ $(DOSELIBS)/cudf.%:
@for i in _build/cudf/cudf.*; do \
if [ -e $$i ]; then \
cp $$i $(DOSELIBS) ; \
- rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
+ rm -f $(DOSELIBS)/*.mlpack ; \
fi ; \
done

@@ -67,7 +67,7 @@ $(DOSELIBS)/common.%: common/*.ml common/*.mli
if [ -e $$i ]; then \
cp $$i $(DOSELIBS) ; \
rm $$i ;\
- rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
+ rm -f $(DOSELIBS)/*.mlpack ; \
fi ; \
done

@@ -78,7 +78,7 @@ $(DOSELIBS)/versioning.%: versioning/*.ml versioning/*.mli
if [ -e $$i ]; then \
cp $$i $(DOSELIBS) ; \
rm $$i ;\
- rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
+ rm -f $(DOSELIBS)/*.mlpack ; \
fi ; \
done

@@ -88,7 +88,7 @@ $(DOSELIBS)/algo.%: algo/*.ml algo/*.mli $(DOSELIBS)/common.%
if [ -e $$i ]; then \
cp $$i $(DOSELIBS) ; \
rm $$i ;\
- rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
+ rm -f $(DOSELIBS)/*.mlpack ; \
fi ; \
done

@@ -98,7 +98,7 @@ $(DOSELIBS)/debian.%: deb/*.ml deb/*.mli $(DOSELIBS)/pef.%
if [ -e $$i ]; then \
cp $$i $(DOSELIBS) ; \
rm $$i ;\
- rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
+ rm -f $(DOSELIBS)/*.mlpack ; \
fi ; \
done

@@ -108,7 +108,7 @@ $(DOSELIBS)/opam.%: opam/*.ml opam/*.mli $(DOSELIBS)/pef.%
if [ -e $$i ]; then \
cp $$i $(DOSELIBS) ; \
rm $$i ;\
- rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
+ rm -f $(DOSELIBS)/*.mlpack ; \
fi ; \
done

@@ -118,7 +118,7 @@ $(DOSELIBS)/npm.%: npm/*.ml npm/*.mli $(DOSELIBS)/versioning.% $(DOSELIBS)/pef.%
if [ -e $$i ]; then \
cp $$i $(DOSELIBS) ; \
rm $$i ;\
- rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
+ rm -f $(DOSELIBS)/*.mlpack ; \
fi ; \
done

@@ -128,7 +128,7 @@ $(DOSELIBS)/rpm.%: rpm/*.ml $(DOSELIBS)/algo.%
if [ -e $$i ]; then \
cp $$i $(DOSELIBS) ; \
rm $$i ;\
- rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
+ rm -f $(DOSELIBS)/*.mlpack ; \
fi ; \
done

@@ -138,7 +138,7 @@ $(DOSELIBS)/pef.%: pef/*.ml pef/*.mli
if [ -e $$i ]; then \
cp $$i $(DOSELIBS) ; \
rm $$i ;\
- rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
+ rm -f $(DOSELIBS)/*.mlpack ; \
fi ; \
done

@@ -148,7 +148,7 @@ $(DOSELIBS)/csw.%: opencsw/*.ml $(DOSELIBS)/versioning.%
if [ -e $$i ]; then \
cp $$i $(DOSELIBS) ; \
rm $$i ;\
- rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ; \
+ rm -f $(DOSELIBS)/*.mlpack ; \
fi ; \
done

@@ -158,7 +158,7 @@ $(DOSELIBS)/doseparse.%: $(DOSELIBS)/pef.% $(DOSELIBS)/debian.%
if [ -e $$i ]; then \
cp $$i $(DOSELIBS) ; \
rm $$i ;\
- rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx $(DOSELIBS)/*.ml ; \
+ rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.ml ; \
fi ; \
done

@@ -168,7 +168,7 @@ $(DOSELIBS)/doseparseNoRpm.%: $(DOSELIBS)/pef.% $(DOSELIBS)/debian.%
if [ -e $$i ]; then \
cp $$i $(DOSELIBS) ;\
rm $$i ;\
- rm -f $(DOSELIBS)/*.mlpack $(DOSELIBS)/*.cmx ;\
+ rm -f $(DOSELIBS)/*.mlpack ;\
fi ; \
done

@@ -223,7 +223,7 @@ INSTALL_STUFF_ = META
INSTALL_STUFF_ += $(wildcard _build/doselibs/*.cma _build/doselibs/*.cmi)
INSTALL_STUFF_ += $(wildcard _build/doselibs/*.cmxa _build/doselibs/*.cmxs)
INSTALL_STUFF_ += $(wildcard _build/doselibs/*.a)
-#INSTALL_STUFF_ += $(wildcard _build/*/*.mli)
+INSTALL_STUFF_ += $(wildcard _build/doselibs/*.mli) $(wildcard _build/doselibs/*.cmti) $(wildcard _build/doselibs/*.cmx)
INSTALL_STUFF_ += $(wildcard _build/rpm/*.so)

exclude_cudf = $(wildcard _build/doselibs/*cudf* _build/cudf/*)
--
2.11.0

9 changes: 9 additions & 0 deletions ocaml/esy/patches/0002-dont-make-printconf.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
--- a/configure
+++ b/configure
@@ -6552,6 +6552,3 @@ if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
fi
-
-
-make printconf
Loading

0 comments on commit 6131b3f

Please sign in to comment.