summary refs log tree commit diff
path: root/pkgs/top-level/static.nix
diff options
context:
space:
mode:
authorAlexander Bantyev <balsoft75@gmail.com>2019-11-20 18:46:18 +0300
committerAlexander Bantyev <balsoft75@gmail.com>2019-11-26 18:03:56 +0300
commit7263951cc87a9cd0bd377cef83c9241d0dffb665 (patch)
treedd05554ff57366482c246a0429e254f60076ac6b /pkgs/top-level/static.nix
parent9c9a0e9cab3b1fc6376e36114d0899c8ae372680 (diff)
downloadnixpkgs-7263951cc87a9cd0bd377cef83c9241d0dffb665.tar
nixpkgs-7263951cc87a9cd0bd377cef83c9241d0dffb665.tar.gz
nixpkgs-7263951cc87a9cd0bd377cef83c9241d0dffb665.tar.bz2
nixpkgs-7263951cc87a9cd0bd377cef83c9241d0dffb665.tar.lz
nixpkgs-7263951cc87a9cd0bd377cef83c9241d0dffb665.tar.xz
nixpkgs-7263951cc87a9cd0bd377cef83c9241d0dffb665.tar.zst
nixpkgs-7263951cc87a9cd0bd377cef83c9241d0dffb665.zip
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.
Diffstat (limited to 'pkgs/top-level/static.nix')
-rw-r--r--pkgs/top-level/static.nix37
1 files changed, 37 insertions, 0 deletions
diff --git a/pkgs/top-level/static.nix b/pkgs/top-level/static.nix
index bf75f700f77..98a75e2df87 100644
--- a/pkgs/top-level/static.nix
+++ b/pkgs/top-level/static.nix
@@ -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; };
 }