lol

ocamlPackages.janeStreet{,_0_9_0}: join the ocamlPackages fix point, allowing overriding to work as expected (#113696)

* ocamlPackages.janeStreet_0_9_0: join the ocamlPackages fix point

Internal dependencies in the janeStreet sets were always taken from the
own rec attribute set. While this is pretty simple and convenient, it
has the disadvantage that it doesn't play nice with overriding: If you'd
override an attribute in a janeStreet set previously, it would be
changed when referenced directly, but the other packages in that
janeStreet set still would use the original, non-overridden version of
the derivation.

This is easily fixed by passing janeStreet_0_9_0 itself from the fix
point of ocamlPackages and using it to reference the dependencies.

Example showing it now works as expected:

test-overlay.nix:

self: super: {
ocamlPackages = super.ocamlPackages.overrideScope (old: _: {
janeStreet_0_9_0 = old.janeStreet_0_9_0 // {
base = old.janeStreet_0_9_0.base.overrideAttrs (_: {
meta.broken = true;
});
};
});
}

nix-repl> (import ./. {
overlays = [ (import ./test-overlay.nix) ];
}).ocamlPackages.janeStreet_0_9_0.stdio

error: Package ‘ocaml4.10.0-base-0.9.4’ in /home/lukas/src/nix/nixpkgs/pkgs/development/ocaml-modules/janestreet/janePackage.nix:6 is marked as broken, refusing to evaluate.

a) To temporarily allow broken packages, you can use an environment variable
for a single invocation of the nix tools.

$ export NIXPKGS_ALLOW_BROKEN=1

b) For `nixos-rebuild` you can set
{ nixpkgs.config.allowBroken = true; }
in configuration.nix to override this.

c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
{ allowBroken = true; }
to ~/.config/nixpkgs/config.nix.

* ocamlPackages.janeStreet: take part in fixpoint for OCaml >= 4.08

This change makes overrides to the janeStreet set work as expected by
making the janeStreet set take part in the ocamlPackages fixpoint for
janeStreet 0.14, i. e. OCaml >= 4.08

* ocamlPackages.janeStreet: take part in fixpoint for OCaml == 4.07

This change makes overrides to the janeStreet set work as expected by
making the janeStreet set take part in the ocamlPackages fixpoint for
janeStreet 0.12, i. e. OCaml == 4.07

* ocamlPackages.janeStreet: take part in fixpoint for OCaml < 4.07

This change makes overrides to the janeStreet set work as expected by
making the janeStreet set take part in the ocamlPackages fixpoint for
janeStreet 0.11, i. e. OCaml < 4.07

* ocamlPackages.janeStreet: remove self - super distinction

Previously, we inherited non-janestreet ocaml dependencies from super
and janestreet dependencies from self which always was super.janeStreet.

This behavior is however not really what we want due to liftJaneStreet:
Users and other packages will use ocamlPackages.base etc. instead of
ocamlPackages.janeStreet.base and the like. Consequently they also would
override the top-level attributes which would mean that other janestreet
packages would not pick up on it however.

As a consequence however, overriding ocamlPackages.janeStreet.base
doesn't work. Since this was never possible, I don't think this is an
issue. It is probably a good idea to deprecate that set anyways and
printing a warning when it is used via trace.

janeStreet_0_9_0 is unchanged as the disticniton between self and super
makes sense for it.

Below is an example showing how overriding would work from an user's
perspective:

test-overlay.nix:

self: super: {
ocamlPackages = super.ocamlPackages.overrideScope (old: _: {
base = old.base.overrideAttrs (_: {
meta.broken = true;
});
});
}

nix-repl> (import ./. { overlays = [ (import ./test-overlay.nix) ]; }).ocamlPackages.
stdio
error: Package ‘ocaml4.10.0-base-0.14.0’ in /home/lukas/src/nix/nixpkgs/pkgs/development/ocaml-modules/janestreet/janePackage_0_14.nix:12 is marked as broken, refusing to evaluate.

a) To temporarily allow broken packages, you can use an environment variable
for a single invocation of the nix tools.

$ export NIXPKGS_ALLOW_BROKEN=1

b) For `nixos-rebuild` you can set
{ nixpkgs.config.allowBroken = true; }
in configuration.nix to override this.

c) For `nix-env`, `nix-build`, `nix-shell` or any other Nix command you can add
{ allowBroken = true; }
to ~/.config/nixpkgs/config.nix.

authored by

sterni and committed by
GitHub
2140791f 441f0c89

+55 -54
+4 -7
pkgs/development/ocaml-modules/janestreet/0.12.nix
··· 1 - { janePackage 2 - , ctypes 3 - , num 4 - , octavius 5 - , ppxlib 6 - , re 1 + { self 7 2 , openssl 8 3 }: 9 4 10 - rec { 5 + with self; 6 + 7 + { 11 8 12 9 ocaml-compiler-libs = janePackage { 13 10 pname = "ocaml-compiler-libs";
+4 -23
pkgs/development/ocaml-modules/janestreet/0.14.nix
··· 1 - { janePackage 2 - , alcotest 3 - , angstrom 4 - , angstrom-async 5 - , base64 6 - , cryptokit 7 - , ctypes 8 - , dune-configurator 9 - , faraday 10 - , inotify 11 - , js_of_ocaml 12 - , js_of_ocaml-ppx 13 - , lambdasoup 14 - , magic-mime 15 - , num 16 - , octavius 17 - , ppxlib 18 - , re 19 - , tyxml 20 - , uri-sexp 21 - , zarith 1 + { self 22 2 , openssl 23 - , ounit 24 3 , zstd 25 4 }: 26 5 27 - rec { 6 + with self; 7 + 8 + { 28 9 29 10 accessor = janePackage { 30 11 pname = "accessor";
+5 -5
pkgs/development/ocaml-modules/janestreet/default.nix
··· 1 - { janePackage, ocamlbuild, angstrom, cryptokit, ctypes, 2 - magic-mime, ocaml-migrate-parsetree, octavius, ounit, ppx_deriving, re, 3 - num, openssl 4 - , ppxlib 1 + { self 2 + , openssl 5 3 }: 6 4 7 - rec { 5 + with self; 6 + 7 + { 8 8 9 9 ocaml-compiler-libs = janePackage { 10 10 pname = "ocaml-compiler-libs";
+28 -4
pkgs/development/ocaml-modules/janestreet/old.nix
··· 1 - { stdenv, lib, janePackage, ocaml, ocamlbuild, cryptokit, ctypes, magic-mime, 2 - ocaml-migrate-parsetree, octavius, ounit, ppx_deriving, re, zarith, num, 3 - openssl }: 1 + { self 2 + , super 3 + , lib 4 + , stdenv 5 + , openssl 6 + }: 4 7 5 - rec { 8 + let 9 + inherit (super) 10 + janePackage 11 + ocaml 12 + ocamlbuild 13 + cryptokit 14 + ctypes 15 + magic-mime 16 + ocaml-migrate-parsetree 17 + octavius 18 + ounit 19 + ppx_deriving 20 + re 21 + zarith 22 + num 23 + ; 24 + 25 + in 26 + 27 + with self; 28 + 29 + { 6 30 7 31 # Jane Street packages, up to ppx_core 8 32
+14 -15
pkgs/top-level/ocaml-packages.nix
··· 1255 1255 janeStreet = 1256 1256 if lib.versionOlder "4.08" ocaml.version 1257 1257 then import ../development/ocaml-modules/janestreet/0.14.nix { 1258 - inherit alcotest angstrom angstrom-async base64 cryptokit ctypes 1259 - dune-configurator faraday inotify janePackage js_of_ocaml 1260 - js_of_ocaml-ppx lambdasoup magic-mime num octavius ounit 1261 - ppxlib re tyxml uri-sexp zarith; 1258 + inherit self; 1262 1259 inherit (pkgs) openssl zstd; 1263 1260 } 1264 1261 else if lib.versionOlder "4.07" ocaml.version 1265 1262 then import ../development/ocaml-modules/janestreet/0.12.nix { 1266 - inherit ctypes janePackage num octavius re; 1263 + self = self // { 1264 + ppxlib = ppxlib.override { version = "0.8.1"; }; 1265 + }; 1267 1266 inherit (pkgs) openssl; 1268 - ppxlib = ppxlib.override { version = "0.8.1"; }; 1269 1267 } 1270 1268 else import ../development/ocaml-modules/janestreet { 1271 - inherit janePackage ocamlbuild angstrom ctypes cryptokit; 1272 - inherit magic-mime num ocaml-migrate-parsetree octavius ounit; 1273 - inherit ppx_deriving re; 1269 + self = self // { 1270 + ppxlib = ppxlib.override { version = "0.8.1"; }; 1271 + }; 1274 1272 inherit (pkgs) openssl; 1275 - ppxlib = ppxlib.override { version = "0.8.1"; }; 1276 1273 }; 1277 1274 1278 1275 janeStreet_0_9_0 = import ../development/ocaml-modules/janestreet/old.nix { 1279 - janePackage = callPackage ../development/ocaml-modules/janestreet/janePackage.nix { defaultVersion = "0.9.0"; }; 1280 - inherit lib ocaml ocamlbuild ctypes cryptokit; 1281 - inherit magic-mime num ocaml-migrate-parsetree octavius ounit; 1282 - inherit ppx_deriving re zarith; 1283 - inherit (pkgs) stdenv openssl; 1276 + self = self.janeStreet_0_9_0; 1277 + super = self // { 1278 + janePackage = callPackage ../development/ocaml-modules/janestreet/janePackage.nix { 1279 + defaultVersion = "0.9.0"; 1280 + }; 1281 + }; 1282 + inherit (pkgs) stdenv lib openssl; 1284 1283 }; 1285 1284 1286 1285 js_build_tools = callPackage ../development/ocaml-modules/janestreet/js-build-tools.nix {};