about summary refs log tree commit diff
path: root/pkgs/top-level/static.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-06-11 18:42:26 +0000
committerJonathan Ringer <jonringer@users.noreply.github.com>2021-06-11 14:16:05 -0700
commitb0b5ef7286dca098f40f5075175105c3c0dfbe05 (patch)
tree072ca704392f8968f06410a1e996192cfd939586 /pkgs/top-level/static.nix
parent8f3ead7190b97ce1f0458766105832d5a6e02dcf (diff)
stdenv: introduce dontAddStaticConfigureFlags
With removeUnknownConfigureFlags, it's impossible to express a package
that needs --enable-static, but will not accept --disable-shared,
without overriding the result of removeUnknownConfigureFlags _again_
in pkgs/top-level/static.nix.

It would be much better (and more in line with the rest of Nixpkgs) if
we encoded changes needed for static builds in package definitions
themselves, rather than in an ever-expanding list in static.nix.  This
is especially true when doing it in static.nix is going to require
multiple overrides to express what could be expressed with stdenv
options.

So as a step in that direction, and to fix the problem described
above, here I replace removeUnknownConfigureFlags with a new stdenv
option, dontAddStaticConfigureFlags.  With this mechanism, a package
that needs one but not both of the flags just needs to set
dontAddStaticConfigureFlags and then set up configureFlags manually
based on stdenv.hostPlatform.isStatic.
Diffstat (limited to 'pkgs/top-level/static.nix')
-rw-r--r--pkgs/top-level/static.nix14
1 files changed, 3 insertions, 11 deletions
diff --git a/pkgs/top-level/static.nix b/pkgs/top-level/static.nix
index 32559c0e79906..0c9af250e876a 100644
--- a/pkgs/top-level/static.nix
+++ b/pkgs/top-level/static.nix
@@ -50,14 +50,10 @@ self: super: let
     # ++ optional (super.stdenv.hostPlatform.libc == "glibc") ((flip overrideInStdenv) [ self.stdenv.glibc.static ])
   ;
 
-  removeUnknownConfigureFlags = f: with self.lib;
-    remove "--disable-shared"
-    (remove "--enable-static" f);
-
   ocamlFixPackage = b:
     b.overrideAttrs (o: {
       configurePlatforms = [ ];
-      configureFlags = removeUnknownConfigureFlags (o.configureFlags or [ ]);
+      dontAddStaticConfigureFlags = true;
       buildInputs = o.buildInputs ++ o.nativeBuildInputs or [ ];
       propagatedNativeBuildInputs = o.propagatedBuildInputs or [ ];
     });
@@ -75,7 +71,8 @@ self: super: let
         preConfigure = ''
           configureFlagsArray+=("-cc" "$CC" "-as" "$AS" "-partialld" "$LD -r")
         '';
-        configureFlags = (removeUnknownConfigureFlags o.configureFlags) ++ [
+        dontAddStaticConfigureFlags = true;
+        configureFlags = [
           "--no-shared-libs"
           "-host ${o.stdenv.hostPlatform.config}"
           "-target ${o.stdenv.targetPlatform.config}"
@@ -124,11 +121,6 @@ in {
     if set ? overrideScope' then set.overrideScope' ocamlStaticAdapter else set
   ) super.ocaml-ng;
 
-  openssl = super.openssl_1_1.overrideAttrs (o: {
-    # OpenSSL doesn't like the `--enable-static` / `--disable-shared` flags.
-    configureFlags = (removeUnknownConfigureFlags o.configureFlags);
-  });
-
   perl = super.perl.override {
     # Don’t use new stdenv zlib because
     # it doesn’t like the --disable-shared flag