Bump nixpkgs and simplify/clean up nix setup (#1529)
* Refactor tests and fix README * fix linting hints from new hlint version * postgrest-style with new nixpkgs-fmt
This commit is contained in:
@@ -42,16 +42,18 @@ jobs:
|
||||
- checkout
|
||||
- run:
|
||||
name: Install linting and styling scripts
|
||||
command: nix-env -f default.nix -iA lint style
|
||||
command: nix-env -f default.nix -iA devtools
|
||||
- run:
|
||||
name: Run linter
|
||||
command: |
|
||||
echo 'Note: For checking this locally, use `make lint`. Or, if using `nix`, run `nix-shell --run postgrest-lint`'
|
||||
# Note: For checking this locally, use `make lint`. Or, if using
|
||||
# `nix`, run `nix-shell --run postgrest-lint`
|
||||
postgrest-lint
|
||||
- run:
|
||||
name: Run style check
|
||||
command: |
|
||||
echo 'Note: For checking this locally, use `make style`. Or, if using `nix`, run `nix-shell --run postgrest-style`'
|
||||
# 'Note: For checking this locally, use `make style`. Or, if using
|
||||
# `nix`, run `nix-shell --run postgrest-style`
|
||||
postgrest-style-check
|
||||
|
||||
build-test-9.4:
|
||||
|
||||
+29
-26
@@ -28,9 +28,10 @@ let
|
||||
|
||||
overlays =
|
||||
[
|
||||
(import nix/overlays/postgresql-default.nix)
|
||||
(import nix/overlays/postgresql-legacy.nix)
|
||||
(import nix/overlays/gitignore.nix)
|
||||
(import nix/overlays/haskell-packages)
|
||||
(import nix/overlays/haskell-packages { inherit compiler; })
|
||||
];
|
||||
|
||||
# Evaluated expression of the Nixpkgs repository.
|
||||
@@ -38,25 +39,29 @@ let
|
||||
import nixpkgs { inherit overlays; };
|
||||
|
||||
postgresqlVersions =
|
||||
[
|
||||
pkgs.postgresql_12
|
||||
pkgs.postgresql_11
|
||||
pkgs.postgresql_10
|
||||
pkgs.postgresql_9_6
|
||||
pkgs.postgresql_9_5
|
||||
pkgs.postgresql_9_4
|
||||
];
|
||||
{
|
||||
postgresql-12 = pkgs.postgresql_12;
|
||||
postgresql-11 = pkgs.postgresql_11;
|
||||
postgresql-10 = pkgs.postgresql_10;
|
||||
"postgresql-9.6" = pkgs.postgresql_9_6;
|
||||
"postgresql-9.5" = pkgs.postgresql_9_5;
|
||||
"postgresql-9.4" = pkgs.postgresql_9_4;
|
||||
};
|
||||
|
||||
patches =
|
||||
pkgs.callPackage nix/patches {};
|
||||
pkgs.callPackage nix/patches { };
|
||||
|
||||
# Base dynamic derivation for the PostgREST package.
|
||||
drv =
|
||||
lib.enableCabalFlag (pkgs.haskellPackages.callCabal2nix name src {}) "FailOnWarn";
|
||||
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; };
|
||||
|
||||
# Static derivation for the PostgREST executable.
|
||||
drvStatic =
|
||||
import nix/static { inherit nixpkgs name src compiler patches; };
|
||||
staticHaskellPackages.callCabal2nix name src { };
|
||||
|
||||
lib =
|
||||
pkgs.haskell.lib;
|
||||
@@ -67,15 +72,15 @@ rec {
|
||||
# Derivation for the PostgREST Haskell package, including the executable,
|
||||
# libraries and documentation. We disable running the test suite on Nix
|
||||
# builds, as they require a database to be set up.
|
||||
postgrestWithLib =
|
||||
lib.dontCheck drv;
|
||||
postgrestPackage =
|
||||
lib.dontCheck (lib.enableCabalFlag drv "FailOnWarn");
|
||||
|
||||
# Derivation for just the PostgREST binary, where we strip all dynamic
|
||||
# libraries and documentation, leaving only the executable. Note that the
|
||||
# executable is static with regards to Haskell libraries, but not system
|
||||
# libraries like glibc and libpq.
|
||||
postgrest =
|
||||
lib.justStaticExecutables postgrestWithLib;
|
||||
lib.justStaticExecutables postgrestPackage;
|
||||
|
||||
# Static executable.
|
||||
postgrestStatic =
|
||||
@@ -98,18 +103,16 @@ rec {
|
||||
|
||||
# Utility for updating the pinned version of Nixpkgs.
|
||||
nixpkgsUpgrade =
|
||||
pkgs.callPackage nix/nixpkgs-upgrade.nix {};
|
||||
pkgs.callPackage nix/nixpkgs-upgrade.nix { };
|
||||
|
||||
# Scripts for running tests.
|
||||
tests =
|
||||
pkgs.callPackage nix/tests.nix
|
||||
{
|
||||
inherit postgresqlVersions;
|
||||
postgrestBuildEnv = env;
|
||||
};
|
||||
pkgs.callPackage nix/tests.nix {
|
||||
inherit postgresqlVersions;
|
||||
postgrestBuildEnv = env;
|
||||
};
|
||||
|
||||
style =
|
||||
pkgs.callPackage nix/style.nix {};
|
||||
|
||||
lint =
|
||||
pkgs.callPackage nix/lint.nix {};
|
||||
# Development tools, including linting and styling scripts.
|
||||
devtools =
|
||||
pkgs.callPackage nix/devtools.nix { };
|
||||
}
|
||||
|
||||
+26
-11
@@ -27,6 +27,21 @@ build the `postgrest` attribute from the Nix expression it finds in our
|
||||
`default.nix` (see below for details). Nix will take care of getting the right
|
||||
GHC version and all the build dependencies.
|
||||
|
||||
We recommend that you use the PostgREST binary cache on
|
||||
[cachix](https://cachix.org/):
|
||||
|
||||
```
|
||||
# Install cachix:
|
||||
nix-env -iA cachix -f https://cachix.org/api/v1/install
|
||||
|
||||
# Set cachix up to use the PostgREST binary cache:
|
||||
cachix use postgrest
|
||||
|
||||
```
|
||||
|
||||
Without cachix, your machine will have to rebuild all the dependencies that are
|
||||
derived on top of `Musl` for the static builds, which can take a very long time.
|
||||
|
||||
## Developing
|
||||
|
||||
A development environment for PostgREST is available with `nix-shell`. The
|
||||
@@ -44,21 +59,21 @@ dependencies from the same pinned Nixpkgs version that the Nix builds use.
|
||||
|
||||
## Aside: Working with `nix-shell` and the PostgREST utility scripts
|
||||
|
||||
The PostgREST utilities available in `nix-shell` all have names that begin
|
||||
with `postgrest-`, so you can use tab completion (`postgrest-<tab>`) in
|
||||
`nix-shell` to see all that are available:
|
||||
The PostgREST utilities available in `nix-shell` all have names that begin with
|
||||
`postgrest-`, so you can use tab completion (typing `postgrest-` and pressing
|
||||
`<tab>`) in `nix-shell` to see all that are available:
|
||||
|
||||
```
|
||||
# Note: The utilities listed here might not be up to date.
|
||||
[nix-shell:~/Projects/postgrest]$ postgrest-
|
||||
postgrest-lint postgrest-test-spec-postgresql-10.12
|
||||
postgrest-style postgrest-test-spec-postgresql-11.7
|
||||
postgrest-style-check postgrest-test-spec-postgresql-12.2
|
||||
postgrest-test-all postgrest-test-spec-postgresql-9.4.24
|
||||
postgrest-test-spec postgrest-test-spec-postgresql-9.5.21
|
||||
postgrest-test-spec-all postgrest-test-spec-postgresql-9.6.17
|
||||
[nix-shell]$ postgrest-<tab>
|
||||
postgrest-lint postgrest-test-spec-postgresql-10
|
||||
postgrest-style postgrest-test-spec-postgresql-11
|
||||
postgrest-style-check postgrest-test-spec-postgresql-12
|
||||
postgrest-test-all postgrest-test-spec-postgresql-9.4
|
||||
postgrest-test-spec postgrest-test-spec-postgresql-9.5
|
||||
postgrest-test-spec-all postgrest-test-spec-postgresql-9.6
|
||||
|
||||
[nix-shell:~/Projects/postgrest]$
|
||||
[nix-shell]$
|
||||
|
||||
```
|
||||
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
{ writeShellScriptBin
|
||||
, buildEnv
|
||||
, git
|
||||
, hlint
|
||||
, nixpkgs-fmt
|
||||
, silver-searcher
|
||||
, stylish-haskell
|
||||
, buildEnv
|
||||
}:
|
||||
let
|
||||
style =
|
||||
@@ -30,8 +31,19 @@ let
|
||||
|
||||
${git}/bin/git diff-index --exit-code HEAD -- '*.hs' '*.lhs' '*.nix'
|
||||
'';
|
||||
lint =
|
||||
writeShellScriptBin "postgrest-lint"
|
||||
''
|
||||
set -euo pipefail
|
||||
|
||||
rootdir="$(${git}/bin/git rev-parse --show-toplevel)"
|
||||
|
||||
# Lint Haskell files
|
||||
${silver-searcher}/bin/ag -l -g '\.l?hs$' "$rootdir" \
|
||||
| xargs ${hlint}/bin/hlint -X QuasiQuotes -X NoPatternSynonyms
|
||||
'';
|
||||
in
|
||||
buildEnv {
|
||||
name = "postgrest-style";
|
||||
paths = [ style check ];
|
||||
name = "postgrest-devtools";
|
||||
paths = [ style check lint ];
|
||||
}
|
||||
+36
-36
@@ -2,48 +2,48 @@
|
||||
let
|
||||
image =
|
||||
tag:
|
||||
dockerTools.buildImage {
|
||||
inherit tag;
|
||||
dockerTools.buildImage {
|
||||
inherit tag;
|
||||
|
||||
name = "postgrest/postgrest";
|
||||
contents = postgrest;
|
||||
name = "postgrest/postgrest";
|
||||
contents = postgrest;
|
||||
|
||||
# Set the current time as the image creation date. This makes the build
|
||||
# non-reproducible, but that should not be an issue for us.
|
||||
created = "now";
|
||||
# Set the current time as the image creation date. This makes the build
|
||||
# non-reproducible, but that should not be an issue for us.
|
||||
created = "now";
|
||||
|
||||
extraCommands =
|
||||
''
|
||||
mkdir etc
|
||||
cp ${./postgrest.conf} etc/postgrest.conf
|
||||
'';
|
||||
extraCommands =
|
||||
''
|
||||
mkdir etc
|
||||
cp ${./postgrest.conf} etc/postgrest.conf
|
||||
'';
|
||||
|
||||
config = {
|
||||
Cmd = [ "/bin/postgrest" "/etc/postgrest.conf" ];
|
||||
Env = [
|
||||
"PGRST_DB_URI=postgresql://?user=postgres"
|
||||
"PGRST_DB_SCHEMA=public"
|
||||
"PGRST_DB_ANON_ROLE="
|
||||
"PGRST_DB_POOL=100"
|
||||
"PGRST_DB_EXTRA_SEARCH_PATH=public"
|
||||
"PGRST_SERVER_HOST=*4"
|
||||
"PGRST_SERVER_PORT=3000"
|
||||
"PGRST_OPENAPI_SERVER_PROXY_URI="
|
||||
"PGRST_JWT_SECRET="
|
||||
"PGRST_SECRET_IS_BASE64=false"
|
||||
"PGRST_JWT_AUD="
|
||||
"PGRST_MAX_ROWS="
|
||||
"PGRST_PRE_REQUEST="
|
||||
"PGRST_ROLE_CLAIM_KEY=.role"
|
||||
"PGRST_ROOT_SPEC="
|
||||
"PGRST_RAW_MEDIA_TYPES="
|
||||
];
|
||||
User = "1000";
|
||||
ExposedPorts = {
|
||||
"3000/tcp" = {};
|
||||
};
|
||||
config = {
|
||||
Cmd = [ "/bin/postgrest" "/etc/postgrest.conf" ];
|
||||
Env = [
|
||||
"PGRST_DB_URI=postgresql://?user=postgres"
|
||||
"PGRST_DB_SCHEMA=public"
|
||||
"PGRST_DB_ANON_ROLE="
|
||||
"PGRST_DB_POOL=100"
|
||||
"PGRST_DB_EXTRA_SEARCH_PATH=public"
|
||||
"PGRST_SERVER_HOST=*4"
|
||||
"PGRST_SERVER_PORT=3000"
|
||||
"PGRST_OPENAPI_SERVER_PROXY_URI="
|
||||
"PGRST_JWT_SECRET="
|
||||
"PGRST_SECRET_IS_BASE64=false"
|
||||
"PGRST_JWT_AUD="
|
||||
"PGRST_MAX_ROWS="
|
||||
"PGRST_PRE_REQUEST="
|
||||
"PGRST_ROLE_CLAIM_KEY=.role"
|
||||
"PGRST_ROOT_SPEC="
|
||||
"PGRST_RAW_MEDIA_TYPES="
|
||||
];
|
||||
User = "1000";
|
||||
ExposedPorts = {
|
||||
"3000/tcp" = { };
|
||||
};
|
||||
};
|
||||
};
|
||||
in
|
||||
rec {
|
||||
imageLatest =
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
{ writeShellScriptBin, git, silver-searcher, hlint }:
|
||||
|
||||
writeShellScriptBin "postgrest-lint"
|
||||
''
|
||||
set -euo pipefail
|
||||
|
||||
rootdir="$(${git}/bin/git rev-parse --show-toplevel)"
|
||||
|
||||
# Lint Haskell files
|
||||
${silver-searcher}/bin/ag -l -g '\.l?hs$' "$rootdir" \
|
||||
| xargs ${hlint}/bin/hlint -X QuasiQuotes -X NoPatternSynonyms
|
||||
''
|
||||
@@ -21,7 +21,8 @@ let
|
||||
tarballUrlBase =
|
||||
https://github.com/nixos/nixpkgs/archive/;
|
||||
in
|
||||
writeShellScriptBin name
|
||||
writeShellScriptBin
|
||||
name
|
||||
''
|
||||
set -euo pipefail
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Pinned version of Nixpkgs, generated with nixpkgs-upgrade.
|
||||
{
|
||||
date = "2020-04-19";
|
||||
rev = "10100a97c8964e82b30f180fda41ade8e6f69e41";
|
||||
tarballHash = "011f36kr3c1ria7rag7px26bh73d1b0xpqadd149bysf4hg17rln";
|
||||
date = "2020-05-19";
|
||||
rev = "0f5ce2fac0c726036ca69a5524c59a49e2973dd4";
|
||||
tarballHash = "0nkk492aa7pr0d30vv1aw192wc16wpa1j02925pldc09s9m9i0r3";
|
||||
}
|
||||
|
||||
@@ -15,5 +15,6 @@ self: super:
|
||||
rev = "2ced4519f865341adcb143c5d668f955a2cb997f";
|
||||
sha256 = "sha256:0fc5bgv9syfcblp23y05kkfnpgh3gssz6vn24frs8dzw39algk2z";
|
||||
};
|
||||
in (super.callPackage gitignoreSrc {}).gitignoreSource;
|
||||
in
|
||||
(super.callPackage gitignoreSrc { }).gitignoreSource;
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@ The `.nix` files in this directory pin specific versions of Haskell packages
|
||||
from Hackage. They were generated with `cabal2nix`, e.g.:
|
||||
|
||||
```bash
|
||||
cabal2nix cabal://protolude > protolude.nix
|
||||
cabal2nix cabal://Cabal-3.0.0.0 > Cabal.nix
|
||||
|
||||
```
|
||||
|
||||
Those overrides might become obsolete as the pinned versions are adopted into
|
||||
our pinned version of nixpkgs.
|
||||
Those overrides will likely become obsolete as the pinned versions are adopted
|
||||
into our pinned version of nixpkgs.
|
||||
|
||||
@@ -1,11 +1,37 @@
|
||||
self: super:
|
||||
{ compiler, static ? false }:
|
||||
|
||||
self: super:
|
||||
let
|
||||
lib =
|
||||
self.haskell.lib;
|
||||
|
||||
overrides =
|
||||
final: prev:
|
||||
rec {
|
||||
protolude =
|
||||
prev.callHackageDirect
|
||||
{
|
||||
pkg = "protolude";
|
||||
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;
|
||||
};
|
||||
in
|
||||
{
|
||||
haskellPackages =
|
||||
super.haskellPackages.override {
|
||||
overrides =
|
||||
final: prev: rec {
|
||||
protolude = prev.callPackage ./protolude.nix {};
|
||||
};
|
||||
haskell =
|
||||
super.haskell // {
|
||||
packages = super.haskell.packages // {
|
||||
"${compiler}" =
|
||||
super.haskell.packages."${compiler}".override { inherit overrides; };
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
{ mkDerivation
|
||||
, array
|
||||
, async
|
||||
, base
|
||||
, bytestring
|
||||
, containers
|
||||
, deepseq
|
||||
, ghc-prim
|
||||
, hashable
|
||||
, mtl
|
||||
, mtl-compat
|
||||
, stdenv
|
||||
, stm
|
||||
, text
|
||||
, transformers
|
||||
, transformers-compat
|
||||
}:
|
||||
mkDerivation {
|
||||
pname = "protolude";
|
||||
version = "0.3.0";
|
||||
sha256 = "4083385a9e03fab9201f63ce198b9ced3fbc1c50d6d42574db5e36c757bedcac";
|
||||
isLibrary = true;
|
||||
isExecutable = true;
|
||||
libraryHaskellDepends = [
|
||||
array
|
||||
async
|
||||
base
|
||||
bytestring
|
||||
containers
|
||||
deepseq
|
||||
ghc-prim
|
||||
hashable
|
||||
mtl
|
||||
mtl-compat
|
||||
stm
|
||||
text
|
||||
transformers
|
||||
transformers-compat
|
||||
];
|
||||
homepage = "https://github.com/sdiehl/protolude";
|
||||
description = "A small prelude";
|
||||
license = stdenv.lib.licenses.mit;
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
self: super:
|
||||
# Overlay that sets the default version of PostgreSQL.
|
||||
{
|
||||
postgresql = super.postgresql_12;
|
||||
}
|
||||
@@ -16,5 +16,5 @@ self: super:
|
||||
sha256 = tarballHash;
|
||||
};
|
||||
in
|
||||
(import pinnedPkgs {}).pkgs.postgresql_9_4;
|
||||
(import pinnedPkgs { }).pkgs.postgresql_9_4;
|
||||
}
|
||||
|
||||
+18
-17
@@ -1,28 +1,29 @@
|
||||
{ runCommand }:
|
||||
|
||||
{
|
||||
# Apply patches to a directory.
|
||||
applyPatches =
|
||||
name: path: patches:
|
||||
runCommand name { inherit patches; }
|
||||
''
|
||||
set -eou pipefail
|
||||
name: src: patches:
|
||||
runCommand
|
||||
name
|
||||
{ inherit src patches; }
|
||||
''
|
||||
set -eou pipefail
|
||||
|
||||
cp -r ${path} $out
|
||||
chmod -R u+w $out
|
||||
cp -r $src $out
|
||||
chmod -R u+w $out
|
||||
|
||||
for patch in $patches; do
|
||||
echo "Applying patch $patch"
|
||||
patch -d "$out" -p1 < "$patch"
|
||||
done
|
||||
'';
|
||||
|
||||
static-haskell-nix-postgrest-libpq =
|
||||
./static-haskell-nix-postgrest-libpq.patch;
|
||||
for patch in $patches; do
|
||||
echo "Applying patch $patch"
|
||||
patch -d "$out" -p1 < "$patch"
|
||||
done
|
||||
'';
|
||||
|
||||
# Patch is required for static builds on GHC 8.8.3, see:
|
||||
# https://github.com/NixOS/nixpkgs/issues/85924
|
||||
nixpkgs-revert-ghc-bootstrap =
|
||||
./nixpkgs-revert-ghc-bootstrap.patch;
|
||||
|
||||
openssl-split-runtime-dependencies-of-static-builds =
|
||||
./openssl-split-runtime-dependencies-of-static-builds.patch;
|
||||
# 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;
|
||||
}
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
From 93cc144b215654ca9cb0d2bcb58bb8922895ccab Mon Sep 17 00:00:00 2001
|
||||
From ba48fc5bf1db795e31778fd67a9d72f28437d6c3 Mon Sep 17 00:00:00 2001
|
||||
From: Remo <remo>
|
||||
Date: Sat, 25 Apr 2020 17:31:55 +0200
|
||||
Date: Tue, 19 May 2020 13:07:54 +0200
|
||||
Subject: [PATCH] Revert "ghc: 8.6.3-binary -> 8.6.5-binary"
|
||||
|
||||
This reverts commit 3c7ef6bcd85e3e133ac6f2ab5e238934d56d902e.
|
||||
---
|
||||
.../{8.6.5-binary.nix => 8.6.3-binary.nix} | 13 ++++++------
|
||||
pkgs/top-level/haskell-packages.nix | 20 +++++++++----------
|
||||
2 files changed, 16 insertions(+), 17 deletions(-)
|
||||
.../ghc/{8.6.5-binary.nix => 8.6.3-binary.nix} | 13 ++++++-------
|
||||
pkgs/top-level/haskell-packages.nix | 16 ++++++++--------
|
||||
2 files changed, 14 insertions(+), 15 deletions(-)
|
||||
rename pkgs/development/compilers/ghc/{8.6.5-binary.nix => 8.6.3-binary.nix} (95%)
|
||||
|
||||
diff --git a/pkgs/development/compilers/ghc/8.6.5-binary.nix b/pkgs/development/compilers/ghc/8.6.3-binary.nix
|
||||
similarity index 95%
|
||||
rename from pkgs/development/compilers/ghc/8.6.5-binary.nix
|
||||
rename to pkgs/development/compilers/ghc/8.6.3-binary.nix
|
||||
index 97793d912895..9e0fd12b96cf 100644
|
||||
index 97793d91289..9e0fd12b96c 100644
|
||||
--- a/pkgs/development/compilers/ghc/8.6.5-binary.nix
|
||||
+++ b/pkgs/development/compilers/ghc/8.6.3-binary.nix
|
||||
@@ -27,19 +27,18 @@ let
|
||||
@@ -52,7 +52,7 @@ index 97793d912895..9e0fd12b96cf 100644
|
||||
}.${stdenv.hostPlatform.system}
|
||||
or (throw "cannot bootstrap GHC on this platform"));
|
||||
diff --git a/pkgs/top-level/haskell-packages.nix b/pkgs/top-level/haskell-packages.nix
|
||||
index aa7ef02a3886..712a98e147e0 100644
|
||||
index 13c5b721301..1bce80e5774 100644
|
||||
--- a/pkgs/top-level/haskell-packages.nix
|
||||
+++ b/pkgs/top-level/haskell-packages.nix
|
||||
@@ -4,7 +4,7 @@ let
|
||||
@@ -73,16 +73,9 @@ index aa7ef02a3886..712a98e147e0 100644
|
||||
|
||||
ghc844 = callPackage ../development/compilers/ghc/8.4.4.nix {
|
||||
bootPkgs = packages.ghc822Binary;
|
||||
@@ -57,31 +57,31 @@ in {
|
||||
@@ -57,19 +57,19 @@ in {
|
||||
llvmPackages = pkgs.llvmPackages_6;
|
||||
};
|
||||
ghc881 = callPackage ../development/compilers/ghc/8.8.1.nix {
|
||||
- bootPkgs = packages.ghc865Binary;
|
||||
+ bootPkgs = packages.ghc863Binary;
|
||||
inherit (buildPackages.python3Packages) sphinx;
|
||||
buildLlvmPackages = buildPackages.llvmPackages_7;
|
||||
llvmPackages = pkgs.llvmPackages_7;
|
||||
};
|
||||
ghc882 = callPackage ../development/compilers/ghc/8.8.2.nix {
|
||||
- bootPkgs = packages.ghc865Binary;
|
||||
+ bootPkgs = packages.ghc863Binary;
|
||||
@@ -103,14 +96,7 @@ index aa7ef02a3886..712a98e147e0 100644
|
||||
inherit (buildPackages.python3Packages) sphinx;
|
||||
buildLlvmPackages = buildPackages.llvmPackages_9;
|
||||
llvmPackages = pkgs.llvmPackages_9;
|
||||
};
|
||||
ghcHEAD = callPackage ../development/compilers/ghc/head.nix {
|
||||
- bootPkgs = packages.ghc883; # no binary yet
|
||||
+ bootPkgs = packages.ghc863Binary;
|
||||
inherit (buildPackages.python3Packages) sphinx;
|
||||
buildLlvmPackages = buildPackages.llvmPackages_9;
|
||||
llvmPackages = pkgs.llvmPackages_9;
|
||||
@@ -118,9 +118,9 @@ in {
|
||||
@@ -112,9 +112,9 @@ in {
|
||||
compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-8.2.x.nix { };
|
||||
packageSetConfig = bootstrapPackageSet;
|
||||
};
|
||||
@@ -123,3 +109,6 @@ index aa7ef02a3886..712a98e147e0 100644
|
||||
compilerConfig = callPackage ../development/haskell-modules/configuration-ghc-8.6.x.nix { };
|
||||
packageSetConfig = bootstrapPackageSet;
|
||||
};
|
||||
--
|
||||
2.25.1
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
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
|
||||
@@ -0,0 +1,42 @@
|
||||
# Derive a fully static set of Haskell packages based on musl instead of glibc.
|
||||
{ nixpkgs, compiler, patches }:
|
||||
let
|
||||
# The nh2/static-haskell-nix project does all the hard work for us.
|
||||
static-haskell-nix =
|
||||
let
|
||||
rev = "749707fc90b781c3e653e67917a7d571fe82ae7b";
|
||||
in
|
||||
builtins.fetchTarball {
|
||||
url = "https://github.com/nh2/static-haskell-nix/archive/${rev}.tar.gz";
|
||||
sha256 = "155spda2lww378bhx68w6dxwqd5y6s9kin3qbgl2m23r3vmk3m3w";
|
||||
};
|
||||
|
||||
patchedNixpkgs =
|
||||
patches.applyPatches "patched-nixpkgs"
|
||||
nixpkgs
|
||||
[
|
||||
patches.nixpkgs-revert-ghc-bootstrap
|
||||
patches.nixpkgs-openssl-split-runtime-dependencies-of-static-builds
|
||||
];
|
||||
|
||||
overlays =
|
||||
[
|
||||
(import overlays/haskell-packages { inherit compiler; static = true; })
|
||||
];
|
||||
|
||||
# Apply our overlay to the given pkgs.
|
||||
normalPkgs =
|
||||
import patchedNixpkgs { inherit overlays; };
|
||||
|
||||
# Each version of GHC needs a specific version of Cabal.
|
||||
defaultCabalPackageVersionComingWithGhc =
|
||||
{
|
||||
ghc883 = "Cabal_3_2_0_0";
|
||||
}."${compiler}";
|
||||
|
||||
# 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; };
|
||||
in
|
||||
survey.haskellPackages
|
||||
@@ -1,90 +0,0 @@
|
||||
# Turn a Haskell source package (given its name and source) into a derivation
|
||||
# for a fully static executable.
|
||||
{ nixpkgs, compiler, name, src, patches }:
|
||||
let
|
||||
# The nh2/static-haskell-nix project does all the hard work for us for
|
||||
# building static Haskell executables. We apply a patch for PostgREST below
|
||||
# until the respective pull request is merged. See:
|
||||
# https://github.com/nh2/static-haskell-nix/pull/91
|
||||
# statix-haskell-nix builds everything based on Musl instead of glibc, so
|
||||
# there will be a _lot_ to rebuild if you don't use a binary cache.
|
||||
static-haskell-nix =
|
||||
let
|
||||
rev = "749707fc90b781c3e653e67917a7d571fe82ae7b";
|
||||
in
|
||||
builtins.fetchTarball {
|
||||
url = "https://github.com/nh2/static-haskell-nix/archive/${rev}.tar.gz";
|
||||
sha256 = "155spda2lww378bhx68w6dxwqd5y6s9kin3qbgl2m23r3vmk3m3w";
|
||||
};
|
||||
|
||||
patched-static-haskell-nix =
|
||||
patches.applyPatches "patched-static-haskell-nix" static-haskell-nix
|
||||
[
|
||||
patches.static-haskell-nix-postgrest-libpq
|
||||
];
|
||||
|
||||
haskellPackagesOverrides =
|
||||
lib: final: prev:
|
||||
{
|
||||
# Add our source package.
|
||||
"${name}" = prev.callCabal2nix name src {};
|
||||
|
||||
# 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
|
||||
cabal2nix =
|
||||
prev.cabal2nix.overrideScope
|
||||
(self: super: { Cabal = self.callPackage ./Cabal.nix {}; });
|
||||
|
||||
# Pinned version of protolude.
|
||||
protolude =
|
||||
prev.callPackage ../overlays/haskell-packages/protolude.nix {};
|
||||
|
||||
# The tests for the packages below took a long time on static
|
||||
# builds, so we disable them for now - to be investigated.
|
||||
happy = lib.dontCheck prev.happy;
|
||||
};
|
||||
|
||||
# This overlay adds our source package and applies adjustments to the
|
||||
# derivation of other packages that it depends on. The overlay applies to
|
||||
# Haskell packages for the given compiler, which we will later use
|
||||
# with the static-haskell-nix survey.
|
||||
overlay =
|
||||
self: super:
|
||||
# Override the set of Haskell packages at
|
||||
# pkgs.haskell.packages."${compiler}".
|
||||
{
|
||||
haskell = super.haskell // {
|
||||
packages = super.haskell.packages // {
|
||||
"${compiler}" =
|
||||
super.haskell.packages."${compiler}".override
|
||||
{ overrides = haskellPackagesOverrides self.haskell.lib; };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
patchedNixpkgs =
|
||||
patches.applyPatches "patched-nixpkgs" nixpkgs
|
||||
[
|
||||
patches.nixpkgs-revert-ghc-bootstrap
|
||||
patches.openssl-split-runtime-dependencies-of-static-builds
|
||||
];
|
||||
|
||||
# Apply our overlay to the given pkgs.
|
||||
normalPkgs =
|
||||
(import patchedNixpkgs {}).appendOverlays [ overlay ];
|
||||
|
||||
# Each version of GHC needs a specific version of Cabal.
|
||||
defaultCabalPackageVersionComingWithGhc =
|
||||
{
|
||||
ghc883 = "Cabal_3_2_0_0";
|
||||
}."${compiler}";
|
||||
|
||||
# Let the static-haskell-nix project do the hard work of deriving a set of
|
||||
# fully static Haskell executables, including one for the our source package
|
||||
# that we added through the overlay.
|
||||
survey =
|
||||
import "${patched-static-haskell-nix}/survey"
|
||||
{ inherit normalPkgs compiler defaultCabalPackageVersionComingWithGhc; };
|
||||
in
|
||||
# Return the fully static derivation of our source package.
|
||||
survey.haskellPackages."${name}"
|
||||
+31
-33
@@ -5,6 +5,7 @@
|
||||
, git
|
||||
, lib
|
||||
, postgrestBuildEnv
|
||||
, postgresql
|
||||
, postgresqlVersions
|
||||
, runtimeShell
|
||||
, writeShellScript
|
||||
@@ -14,53 +15,50 @@ let
|
||||
# Wrap the `test/with_tmp_db` script with the required dependencies from Nix.
|
||||
withTmpDb =
|
||||
postgresql:
|
||||
writeShellScript "postgrest-test-${postgresql.name}"
|
||||
''
|
||||
set -euo pipefail
|
||||
writeShellScript "postgrest-test-${postgresql.name}"
|
||||
''
|
||||
set -euo pipefail
|
||||
|
||||
export PATH=${postgresql}/bin:${git}/bin:${runtimeShell}/bin:"$PATH"
|
||||
export PATH=${postgresql}/bin:${git}/bin:${runtimeShell}/bin:"$PATH"
|
||||
|
||||
exec ${../test/with_tmp_db} "$@"
|
||||
'';
|
||||
exec ${../test/with_tmp_db} "$@"
|
||||
'';
|
||||
|
||||
# Script to run the Haskell test suite against a specific version of
|
||||
# PostgreSQL.
|
||||
testSpec =
|
||||
name: postgresql:
|
||||
writeShellScriptBin name
|
||||
''
|
||||
set -euo pipefail
|
||||
writeShellScriptBin
|
||||
name
|
||||
''
|
||||
set -euo pipefail
|
||||
|
||||
cat << EOF
|
||||
cat << EOF
|
||||
|
||||
Running spec against ${postgresql.name}...
|
||||
Running spec against ${postgresql.name}...
|
||||
|
||||
EOF
|
||||
EOF
|
||||
|
||||
# TODO: Make this work outside nix-shell when installed with nix-env.
|
||||
# Probably using postgrestBuildEnv somehow?
|
||||
${withTmpDb postgresql} ${cabal-install}/bin/cabal v2-test \
|
||||
--test-show-detail=direct
|
||||
# TODO: Make this work outside nix-shell when installed with nix-env.
|
||||
# Probably using postgrestBuildEnv somehow?
|
||||
${withTmpDb postgresql} ${cabal-install}/bin/cabal v2-test \
|
||||
--test-show-detail=direct
|
||||
|
||||
cat << EOF
|
||||
cat << EOF
|
||||
|
||||
Done running spec against ${postgresql.name}.
|
||||
Done running spec against ${postgresql.name}.
|
||||
|
||||
EOF
|
||||
'';
|
||||
|
||||
# The PostgreSQL version that we run the tests against by default.
|
||||
defaultPostgresql =
|
||||
builtins.head postgresqlVersions;
|
||||
EOF
|
||||
'';
|
||||
|
||||
defaultTestSpec =
|
||||
testSpec "postgrest-test-spec" defaultPostgresql;
|
||||
testSpec "postgrest-test-spec" postgresql;
|
||||
|
||||
# Create a `testSpec` for each PostgreSQL version that we want to test
|
||||
# against.
|
||||
testSpecVersions =
|
||||
map
|
||||
(postgresql: testSpec "postgrest-test-spec-${postgresql.name}" postgresql)
|
||||
lib.mapAttrsToList
|
||||
(name: postgresql: testSpec "postgrest-test-spec-${name}" postgresql)
|
||||
postgresqlVersions;
|
||||
|
||||
# Helper script for running the tests against all PostgreSQL versions.
|
||||
@@ -69,14 +67,14 @@ let
|
||||
testRunners =
|
||||
map (test: "${test}/bin/${test.name}") testSpecVersions;
|
||||
in
|
||||
writeShellScriptBin "postgrest-test-spec-all"
|
||||
''
|
||||
set -euo pipefail
|
||||
writeShellScriptBin "postgrest-test-spec-all"
|
||||
''
|
||||
set -euo pipefail
|
||||
|
||||
${lib.concatStringsSep "\n" testRunners}
|
||||
'';
|
||||
${lib.concatStringsSep "\n" testRunners}
|
||||
'';
|
||||
in
|
||||
# Create an environment that contains all the utility scripts for running tests
|
||||
# Create an environment that contains all the utility scripts for running tests
|
||||
# that we defined above.
|
||||
buildEnv {
|
||||
name =
|
||||
|
||||
@@ -9,8 +9,7 @@ pkgs.lib.overrideDerivation env (
|
||||
pkgs.postgresql
|
||||
nixpkgsUpgrade
|
||||
tests
|
||||
style
|
||||
lint
|
||||
devtools
|
||||
# We don't include the `postgrest-docker-load` here, as that would
|
||||
# cause the shell to depend on building the Docker images and in turn
|
||||
# on the static executable. Use `nix-shell default.nix -A dockerLoad`
|
||||
|
||||
@@ -82,7 +82,7 @@ postgrest conf refDbStructure pool getTime worker =
|
||||
-- Need to parse ?columns early because findProc needs it to solve overloaded functions.
|
||||
-- TODO: move this logic to the app function
|
||||
let apiReq = userApiRequest (configSchemas conf) (configRootSpec conf) req body
|
||||
apiReqCols = (,) <$> apiReq <*> (pRequestColumns =<< iColumns <$> apiReq)
|
||||
apiReqCols = (,) <$> apiReq <*> (pRequestColumns . iColumns =<< apiReq)
|
||||
case apiReqCols of
|
||||
Left err -> return . errorResponseFor $ err
|
||||
Right (apiRequest, maybeCols) -> do
|
||||
|
||||
@@ -164,7 +164,7 @@ readOptions = do
|
||||
<*> (fmap unpack <$> optString "server-unix-socket")
|
||||
<*> parseSocketFileMode "server-unix-socket-mode"
|
||||
<*> (fmap encodeUtf8 <$> optString "jwt-secret")
|
||||
<*> (fromMaybe False <$> optBool "secret-is-base64")
|
||||
<*> ((Just True ==) <$> optBool "secret-is-base64")
|
||||
<*> parseJwtAudience "jwt-aud"
|
||||
<*> (fromMaybe 10 <$> optInt "db-pool")
|
||||
<*> (fromMaybe 10 <$> optInt "db-pool-timeout")
|
||||
|
||||
@@ -229,7 +229,7 @@ pLogicSingleVal = try (pQuotedValue <* notFollowedBy (noneOf ",)")) <|> try pPgA
|
||||
a <- string "{"
|
||||
b <- many (noneOf "{}")
|
||||
c <- string "}"
|
||||
toS <$> pure (a ++ b ++ c)
|
||||
pure (toS $ a ++ b ++ c)
|
||||
|
||||
pLogicPath :: Parser (EmbedPath, Text)
|
||||
pLogicPath = do
|
||||
|
||||
@@ -99,5 +99,5 @@ contentRangeH lower upper total =
|
||||
| totalNotZero && fromInRange = show lower <> "-" <> show upper
|
||||
| otherwise = "*"
|
||||
totalString = maybe "*" show total
|
||||
totalNotZero = maybe True (0 /=) total
|
||||
totalNotZero = Just 0 /= total
|
||||
fromInRange = lower <= upper
|
||||
|
||||
Reference in New Issue
Block a user