ocaml: partially fix pkgsStatic.ocaml-ng

This commit adds a static adapter for ocaml packages and applies it to
pkgsStatic.ocaml-ng.

The adapter fixes build of ocaml itself with version <= 4.7 and also attempts
to fix builds of some packages.
This commit is contained in:
Alexander Bantyev 2019-11-20 18:46:18 +03:00
parent 9c9a0e9cab
commit 7263951cc8
No known key found for this signature in database
GPG key ID: E081FF12ADCB4AD5

View file

@ -51,7 +51,40 @@ self: super: let
enableStaticLibraries = true;
});
};
removeUnknownConfigureFlags = f: with self.lib;
remove "--disable-shared"
(remove "--enable-static" f);
ocamlFixPackage = b:
b.overrideAttrs (o: {
configurePlatforms = [ ];
configureFlags = removeUnknownConfigureFlags (o.configureFlags or [ ]);
buildInputs = o.buildInputs ++ o.nativeBuildInputs or [ ];
propagatedNativeBuildInputs = o.propagatedBuildInputs or [ ];
});
ocamlStaticAdapter = _: super:
self.lib.mapAttrs
(_: p: if p ? overrideAttrs then ocamlFixPackage p else p)
super
// {
lablgtk = null; # Currently xlibs cause infinite recursion
ocaml = ((super.ocaml.override { useX11 = false; }).overrideAttrs (o: {
configurePlatforms = [ ];
dontUpdateAutotoolsGnuConfigScripts = true;
})).overrideDerivation (o: {
preConfigure = ''
configureFlagsArray+=("-cc" "$CC" "-as" "$AS" "-partialld" "$LD -r")
'';
configureFlags = (removeUnknownConfigureFlags o.configureFlags) ++ [
"--no-shared-libs"
"-host ${o.stdenv.hostPlatform.config}"
"-target ${o.stdenv.targetPlatform.config}"
];
});
};
in {
stdenv = foldl (flip id) super.stdenv staticAdapters;
gcc49Stdenv = foldl (flip id) super.gcc49Stdenv staticAdapters;
@ -199,6 +232,10 @@ in {
};
};
};
ocaml-ng = self.lib.mapAttrs (_: set:
if set ? overrideScope' then set.overrideScope' ocamlStaticAdapter else set
) super.ocaml-ng;
python27 = super.python27.override { static = true; };
}