From b90444ed77dca93d45c5f5a7fbcb1c47b0d53269 Mon Sep 17 00:00:00 2001 From: Robert Vollmert Date: Fri, 10 Jun 2022 11:14:03 +0000 Subject: [PATCH] nix: hack static-haskell-nix for updated nixpkgs This patches static-haskell-nix to work for building postgrest with updated nixpkgs (from ~202203): - The ncurses 'enableStatic' argument doesn't exist anymore. We use the vanilla package instead, which seems to work fine. - The 'isExecutable' check fails with a strange error related to trying to override 'mkDerivation'. We patch 'isExecutable' to check explicitly whether we're building postgrest. ('isExecutable' is used to determine whether to build a package statically.) --- nix/patches/default.nix | 5 +++++ .../static-haskell-nix-isexecutable.patch | 18 ++++++++++++++++++ nix/patches/static-haskell-nix-ncurses.patch | 13 +++++++++++++ nix/static-haskell-package.nix | 3 ++- 4 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 nix/patches/static-haskell-nix-isexecutable.patch create mode 100644 nix/patches/static-haskell-nix-ncurses.patch diff --git a/nix/patches/default.nix b/nix/patches/default.nix index 9c9109cd8a..880a8cece9 100644 --- a/nix/patches/default.nix +++ b/nix/patches/default.nix @@ -21,4 +21,9 @@ # See: https://github.com/NixOS/nixpkgs/pull/87879 nixpkgs-openssl-split-runtime-dependencies-of-static-builds = ./nixpkgs-openssl-split-runtime-dependencies-of-static-builds.patch; + + static-haskell-nix-ncurses = + ./static-haskell-nix-ncurses.patch; + static-haskell-nix-isexecutable = + ./static-haskell-nix-isexecutable.patch; } diff --git a/nix/patches/static-haskell-nix-isexecutable.patch b/nix/patches/static-haskell-nix-isexecutable.patch new file mode 100644 index 0000000000..a35adc8853 --- /dev/null +++ b/nix/patches/static-haskell-nix-isexecutable.patch @@ -0,0 +1,18 @@ +diff --git a/survey/default.nix b/survey/default.nix +index 46d8066..5f7950b 100644 +--- a/survey/default.nix ++++ b/survey/default.nix +@@ -85,10 +85,9 @@ let + # Function that tells us if a given Haskell package has an executable. + # Pass only Haskell packages to this! + # Filter away other stuff with `isProperHaskellPackage` first. +- isExecutable = pkg: +- (pkgs.haskell.lib.overrideCabal pkg (drv: { +- passthru.isExecutable = drv.isExecutable or false; +- })).isExecutable; ++ # FIXME postgrest: original fails with our nixpkgs version, we ++ # just hardcode the check to work for a static postgrest build. ++ isExecutable = pkg: pkg.name == "postgrest"; + + # Turn e.g. `Cabal_1_2_3_4` into `1.2.3.4`. + cabalDottedVersion = diff --git a/nix/patches/static-haskell-nix-ncurses.patch b/nix/patches/static-haskell-nix-ncurses.patch new file mode 100644 index 0000000000..39c1327412 --- /dev/null +++ b/nix/patches/static-haskell-nix-ncurses.patch @@ -0,0 +1,13 @@ +diff --git a/survey/default.nix b/survey/default.nix +index 46d8066..a47f214 100644 +--- a/survey/default.nix ++++ b/survey/default.nix +@@ -1519,7 +1519,7 @@ let + [ + "--enable-executable-static" # requires `useFixedCabal` + # `enableShared` seems to be required to avoid `recompile with -fPIC` errors on some packages. +- "--extra-lib-dirs=${final.ncurses.override { enableStatic = true; enableShared = true; }}/lib" ++ "--extra-lib-dirs=${final.ncurses}/lib" + ] + # TODO Figure out why this and the below libffi are necessary. + # `working` and `workingStackageExecutables` don't seem to need that, diff --git a/nix/static-haskell-package.nix b/nix/static-haskell-package.nix index 57d5e6a1f5..1c353970ac 100644 --- a/nix/static-haskell-package.nix +++ b/nix/static-haskell-package.nix @@ -17,7 +17,8 @@ let patches.applyPatches "patched-static-haskell-nix" static-haskell-nix [ - # No patches currently required. + patches.static-haskell-nix-ncurses + patches.static-haskell-nix-isexecutable ]; patchedNixpkgs =