Fix the static build (#1534)
* openssl linking fix is required after all * remove Cabal override (obsoleted on new nixpkgs)
This commit is contained in:
+12
-8
@@ -26,12 +26,15 @@ let
|
||||
sha256 = nixpkgsVersion.tarballHash;
|
||||
};
|
||||
|
||||
allOverlays =
|
||||
import nix/overlays;
|
||||
|
||||
overlays =
|
||||
[
|
||||
(import nix/overlays/postgresql-default.nix)
|
||||
(import nix/overlays/postgresql-legacy.nix)
|
||||
(import nix/overlays/gitignore.nix)
|
||||
(import nix/overlays/haskell-packages { inherit compiler; })
|
||||
allOverlays.postgresql-default
|
||||
allOverlays.postgresql-legacy
|
||||
allOverlays.gitignore
|
||||
(allOverlays.haskell-packages { inherit compiler; })
|
||||
];
|
||||
|
||||
# Evaluated expression of the Nixpkgs repository.
|
||||
@@ -55,13 +58,14 @@ let
|
||||
drv =
|
||||
pkgs.haskell.packages."${compiler}".callCabal2nix name src { };
|
||||
|
||||
# Static set of Haskell Packages based on nh2/static-haskell-nix
|
||||
staticHaskellPackages =
|
||||
import nix/static-haskell-packages.nix { inherit nixpkgs compiler patches; };
|
||||
# Function that derives a fully static Haskell package based on
|
||||
# nh2/static-haskell-nix
|
||||
staticHaskellPackage =
|
||||
import nix/static-haskell-package.nix { inherit nixpkgs compiler patches allOverlays; };
|
||||
|
||||
# Static derivation for the PostgREST executable.
|
||||
drvStatic =
|
||||
staticHaskellPackages.callCabal2nix name src { };
|
||||
staticHaskellPackage name src;
|
||||
|
||||
lib =
|
||||
pkgs.haskell.lib;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Pinned version of Nixpkgs, generated with nixpkgs-upgrade.
|
||||
{
|
||||
date = "2020-05-19";
|
||||
rev = "0f5ce2fac0c726036ca69a5524c59a49e2973dd4";
|
||||
tarballHash = "0nkk492aa7pr0d30vv1aw192wc16wpa1j02925pldc09s9m9i0r3";
|
||||
date = "2020-05-21";
|
||||
rev = "6405edf2dca7f6faaa29266136dfa7f8f969b511";
|
||||
tarballHash = "069skn0ayxmhdlw1xcj92cij7wydkk2bndkcyk4vvhms16p9wj46";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
gitignore = import ./gitignore.nix;
|
||||
haskell-packages = import ./haskell-packages;
|
||||
postgresql-default = import ./postgresql-default.nix;
|
||||
postgresql-legacy = import ./postgresql-legacy.nix;
|
||||
}
|
||||
@@ -1,90 +0,0 @@
|
||||
{ mkDerivation
|
||||
, array
|
||||
, base
|
||||
, base-compat
|
||||
, base-orphans
|
||||
, binary
|
||||
, bytestring
|
||||
, containers
|
||||
, deepseq
|
||||
, Diff
|
||||
, directory
|
||||
, filepath
|
||||
, integer-logarithms
|
||||
, mtl
|
||||
, optparse-applicative
|
||||
, parsec
|
||||
, pretty
|
||||
, process
|
||||
, QuickCheck
|
||||
, stdenv
|
||||
, stm
|
||||
, tagged
|
||||
, tar
|
||||
, tasty
|
||||
, tasty-golden
|
||||
, tasty-hunit
|
||||
, tasty-quickcheck
|
||||
, temporary
|
||||
, text
|
||||
, time
|
||||
, transformers
|
||||
, tree-diff
|
||||
, unix
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "Cabal";
|
||||
version = "3.0.0.0";
|
||||
sha256 = "5143ec26d740c1a508c93a8860e64407e7546c29b9817db20ff1595c1968d287";
|
||||
setupHaskellDepends = [ mtl parsec ];
|
||||
libraryHaskellDepends = [
|
||||
array
|
||||
base
|
||||
binary
|
||||
bytestring
|
||||
containers
|
||||
deepseq
|
||||
directory
|
||||
filepath
|
||||
mtl
|
||||
parsec
|
||||
pretty
|
||||
process
|
||||
text
|
||||
time
|
||||
transformers
|
||||
unix
|
||||
];
|
||||
testHaskellDepends = [
|
||||
array
|
||||
base
|
||||
base-compat
|
||||
base-orphans
|
||||
binary
|
||||
bytestring
|
||||
containers
|
||||
deepseq
|
||||
Diff
|
||||
directory
|
||||
filepath
|
||||
integer-logarithms
|
||||
optparse-applicative
|
||||
pretty
|
||||
process
|
||||
QuickCheck
|
||||
stm
|
||||
tagged
|
||||
tar
|
||||
tasty
|
||||
tasty-golden
|
||||
tasty-hunit
|
||||
tasty-quickcheck
|
||||
temporary
|
||||
text
|
||||
tree-diff
|
||||
];
|
||||
doCheck = false;
|
||||
homepage = "http://www.haskell.org/cabal/";
|
||||
description = "A framework for packaging Haskell software";
|
||||
license = stdenv.lib.licenses.bsd3;
|
||||
}
|
||||
@@ -1,10 +1,7 @@
|
||||
{ compiler, static ? false }:
|
||||
{ compiler, extraOverrides ? (final: prev: { }) }:
|
||||
|
||||
self: super:
|
||||
let
|
||||
lib =
|
||||
self.haskell.lib;
|
||||
|
||||
overrides =
|
||||
final: prev:
|
||||
rec {
|
||||
@@ -15,16 +12,7 @@ let
|
||||
ver = "0.3.0";
|
||||
sha256 = "0iwh4wsjhb7pms88lw1afhdal9f86nrrkkvv65f9wxbd1b159n72";
|
||||
} { };
|
||||
|
||||
cabal2nix =
|
||||
if static then
|
||||
# cabal2nix depends on Cabal 3.0.*, while our pinned version of
|
||||
# Nixpkgs only provides 2.4 or 3.2. So we pinned 3.0.0.0 in
|
||||
# ./Cabal.nix
|
||||
prev.cabal2nix.overrideScope (self: super: { Cabal = self.callPackage ./Cabal.nix { }; })
|
||||
else
|
||||
prev.cabal2nix;
|
||||
};
|
||||
} // extraOverrides final prev;
|
||||
in
|
||||
{
|
||||
haskell =
|
||||
|
||||
@@ -26,4 +26,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;
|
||||
|
||||
# Fix how openssl is linked on static builds, see:
|
||||
# https://github.com/nh2/static-haskell-nix/pull/91
|
||||
static-haskell-nix-postgrest-openssl-linking-fix =
|
||||
./static-haskell-nix-postgrest-openssl-linking-fix.patch;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
From bb4c1e27e391eff01591fe60830ff68a9ada41ef Mon Sep 17 00:00:00 2001
|
||||
From: Remo <remo>
|
||||
Date: Wed, 22 Apr 2020 11:58:07 +0200
|
||||
Subject: [PATCH] Add postgrest libpq linking fix
|
||||
|
||||
---
|
||||
survey/default.nix | 5 +++++
|
||||
1 file changed, 5 insertions(+)
|
||||
|
||||
diff --git a/survey/default.nix b/survey/default.nix
|
||||
index b28606c..fd7cde7 100644
|
||||
--- a/survey/default.nix
|
||||
+++ b/survey/default.nix
|
||||
@@ -1052,6 +1052,11 @@ let
|
||||
super.squeal-postgresql
|
||||
[ final.openssl ]
|
||||
"--libs openssl";
|
||||
+ postgrest =
|
||||
+ addStaticLinkerFlagsWithPkgconfig
|
||||
+ super.postgrest
|
||||
+ [ final.openssl ]
|
||||
+ "--libs openssl";
|
||||
|
||||
xml-to-json =
|
||||
addStaticLinkerFlagsWithPkgconfig
|
||||
@@ -1,5 +1,7 @@
|
||||
# Derive a fully static set of Haskell packages based on musl instead of glibc.
|
||||
{ nixpkgs, compiler, patches }:
|
||||
# Derive a fully static Haskell package based on musl instead of glibc.
|
||||
{ nixpkgs, compiler, patches, allOverlays }:
|
||||
|
||||
name: src:
|
||||
let
|
||||
# The nh2/static-haskell-nix project does all the hard work for us.
|
||||
static-haskell-nix =
|
||||
@@ -11,6 +13,13 @@ let
|
||||
sha256 = "155spda2lww378bhx68w6dxwqd5y6s9kin3qbgl2m23r3vmk3m3w";
|
||||
};
|
||||
|
||||
patched-static-haskell-nix =
|
||||
patches.applyPatches "patched-static-haskell-nix"
|
||||
static-haskell-nix
|
||||
[
|
||||
patches.static-haskell-nix-postgrest-openssl-linking-fix
|
||||
];
|
||||
|
||||
patchedNixpkgs =
|
||||
patches.applyPatches "patched-nixpkgs"
|
||||
nixpkgs
|
||||
@@ -19,9 +28,20 @@ let
|
||||
patches.nixpkgs-openssl-split-runtime-dependencies-of-static-builds
|
||||
];
|
||||
|
||||
extraOverrides =
|
||||
final: prev:
|
||||
rec {
|
||||
# We need to add our package needs to the package set that we pass to
|
||||
# static-haskell-nix. Using callCabal2nix on the haskellPackages that
|
||||
# it returns would result in a dynamic build based on musl, and not the
|
||||
# fully static build that we want.
|
||||
"${name}" =
|
||||
prev.callCabal2nix name src { };
|
||||
};
|
||||
|
||||
overlays =
|
||||
[
|
||||
(import overlays/haskell-packages { inherit compiler; static = true; })
|
||||
(allOverlays.haskell-packages { inherit compiler extraOverrides; })
|
||||
];
|
||||
|
||||
# Apply our overlay to the given pkgs.
|
||||
@@ -37,6 +57,6 @@ let
|
||||
# The static-haskell-nix 'survey' derives a full static set of Haskell
|
||||
# packages, applying fixes where necessary.
|
||||
survey =
|
||||
import "${static-haskell-nix}/survey" { inherit normalPkgs compiler defaultCabalPackageVersionComingWithGhc; };
|
||||
import "${patched-static-haskell-nix}/survey" { inherit normalPkgs compiler defaultCabalPackageVersionComingWithGhc; };
|
||||
in
|
||||
survey.haskellPackages
|
||||
survey.haskellPackages."${name}"
|
||||
Reference in New Issue
Block a user