diff --git a/flake.lock b/flake.lock index 6f74ce80e52..88a35c5e00f 100644 --- a/flake.lock +++ b/flake.lock @@ -1,23 +1,5 @@ { "nodes": { - "flake-utils": { - "inputs": { - "systems": "systems" - }, - "locked": { - "lastModified": 1731533236, - "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "melange": { "inputs": { "melange-compiler-libs": "melange-compiler-libs", @@ -63,11 +45,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1752012998, - "narHash": "sha256-Q82Ms+FQmgOBkdoSVm+FBpuFoeUAffNerR5yVV7SgT8=", + "lastModified": 1758029226, + "narHash": "sha256-TjqVmbpoCqWywY9xIZLTf6ANFvDCXdctCjoYuYPYdMI=", "owner": "nixos", "repo": "nixpkgs", - "rev": "2a2130494ad647f953593c4e84ea4df839fbd68c", + "rev": "08b8f92ac6354983f5382124fef6006cade4a1c1", "type": "github" }, "original": { @@ -84,11 +66,11 @@ ] }, "locked": { - "lastModified": 1752292614, - "narHash": "sha256-PwW/5J+SslGqkaCEad/1fvbTgPw2eI2UJkjStmGSChI=", + "lastModified": 1757914736, + "narHash": "sha256-fiLNJX5uusNjr/MtVwwBtXVS1qu9ON9kND1wN+w3VT8=", "owner": "nix-ocaml", "repo": "nix-overlays", - "rev": "fbbcd2e563cf33e4a4fdbac4395e7276a506ef09", + "rev": "0cb4c494c441b78462606d5c26ce5df52b4dc900", "type": "github" }, "original": { @@ -99,26 +81,10 @@ }, "root": { "inputs": { - "flake-utils": "flake-utils", "melange": "melange", "nixpkgs": "nixpkgs", "ocaml-overlays": "ocaml-overlays" } - }, - "systems": { - "locked": { - "lastModified": 1681028828, - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", - "owner": "nix-systems", - "repo": "default", - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", - "type": "github" - }, - "original": { - "owner": "nix-systems", - "repo": "default", - "type": "github" - } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 83674891b7c..bbbaa8e206f 100644 --- a/flake.nix +++ b/flake.nix @@ -1,7 +1,6 @@ { inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; - flake-utils.url = "github:numtide/flake-utils"; melange = { url = "github:melange-re/melange/refs/tags/5.1.0-53"; inputs.nixpkgs.follows = "nixpkgs"; @@ -14,371 +13,386 @@ outputs = { self, - flake-utils, nixpkgs, melange, ocaml-overlays, }: - flake-utils.lib.eachDefaultSystem ( - system: - let - pkgs = nixpkgs.legacyPackages.${system}.appendOverlays [ - ocaml-overlays.overlays.default - (self: super: { - ocamlPackages = super.ocaml-ng.ocamlPackages_5_3.overrideScope ( - oself: osuper: { - mdx = osuper.mdx.override { - logs = oself.logs; - }; - utop = osuper.utop.overrideAttrs { - dontGzipMan = true; - }; - } - ); - }) - melange.overlays.default - (self: super: { - coq_8_16_native = super.coq_8_16.overrideAttrs (a: { - configureFlags = [ - "-native-compiler" - "yes" - ]; - }); - }) - ]; - dune-static-overlay = self: super: { - ocamlPackages = super.ocaml-ng.ocamlPackages_5_3.overrideScope ( - oself: osuper: { - dune_3 = osuper.dune_3.overrideAttrs (a: { - src = ./.; - preBuild = "ocaml boot/bootstrap.ml --static"; + let + inherit (nixpkgs) lib; + systems = [ + "x86_64-linux" + "aarch64-linux" + "x86_64-darwin" + "aarch64-darwin" + ]; + eachSystem = lib.genAttrs systems; + pkgsFor = eachSystem ( + system: + import nixpkgs { + localSystem.system = system; + overlays = [ + ocaml-overlays.overlays.default + melange.overlays.default + (_: super: { + ocamlPackages = super.ocaml-ng.ocamlPackages_5_3.overrideScope ( + oself: osuper: { + mdx = osuper.mdx.override { + logs = oself.logs; + }; + utop = osuper.utop.overrideAttrs { + dontGzipMan = true; + }; + } + ); + }) + (_: super: { + coq_8_16_native = super.coq_8_16.overrideAttrs (_: { + configureFlags = [ + "-native-compiler" + "yes" + ]; }); - } - ); + }) + ]; + } + ); + dune-static-overlay = _: super: { + ocamlPackages = super.ocaml-ng.ocamlPackages_5_3.overrideScope ( + _: osuper: { + dune_3 = osuper.dune_3.overrideAttrs (a: { + src = ./.; + preBuild = "ocaml boot/bootstrap.ml --static"; + }); + } + ); + }; + + pkgsForStatic = eachSystem ( + system: + import nixpkgs { + localSystem.system = system; + overlays = [ + ocaml-overlays.overlays.default + dune-static-overlay + ]; + } + ); + add-experimental-configure-flags = + pkg: + pkg.overrideAttrs { + configureFlags = [ + "--pkg-build-progress" + "enable" + "--lock-dev-tool" + "enable" + "--portable-lock-dir" + "enable" + ]; }; - pkgs-static = nixpkgs.legacyPackages.${system}.appendOverlays [ - ocaml-overlays.overlays.default - dune-static-overlay - ]; + ocamlformat_version = + let + ocamlformat_config = lib.splitString "\n" (builtins.readFile ./.ocamlformat); + prefix = "version="; + ocamlformat_version_pred = line: lib.hasPrefix prefix line; + version_line = lib.findFirst ocamlformat_version_pred "not_found" ocamlformat_config; + version = lib.removePrefix prefix version_line; + in + lib.replaceString "." "_" version; + in + { + formatter = eachSystem (system: pkgsFor.${system}.nixfmt); - add-experimental-configure-flags = - pkg: - pkg.overrideAttrs { - configureFlags = [ - "--pkg-build-progress" - "enable" - "--lock-dev-tool" - "enable" - "--portable-lock-dir" - "enable" - ]; - }; + packages = eachSystem ( + system: + let + pkgs = pkgsFor.${system}; + in + { + default = self.packages.${system}.dune; - ocamlformat = - let - ocamlformat_version = + dune = pkgs.stdenv.mkDerivation { + pname = "dune"; + version = "3.x-n/a"; + src = let - lists = pkgs.lib.lists; - strings = pkgs.lib.strings; - ocamlformat_config = strings.splitString "\n" (builtins.readFile ./.ocamlformat); - prefix = "version="; - ocamlformat_version_pred = line: strings.hasPrefix prefix line; - version_line = lists.findFirst ocamlformat_version_pred "not_found" ocamlformat_config; - version = strings.removePrefix prefix version_line; + fs = lib.fileset; in - builtins.replaceStrings [ "." ] [ "_" ] version; - in - builtins.getAttr ("ocamlformat_" + ocamlformat_version) pkgs; + fs.toSource { + root = ./.; + fileset = fs.unions [ + ./bin + ./boot + ./configure + ./dune-project + ./dune-file + ./src + ./plugin + ./vendor + ./otherlibs + ./Makefile + (fs.fileFilter (file: file.hasExt "opam" || file.hasExt "template") ./.) + ]; + }; - testBuildInputs = - with pkgs; - [ - file - mercurial - unzip - ] - ++ lib.optionals stdenv.isLinux [ strace ]; - testNativeBuildInputs = - pkgs: with pkgs; [ - nodejs-slim - pkg-config - opam - ocamlformat - ]; + nativeBuildInputs = with pkgs.ocamlPackages; [ + ocaml + findlib + ]; - docInputs = with pkgs.python3.pkgs; [ - sphinx-autobuild - furo - sphinx-copybutton - sphinx-design - myst-parser - ]; - in - { - formatter = pkgs.nixfmt; + strictDeps = true; + buildFlags = [ "release" ]; + dontAddPrefix = true; + dontAddStaticConfigureFlags = true; + configurePlatforms = [ ]; + installFlags = [ + "PREFIX=${placeholder "out"}" + "LIBDIR=$(OCAMLFIND_DESTDIR)" + ]; + }; - packages = { - default = - with pkgs; - stdenv.mkDerivation { - pname = "dune"; - version = "3.x-n/a"; - src = - let - fs = lib.fileset; - in - fs.toSource { - root = ./.; - fileset = fs.unions [ - ./bin - ./boot - ./configure - ./dune-project - ./dune-file - ./src - ./plugin - ./vendor - ./otherlibs - ./Makefile - (fs.fileFilter (file: file.hasExt "opam" || file.hasExt "template") ./.) - ]; - }; - nativeBuildInputs = with ocamlPackages; [ - ocaml - findlib - ]; - buildInputs = lib.optionals stdenv.isDarwin [ - darwin.apple_sdk.frameworks.CoreServices - ]; - strictDeps = true; - buildFlags = [ "release" ]; - dontAddPrefix = true; - dontAddStaticConfigureFlags = true; - configurePlatforms = [ ]; - installFlags = [ - "PREFIX=${placeholder "out"}" - "LIBDIR=$(OCAMLFIND_DESTDIR)" - ]; - }; - dune = self.packages.${system}.default; - dune-static = pkgs-static.pkgsCross.musl64.ocamlPackages.dune; + dune-static = pkgsForStatic.${system}.pkgsCross.musl64.ocamlPackages.dune; dune-experimental = add-experimental-configure-flags self.packages.${system}.dune; dune-static-experimental = add-experimental-configure-flags self.packages.${system}.dune-static; - }; + } + ); - devShells = - let - INSIDE_NIX = "true"; - makeDuneDevShell = - { - extraBuildInputs ? (pkgs: [ ]), - meta ? null, - duneFromScope ? false, - }: - let - pkgs' = - if duneFromScope then - pkgs.extend ( - pself: psuper: { - ocamlPackages = psuper.ocamlPackages.overrideScope ( - oself: osuper: { - dune_3 = self.packages.${system}.default; - } - ); - } - ) - else - pkgs; + devShells = eachSystem ( + system: + let + pkgs = pkgsFor.${system}; + INSIDE_NIX = "true"; - inherit (pkgs') writeScriptBin stdenv; + ocamlformat = builtins.getAttr ("ocamlformat_" + ocamlformat_version) pkgs; - duneScript = writeScriptBin "dune" '' - #!${stdenv.shell} - "$DUNE_SOURCE_ROOT"/_boot/dune.exe $@ - ''; - in + testNativeBuildInputs = + p: + [ ocamlformat ] + ++ (with p; [ + nodejs-slim + pkg-config + opam + ]); - pkgs'.mkShell { - shellHook = '' - export DUNE_SOURCE_ROOT=$PWD - ''; - inherit meta; - nativeBuildInputs = (testNativeBuildInputs pkgs') ++ docInputs ++ [ duneScript ]; - inputsFrom = [ pkgs'.ocamlPackages.dune_3 ]; - buildInputs = - testBuildInputs - ++ ( - with pkgs'.ocamlPackages; - [ - ctypes - cinaps - integers - lwt - mdx - menhir - merlin - ocaml-index - ocaml-lsp - odoc - patdiff - ppx_expect - re - spawn - uutf - ] - ++ (extraBuildInputs pkgs') - ); - inherit INSIDE_NIX; - }; - in - { - doc = pkgs.mkShell { - inherit INSIDE_NIX; - buildInputs = docInputs; - meta.description = '' - Provides a shell environment suitable for building the Dune - documentation website (e.g. `make doc`). - ''; - }; + makeDuneDevShell = + { + extraBuildInputs ? (_: [ ]), + meta ? null, + duneFromScope ? false, + }: + let + pkgs' = + if duneFromScope then + pkgs.extend ( + _: psuper: { + ocamlPackages = psuper.ocamlPackages.overrideScope ( + _: _: { + dune_3 = self.packages.${system}.default; + } + ); + } + ) + else + pkgs; - fmt = pkgs.mkShell { - inherit INSIDE_NIX; - nativeBuildInputs = [ ocamlformat ]; - # re shouldn't be needed. this is an issue with the fmt rules - inputsFrom = [ - pkgs.dune_3 - ]; - buildInputs = with pkgs.ocamlPackages; [ - re - spawn - uutf - findlib - ]; - meta.description = '' - Provides a shell environment suitable for formatting the Dune - codebase source code (e.g. with `make fmt`). + duneScript = pkgs.writeScriptBin "dune" '' + #!${pkgs.stdenv.shell} + "$DUNE_SOURCE_ROOT"/_boot/dune.exe $@ ''; - }; + in - slim = makeDuneDevShell { - meta.description = '' - Provides a minimal shell environment built purely from nixpkgs - that can run the testsuite (except the coq / melange tests). + pkgs.mkShell { + shellHook = '' + export DUNE_SOURCE_ROOT=$PWD ''; - }; - slim-melange = makeDuneDevShell { - extraBuildInputs = pkgs: [ - pkgs.ocamlPackages.melange - ]; - meta.description = '' - Provides a minimal shell environment built purely from nixpkgs - that can run the testsuite (except the coq tests). - ''; - }; - slim-opam = - with pkgs; - mkShell { - inherit INSIDE_NIX; - nativeBuildInputs = lib.remove pkgs.ocamlformat (testNativeBuildInputs pkgs); - buildInputs = lib.optionals stdenv.isDarwin [ - darwin.apple_sdk.frameworks.CoreServices - ]; - meta.description = '' - provides a shell with just `opam` and minimal (external) - dependencies to run the testsuite."; - ''; - }; - - coq = pkgs.mkShell { inherit INSIDE_NIX; - nativeBuildInputs = (testNativeBuildInputs pkgs); - # Coq requires OCaml 4.x + inherit meta; + nativeBuildInputs = [ duneScript ] ++ (testNativeBuildInputs pkgs'); inputsFrom = [ - pkgs.ocaml-ng.ocamlPackages_4_14.dune_3 - ]; - buildInputs = with pkgs; [ - ocaml-ng.ocamlPackages_4_14.re - ocaml-ng.ocamlPackages_4_14.spawn - ocaml-ng.ocamlPackages_4_14.uutf - coq_8_16_native - coq_8_16_native.ocamlPackages.findlib + pkgs'.ocamlPackages.dune_3 + self.devShells.${system}.doc ]; - meta.description = '' - Provides a minimal shell environment built purely from nixpkgs - that can build Dune and the Coq testsuite. - ''; + buildInputs = + (with pkgs; [ + file + mercurial + unzip + ]) + ++ (with pkgs'.ocamlPackages; [ + ctypes + cinaps + integers + lwt + mdx + menhir + merlin + ocaml-index + ocaml-lsp + odoc + patdiff + ppx_expect + re + spawn + uutf + ]) + ++ (extraBuildInputs pkgs') + ++ lib.optionals pkgs.stdenv.isLinux [ pkgs.strace ]; }; + in + { + doc = pkgs.mkShell { + inherit INSIDE_NIX; + packages = with pkgs.python3Packages; [ + sphinx-autobuild + furo + sphinx-copybutton + sphinx-design + myst-parser + ]; + meta.description = '' + Provides a shell environment suitable for building the Dune + documentation website (e.g. `make doc`). + ''; + }; - bootstrap-check = pkgs.mkShell { - inherit INSIDE_NIX; - buildInputs = with pkgs; [ - gnumake - ocaml-ng.ocamlPackages_4_02.ocaml - ]; - meta.description = '' - Provides a minimal shell environment with OCaml 4.02 in order - to test the bootstrapping script. - ''; - }; + fmt = pkgs.mkShell { + inherit INSIDE_NIX; + packages = [ + ocamlformat + ] + ++ (with pkgs.ocamlPackages; [ + re + spawn + uutf + findlib + ]); - bootstrap-check_4_08 = pkgs.mkShell { - inherit INSIDE_NIX; - buildInputs = with pkgs; [ - gnumake - ocaml-ng.ocamlPackages_4_08.ocaml - ]; - meta.description = '' - Provides a minimal shell environment with OCaml 4.08 in order - to test the bootstrapping script. - ''; - }; + # re shouldn't be needed. this is an issue with the fmt rules + inputsFrom = [ + pkgs.dune_3 + ]; - microbench = makeDuneDevShell { - extraBuildInputs = pkgs: [ - pkgs.ocamlPackages.core_bench - ]; - meta.description = '' - Provides a minimal shell environment that can build the - microbenchmarks. - ''; - }; + meta.description = '' + Provides a shell environment suitable for formatting the Dune + codebase source code (e.g. with `make fmt`). + ''; + }; - scope = makeDuneDevShell { - duneFromScope = true; - meta.description = '' - Provides a minimal shell environment built purely from nixpkgs - that replaces the Dune executable in the `ocamlPackages` scope by - the Dune binary built by from the repo. - ''; - }; - default = makeDuneDevShell { - extraBuildInputs = - pkgs: - (with pkgs; [ - # dev tools - ccls - # test dependencies - binaryen - curl - git - procps - which - ]) - ++ (with pkgs.ocamlPackages; [ - core_bench - js_of_ocaml - js_of_ocaml-compiler - ocaml-lsp - pkgs.ocamlPackages.melange - utop - wasm_of_ocaml-compiler - ]); - meta.description = '' - Provides a shell environment where `dune` is provided and built - using the source code in this repo. - ''; - }; + slim-opam = pkgs.mkShell { + inherit INSIDE_NIX; + nativeBuildInputs = lib.remove ocamlformat (testNativeBuildInputs pkgs); + meta.description = '' + provides a shell with just `opam` and minimal (external) + dependencies to run the testsuite."; + ''; + }; + + slim = makeDuneDevShell { + meta.description = '' + Provides a minimal shell environment built purely from nixpkgs + that can run the testsuite (except the coq / melange tests). + ''; + }; + + slim-melange = makeDuneDevShell { + extraBuildInputs = p: [ p.ocamlPackages.melange ]; + meta.description = '' + Provides a minimal shell environment built purely from nixpkgs + that can run the testsuite (except the coq tests). + ''; + }; + + coq = pkgs.mkShell { + inherit INSIDE_NIX; + nativeBuildInputs = (testNativeBuildInputs pkgs); + # Coq requires OCaml 4.x + inputsFrom = [ + pkgs.ocaml-ng.ocamlPackages_4_14.dune_3 + ]; + buildInputs = with pkgs; [ + ocaml-ng.ocamlPackages_4_14.re + ocaml-ng.ocamlPackages_4_14.spawn + ocaml-ng.ocamlPackages_4_14.uutf + coq_8_16_native + coq_8_16_native.ocamlPackages.findlib + ]; + meta.description = '' + Provides a minimal shell environment built purely from nixpkgs + that can build Dune and the Coq testsuite. + ''; + }; + + bootstrap-check = pkgs.mkShell { + inherit INSIDE_NIX; + buildInputs = with pkgs; [ + gnumake + ocaml-ng.ocamlPackages_4_02.ocaml + ]; + meta.description = '' + Provides a minimal shell environment with OCaml 4.02 in order + to test the bootstrapping script. + ''; }; - } - ); + + bootstrap-check_4_08 = pkgs.mkShell { + inherit INSIDE_NIX; + buildInputs = with pkgs; [ + gnumake + ocaml-ng.ocamlPackages_4_08.ocaml + ]; + meta.description = '' + Provides a minimal shell environment with OCaml 4.08 in order + to test the bootstrapping script. + ''; + }; + + microbench = makeDuneDevShell { + extraBuildInputs = p: [ + p.ocamlPackages.core_bench + ]; + meta.description = '' + Provides a minimal shell environment that can build the + microbenchmarks. + ''; + }; + + scope = makeDuneDevShell { + duneFromScope = true; + meta.description = '' + Provides a minimal shell environment built purely from nixpkgs + that replaces the Dune executable in the `ocamlPackages` scope by + the Dune binary built by from the repo. + ''; + }; + + default = makeDuneDevShell { + extraBuildInputs = + pkgs: + (with pkgs; [ + # dev tools + ccls + # test dependencies + binaryen + curl + git + procps + which + ]) + ++ (with pkgs.ocamlPackages; [ + core_bench + js_of_ocaml + js_of_ocaml-compiler + ocaml-lsp + pkgs.ocamlPackages.melange + utop + wasm_of_ocaml-compiler + ]); + meta.description = '' + Provides a shell environment where `dune` is provided and built + using the source code in this repo. + ''; + }; + } + ); + + }; }