nix-ocaml / nix-overlays Goto Github PK
View Code? Open in Web Editor NEWOCaml-focused, custom nix-overlays
License: MIT License
OCaml-focused, custom nix-overlays
License: MIT License
to be used with nix flake init -t
$ nix-build ./boot.nix -A pkgs.pkgsCross.aarch64-multiplatform.ocaml-ng.ocamlPackages_4_12.bigstringaf
I have been using the nix-ocaml/ocaml-overlays
for a while now. Recently, I tried to update my flake-inputs and have been receiving a
error: attribute 'aarch64-darwin' missing
at /nix/store/5pn4hvrbh34ri3b60z7dqaszipbxc8v6-source/flake.nix:26:24:
25| inherit system;
26| overlays = [ inputs.ocaml-overlay.overlays.${system} ];
| ^
27| };
The relevant parts of my flake.nix
are:
{
inputs = {
...
ocaml-overlay = {
url = "github:nix-ocaml/nix-overlays";
inputs.nixpkgs.follows = "nixpkgs";
};
...
};
outputs = { self, nixpkgs, ... }@inputs:
let
supportedSystems = with inputs.flake-utils.lib.system; [ aarch64-darwin ];
in inputs.flake-utils.lib.eachSystem supportedSystems (system:
let
overlays = [ inputs.ocaml-overlay.overlays.${system} ];
pkgs = import nixpkgs {
inherit system overlays;
};
in { ... });
}
Nothing else has changed and going back to my previous flake.lock
has it working again.
Has something happened to the aarch64-darwin
support? Or did the project's structure change and it is not reflected in the README?
Currently, the default overlay for this repo is completely absent due to the use of the non-recursive //
operator. It should be replaced with pkgs.lib.recursiveUpdate
.
I tried getting an OCaml 5 on aarch64-darwin
using this overlay, but encounter a build failure. Any idea whether it's a known issue/limitation with the overlay, or with upstream support for these machines?
Flake:
{
description = "foo";
inputs = {
nixpkgs.url = "nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
ocaml-overlay = {
url = "github:nix-ocaml/nix-overlays";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils, ocaml-overlay }@inputs:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; overlays = [ocaml-overlay.overlays.default]; };
in
{
devShell = pkgs.mkShell {
buildInputs = with pkgs.ocaml-ng.ocamlPackages_5_0; [ ocaml ];
};
}
);
}
Failure:
error: builder for '/nix/store/hlhq92xxm9kd3n5xfcmgkqxq5qndc9gy-ocaml+flambda-5.0.0.drv' failed with exit code 2;
last 10 log lines:
> Error: I/O error: dllunix.so_The boot compiler cannot load DLLs: No such file or directory
> make[4]: *** [Makefile:166: ../ocamldoc/ocamldoc] Error 2
> make[4]: Leaving directory '/private/tmp/nix-build-ocaml+flambda-5.0.0.drv-0/ocaml-5.0.0/ocamldoc'
> make[3]: *** [Makefile:1163: ocamldoc] Error 2
> make[3]: Leaving directory '/private/tmp/nix-build-ocaml+flambda-5.0.0.drv-0/ocaml-5.0.0'
> make[2]: *** [Makefile:313: all] Error 2
> make[2]: Leaving directory '/private/tmp/nix-build-ocaml+flambda-5.0.0.drv-0/ocaml-5.0.0'
> make[1]: *** [Makefile:328: bootstrap] Error 2
> make[1]: Leaving directory '/private/tmp/nix-build-ocaml+flambda-5.0.0.drv-0/ocaml-5.0.0'
> make: *** [/nix/store/0rawfy9g1y4c2h4s60sjm6m80cri92n3-Makefile.nixpkgs:15: nixpkgs_world_bootstrap_world_opt] Error 2
For full logs, run 'nix log /nix/store/hlhq92xxm9kd3n5xfcmgkqxq5qndc9gy-ocaml+flambda-5.0.0.drv'.
error: 1 dependencies of derivation '/nix/store/pkxbhi6a836hs25m9b2h3xsj90n7s667-nix-shell-env.drv' failed to build
Full log: https://gist.github.com/purcell/22c016df4c572d8139f847bbb37326bc
Cachix is great but we're building too much
I don't see any license in this repo, which means that legally there's very little people can use this code for. This would be a blocker for somebody other than the copyright holder upstreaming the cross compilation support.
I suggest copying the license structure of Nixpkgs, particularly the note about patches being licensed under the licenses of their respective upstreams, to allow for upstreaming.
I wasn't aware of your overlay repository before I started packaging / upstreaming packages to nixpkgs.
I understand it is not your priority to upstream your packages.
Packages already upstreamed to nixpkgs (some in a newer version):
dune-configurator
.[I haven't included all yet.]
Consider testing them from upstream and removing it from your overlay in case it works for you.
My goal here is to avoid duplication, avoid drift and find edge cases to be fixed on upstream.
I'll keep updating this issue as I go through the process of upstreaming to Nixpkgs (packages that overlaps yours).
Note: I am by no means an ocaml person, I know 0 ocaml, just trying to statically package comby ๐
Im getting build failures of the above kind when trying to build the following derivation using nix-ocaml/nix-overlays?rev=9287d78084ac4c0b69bff81cd6afacc4ff98c4a9. Apply the following patch to the above revision of sourcegraph/sourcegraph
for it to be using nix-ocaml/nix-overlays:
diff --git a/flake.lock b/flake.lock
index 03634ff4d4..3c70103cdf 100644
--- a/flake.lock
+++ b/flake.lock
@@ -1,5 +1,20 @@
{
"nodes": {
+ "flake-utils": {
+ "locked": {
+ "lastModified": 1678901627,
+ "narHash": "sha256-U02riOqrKKzwjsxc/400XnElV+UtPUQWpANPlyazjH0=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "93a2b84fc4b70d9e089d029deacc3583435c2ed6",
+ "type": "github"
+ },
+ }
+ },
+ "ocaml": {
+ "inputs": {
+ "flake-utils": "flake-utils",
+ "nixpkgs": "nixpkgs_2"
+ },
+ "locked": {
+ "lastModified": 1680538699,
+ "narHash": "sha256-0un9Iyt437edWOeZ3oP9iYhjYtCfQKCMprL902Eo2Ck=",
+ "owner": "nix-ocaml",
+ "repo": "nix-overlays",
+ "rev": "9287d78084ac4c0b69bff81cd6afacc4ff98c4a9",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-ocaml",
+ "repo": "nix-overlays",
+ "type": "github"
+ }
+ },
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
+ "ocaml": "ocaml",
"utils": "utils"
}
},
diff --git a/flake.nix b/flake.nix
index 2159574e29..333730ba79 100644
--- a/flake.nix
+++ b/flake.nix
@@ -4,9 +4,10 @@
inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
+ ocaml.url = "github:nix-ocaml/nix-overlays";
};
- outputs = { self, nixpkgs, utils }:
+ outputs = { self, nixpkgs, utils, ocaml }:
with nixpkgs.lib; with utils.lib; {
devShells = eachDefaultSystem (system:
let
@@ -23,7 +24,7 @@
packages = fold recursiveUpdate { } [
((import ./dev/nix/ctags.nix { inherit nixpkgs utils; }).packages)
(import ./dev/nix/p4-fusion.nix { inherit nixpkgs utils; })
- (import ./dev/nix/comby.nix { inherit nixpkgs utils; })
+ (import ./dev/nix/comby.nix { inherit utils; nixpkgs = ocaml; })
];
};
}
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/9hxcsw76gq991d6abh6nmjsm7rl1dd6k-source
source root is source
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
no configure script, doing nothing
@nix { "action": "setPhase", "phase": "buildPhase" }
building
Scanned 0 directories
Done: 0% (0/0, 0 left) (jobs: 0)
...
@nix { "action": "setPhase", "phase": "unpackPhase" }
unpacking sources
unpacking source archive /nix/store/9hxcsw76gq991d6abh6nmjsm7rl1dd6k-source
source root is source
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
updateAutotoolsGnuConfigScriptsPhase
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
no configure script, doing nothing
@nix { "action": "setPhase", "phase": "buildPhase" }
building
Scanned 0 directories
Done: 0% (0/0, 0 left) (jobs: 0)
...
File "src/unix/config/dune", line 4, characters 12-29:
4 | (libraries dune.configurator))
^^^^^^^^^^^^^^^^^
Error: Library "dune.configurator" not found.
-> required by _build/default/src/unix/config/discover.exe
-> required by _build/default/src/unix/lwt_features.h
-> required by _build/install/default/lib/lwt/unix/lwt_features.h
-> required by _build/default/lwt.install
-> required by alias install
Done: 25% (116/448, 332 left) (jobs: 0)
...
(cd _build/default && /nix/store/3s8bqs0wbrc1wmvywqknm9p9725nx24x-ocaml+flambda-static-x86_64-unknown-linux-musl-4.14.1/bin/ocamlc.opt -w -40 -w +A-29 -g -bin-annot -I src/core/.lwt.objs/byte -intf-suffix .ml -no-alias-deps -o src/core/.lwt.objs/byte/lwt_stream.cmo -c -impl src/core/lwt_stream.ml)
File "src/core/lwt_stream.ml", line 46, characters 2-55:
46 | mutable push_external : Obj.t [@ocaml.warning "-69"];
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning 69 [unused-field]: record field push_external is never read.
(However, this field is used to build or mutate values.)
File "src/core/lwt_stream.ml", line 67, characters 2-56:
67 | mutable pushb_external : Obj.t [@ocaml.warning "-69"];
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning 69 [unused-field]: record field pushb_external is never read.
(However, this field is used to build or mutate values.)
Done: 71% (591/821, 230 left, 1 failed) (jobs: 6)
...
(cd _build/default && /nix/store/3s8bqs0wbrc1wmvywqknm9p9725nx24x-ocaml+flambda-static-x86_64-unknown-linux-musl-4.14.1/bin/ocamlopt.opt -w -40 -w +A-29 -g -I src/core/.lwt.objs/byte -I src/core/.lwt.objs/native -intf-suffix .ml -no-alias-deps -o src/core/.lwt.objs/native/lwt_stream.cmx -c -impl src/core/lwt_stream.ml)
File "src/core/lwt_stream.ml", line 46, characters 2-55:
46 | mutable push_external : Obj.t [@ocaml.warning "-69"];
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning 69 [unused-field]: record field push_external is never read.
(However, this field is used to build or mutate values.)
File "src/core/lwt_stream.ml", line 67, characters 2-56:
67 | mutable pushb_external : Obj.t [@ocaml.warning "-69"];
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Warning 69 [unused-field]: record field pushb_external is never read.
(However, this field is used to build or mutate values.)
Done: 76% (627/821, 194 left, 1 failed) (jobs: 1)
Done: 76% (629/821, 192 left, 1 failed) (jobs: 1)
Saving build trace db...
Saving digest db...
Any pointers or solutions much appreciated!
Does this task going to be complicated?
Any chance that newcomer like me could manage doing this by textually replacing arm by riscv?
Both failures are build of ocaml itself
I cut most interesting parts from logs (patching, detecting architectures, and failure itself), but could provide full logs if needed.
You can see, that patches from overlay not applied, and so build of cross compiler fails.
I isolated problem to minimal flake, which illustrating how I used it -- https://github.com/avnik/nixpkgs-cross-build-repro/tree/avnik/ocaml-cross-overlay-repro
Could you hint, if I used overlay in wrong way or help me debug this issue if usage of overlay is correct.
Will be grateful for your help.
unpacking sources
unpacking source archive /nix/store/121nmhs8zpd9729jhmskvsd6n010cwim-ocaml-4.14.1.tar.xz
source root is ocaml-4.14.1
setting SOURCE_DATE_EPOCH to timestamp 1671539204 of file ocaml-4.14.1/yacc/wstr.c
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
updateAutotoolsGnuConfigScriptsPhase
Updating Autotools / GNU config script to a newer upstream version: ./build-aux/config.sub
Updating Autotools / GNU config script to a newer upstream version: ./build-aux/config.guess
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
fixing libtool script ./build-aux/ltmain.sh
./configure
configure flags: --disable-static -prefix /nix/store/dzn0inc8w11bs0lwh5x12nzapf74l323-ocaml+flambda-4.14.1 --enable-flambda --host=x86_64-unknown-linux-gnu --target=aarch64-unknown-linux-gnu
configure: Configuring OCaml version 4.14.1
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... aarch64-unknown-linux-gnu
...
make[5]: Entering directory '/build/ocaml-4.14.1/api_docgen/ocamldoc'
mkdir -p build/
cp ../../api_docgen/Ocaml_operators.mld build/Ocaml_operators.mld
mkdir -p build/libref
../../boot/ocamlrun ./../../ocamldoc/ocamldoc -I ../../stdlib -I ../../otherlibs/str -I ../../otherlibs/unix -I ../../otherlibs/dynlink -I ../../otherlibs/systhreads -text build/Ocaml_operato>
Fatal error: cannot load shared library dllunix
Reason: dllunix.so: cannot open shared object file: No such file or directory
make[5]: *** [Makefile:60: build/libref/Ocaml_operators.odoc] Aborted (core dumped)
And build for target
unpacking source archive /nix/store/121nmhs8zpd9729jhmskvsd6n010cwim-ocaml-4.14.1.tar.xz
source root is ocaml-4.14.1
setting SOURCE_DATE_EPOCH to timestamp 1671539204 of file ocaml-4.14.1/yacc/wstr.c
@nix { "action": "setPhase", "phase": "patchPhase" }
patching sources
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
updateAutotoolsGnuConfigScriptsPhase
Updating Autotools / GNU config script to a newer upstream version: ./build-aux/config.sub
Updating Autotools / GNU config script to a newer upstream version: ./build-aux/config.guess
@nix { "action": "setPhase", "phase": "updateAutotoolsGnuConfigScriptsPhase" }
updateAutotoolsGnuConfigScriptsPhase
Updating Autotools / GNU config script to a newer upstream version: ./build-aux/config.sub
Updating Autotools / GNU config script to a newer upstream version: ./build-aux/config.guess
@nix { "action": "setPhase", "phase": "configurePhase" }
configuring
fixing libtool script ./build-aux/ltmain.sh
./configure
configure flags: --disable-static -prefix /nix/store/qhqzlxgw5i89pynx9mgwg6arv70r14x6-ocaml+flambda-aarch64-unknown-linux-gnu-4.14.1 --enable-flambda --host=aarch64-unknown-linux-gnu --target=aarch64-unknown-linux-gnu
configure: Configuring OCaml version 4.14.1
checking build system type... x86_64-pc-linux-gnu
checking host system type... aarch64-unknown-linux-gnu
checking target system type... aarch64-unknown-linux-gnu
...
aarch64-unknown-linux-gnu-gcc -c -O2 -fno-strict-aliasing -fwrapv -pthread -Wall -Wdeclaration-after-statement -fno-common -fexcess-precision=standard -ffunction-sections -g -D_FILE_OFFSET_BITS=64 -DCAML_NAME_SPACE -DCAMLDLLIMPORT= -o startup_byt.b.o startup_byt.c
In file included from caml/alloc.h:23,
from startup_byt.c:32:
startup_byt.c: In function 'do_print_config':
caml/misc.h:382:32: error: too few arguments to function 'caml_stat_strdup'
382 | #define caml_stat_strdup_of_os caml_stat_strdup
| ^~~~~~~~~~~~~~~~
startup_byt.c:382:10: note: in expansion of macro 'caml_stat_strdup_of_os'
382 | caml_stat_strdup_of_os(OCAML_STDLIB_DIR));
| ^~~~~~~~~~~~~~~~~~~~~~
In file included from startup_byt.c:49:
caml/memory.h:161:29: note: declared here
161 | CAMLextern caml_stat_string caml_stat_strdup(const char *s);
| ^~~~~~~~~~~~~~~~
make[2]: *** [Makefile:366: startup_byt.b.o] Error 1
It would be really great if Nixpkgs could cross-compile OCaml out of the box. What would need to happen to get the cross-compilation support from this overlay upstream? I would be willing to put work into this, but if you already have thought about what would need to happen it would be great to hear from you.
I'm on nix v2.13.0
When attempting to use your overlay in my shell.nix
a la:
let
nixpkgs = <nixpkgs>;
ocaml-overlay = builtins.fetchTarball
https://github.com/nix-ocaml/nix-overlays/archive/master.tar.gz;
in with import nixpkgs {
overlays = [
(import "${ocaml-overlay}/overlay" { inherit nixpkgs; })
];
}; ...
I get the error cannot coerce a set into a string
pointing to
nix-overlays/ocaml/default.nix
Line 595 in 1a1f0f8
We should figure out a way to apply patches to the upstream nixpkgs do that we can cherry pick upstream PRs.
I'm trying to figure out an approach to using cross compilation in a flake, where there would be a client and a server, the client being run on a raspberry pi, and the server on x86 linux. I'm unsure about the project structure and workflow for that, whether the cross overlay is meant to enable dune to support cross compilation, a system flag is meant to be passed to nix build
, or a separate packages should be defined for each system, where each package calls buildDunePackage
with the appropriate cross or host ocamlPackages
. I'm also not sure about where tools like dune should be provided to enable the cross compilation. Is there an example that does something like along these lines?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.