Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ jobs:
strategy:
fail-fast: false
matrix:
pgVersion: [12, 13, 14, 15, 16, 17]
pgVersion: [13, 14, 15, 16, 17]
name: PG ${{ matrix.pgVersion }}
runs-on: ubuntu-24.04
defaults:
Expand Down
7 changes: 3 additions & 4 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ system ? builtins.currentSystem

, compiler ? "ghc948"
, compiler ? "ghc984"

, # Commit of the Nixpkgs repository that we want to use.
nixpkgsVersion ? import nix/nixpkgs-version.nix
Expand Down Expand Up @@ -35,7 +35,6 @@ let
allOverlays.build-toolbox
allOverlays.checked-shell-script
allOverlays.gitignore
allOverlays.postgresql-libpq
(allOverlays.haskell-packages { inherit compiler; })
allOverlays.slocat
];
Expand All @@ -51,7 +50,6 @@ let
{ name = "postgresql-15"; postgresql = pkgs.postgresql_15.withPackages (p: [ p.postgis p.pg_safeupdate ]); }
{ name = "postgresql-14"; postgresql = pkgs.postgresql_14.withPackages (p: [ p.postgis p.pg_safeupdate ]); }
{ name = "postgresql-13"; postgresql = pkgs.postgresql_13.withPackages (p: [ p.postgis p.pg_safeupdate ]); }
{ name = "postgresql-12"; postgresql = pkgs.postgresql_12.withPackages (p: [ p.postgis p.pg_safeupdate ]); }
];

# Dynamic derivation for PostgREST
Expand Down Expand Up @@ -97,7 +95,8 @@ rec {
# Tooling for analyzing Haskell imports and exports.
hsie =
pkgs.callPackage nix/hsie {
inherit (pkgs.haskell.packages."${compiler}") ghcWithPackages;
# TODO: Fix hsie with newer GHC
inherit (pkgs.haskell.packages.ghc948) ghcWithPackages;
};

### Tools
Expand Down
24 changes: 12 additions & 12 deletions nix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,12 @@ The PostgREST utilities available in `nix-shell` all have names that begin with
postgrest-build postgrest-test-spec
postgrest-check postgrest-watch
postgrest-clean postgrest-with-all
postgrest-coverage postgrest-with-postgresql-12
postgrest-lint postgrest-with-postgresql-13
postgrest-run postgrest-with-postgresql-14
postgrest-style postgrest-with-postgresql-15
postgrest-style-check postgrest-with-postgresql-16
postgrest-test-io postgrest-with-postgresql-17
postgrest-coverage postgrest-with-postgresql-13
postgrest-lint postgrest-with-postgresql-14
postgrest-run postgrest-with-postgresql-15
postgrest-style postgrest-with-postgresql-16
postgrest-style-check postgrest-with-postgresql-17
postgrest-test-io
...

[nix-shell]$
Expand All @@ -99,12 +99,12 @@ $ nix-shell --arg memory true
postgrest-build postgrest-test-spec
postgrest-check postgrest-watch
postgrest-clean postgrest-with-all
postgrest-coverage postgrest-with-postgresql-12
postgrest-lint postgrest-with-postgresql-13
postgrest-run postgrest-with-postgresql-14
postgrest-style postgrest-with-postgresql-15
postgrest-style-check postgrest-with-postgresql-16
postgrest-test-io postgrest-with-postgresql-17
postgrest-coverage postgrest-with-postgresql-13
postgrest-lint postgrest-with-postgresql-14
postgrest-run postgrest-with-postgresql-15
postgrest-style postgrest-with-postgresql-16
postgrest-style-check postgrest-with-postgresql-17
postgrest-test-io
postgrest-test-memory
...

Expand Down
61 changes: 0 additions & 61 deletions nix/libpq.nix

This file was deleted.

8 changes: 4 additions & 4 deletions nix/nixpkgs-version.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
{
owner = "NixOS";
repo = "nixpkgs";
ref = "refs/heads/nixpkgs-unstable-darwin";
date = "2024-11-09";
rev = "a90280100f41a10914edfe729a4053e60c92b8e3";
tarballHash = "1vwr665b6l6gma24w45q5hic86vbd8alc01mziwwr621hwlca88f";
ref = "refs/heads/nixpkgs-unstable";
date = "2025-01-11";
rev = "32af3611f6f05655ca166a0b1f47b57c762b5192";
tarballHash = "0shknvd56nfqh4awklgsxwaavpfixgh766m428qdlxihjmmqvhbl";
}
5 changes: 3 additions & 2 deletions nix/overlays/checked-shell-script/checked-shell-script.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
, coreutils
, git
, lib
, moreutils
, runCommand
, shellcheck
, stdenv
Expand Down Expand Up @@ -56,7 +57,7 @@ let
# Example: This way `postgrest-watch -h` will return the help output for watch, while
# `postgrest-watch postgrest-test-spec -h` will return the help output for test-spec.
# Taken from: https://github.com/matejak/argbash/issues/114#issuecomment-557108274
sed '/_positionals_count + 1/a\\t\t\t\tset -- "''${@:1:1}" "--" "''${@:2}"' -i $out
sed '/_positionals_count + 1/a\\t\t\t\tset -- "''${@:1:1}" "--" "''${@:2}"' $out | ${moreutils}/bin/sponge $out
'';

bash-completion =
Expand All @@ -66,7 +67,7 @@ let
''

+ lib.optionalString (positionalCompletion != "") ''
sed 's#COMPREPLY.*compgen -o bashdefault .*$#${escape positionalCompletion}#' -i $out
sed 's#COMPREPLY.*compgen -o bashdefault .*$#${escape positionalCompletion}#' $out | ${moreutils}/bin/sponge $out
''
);

Expand Down
1 change: 0 additions & 1 deletion nix/overlays/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,5 @@
checked-shell-script = import ./checked-shell-script;
gitignore = import ./gitignore.nix;
haskell-packages = import ./haskell-packages.nix;
postgresql-libpq = import ./postgresql-libpq.nix;
slocat = import ./slocat.nix;
}
29 changes: 20 additions & 9 deletions nix/overlays/haskell-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -50,25 +50,36 @@ let
# jailbreak, because hspec limit for tests
fuzzyset = prev.fuzzyset_0_2_4;

hasql-pool = lib.dontCheck (prev.callHackageDirect
postgresql-binary = prev.postgresql-binary_0_14;
hasql = prev.hasql_1_8_1_1;
hasql-dynamic-statements = prev.hasql-dynamic-statements_0_3_1_7;
hasql-implicits = prev.hasql-implicits_0_2;
hasql-pool = prev.hasql-pool_1_2_0_2;
hasql-transaction = prev.hasql-transaction_1_1_1_2;

hasql-notifications = lib.dontCheck (prev.callHackageDirect
{
pkg = "hasql-pool";
ver = "1.0.1";
sha256 = "sha256-Hf1f7lX0LWkjrb25SDBovCYPRdmUP1H6pAxzi7kT4Gg=";
pkg = "hasql-notifications";
ver = "0.2.3.1";
sha256 = "sha256-vLLUBreUXLPACqzKun8a+Irew895/VydI1lKrnY/M1w=";
}
{ });
{ }
);

jose-jwt = prev.jose-jwt_0_10_0;

postgresql-libpq = lib.dontCheck (prev.callHackageDirect
postgresql-libpq = lib.overrideCabal (lib.dontCheck (prev.callHackageDirect
{
pkg = "postgresql-libpq";
ver = "0.10.1.0";
sha256 = "sha256-tXOMqCO8opMilI9rx0D+njqjIjbZsH168Bzb8Aq8Ff4=";
}
{
postgresql = super.libpq;
});
{ }
)) (drv: {
configureFlags = [ "-fuse-pkg-config" ];
libraryPkgconfigDepends = [ super.postgresql_16 ];
librarySystemDepends = [ ];
});
};
in
{
Expand Down
6 changes: 0 additions & 6 deletions nix/overlays/postgresql-libpq.nix

This file was deleted.

64 changes: 11 additions & 53 deletions nix/static.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,64 +8,22 @@ let
inherit (pkgs) pkgsStatic;
inherit (pkgsStatic.haskell) lib;

packagesStatic =
pkgsStatic.haskell.packages."${compiler}".override (old: {
ghc = pkgsStatic.pkgsBuildHost.haskell.compiler."${compiler}".override {
# Using the bundled libffi generally works better for cross-compiling
libffi = null;
# Building sphinx fails on some platforms
enableDocs = false;
# Cross compiling with native bignum works better than with gmp
enableNativeBignum = true;
};

overrides = pkgs.lib.composeExtensions old.overrides (_: prev: {
postgresql-libpq = (lib.overrideCabal prev.postgresql-libpq {
# TODO: This section can be simplified when this PR has made it's way to us:
# https://github.com/NixOS/nixpkgs/pull/286370
# Additionally, we need to use the default version in nixpkgs, otherwise the
# override will not be active as well.
# Using use-pkg-config flag, because pg_config won't work when cross-compiling
configureFlags = [ "-fuse-pkg-config" ];
# postgresql doesn't build in the fully static overlay - but the default
# derivation is built with static libraries anyway.
libraryPkgconfigDepends = [ pkgsStatic.libpq ];
librarySystemDepends = [ ];
}).overrideAttrs (_: prevAttrs: {
buildInputs = prevAttrs.buildInputs ++ [ pkgsStatic.openssl ];
});
});
});
packagesStatic = pkgsStatic.haskell.packages.native-bignum."${compiler}";

makeExecutableStatic = drv: pkgs.lib.pipe drv [
lib.compose.justStaticExecutables

# To successfully compile a redistributable, fully static executable we need to:
# 1. make executable really statically linked.
# 2. avoid any references to /nix/store to prevent blowing up the closure size.
# 3. be able to run the executable.
# When checking for references, we ignore the following:
# - eeee... are removed references which don't actually exist
# - openssl-etc references are purposely designed to be very small
(lib.compose.overrideCabal (drv: {
postFixup = drv.postFixup + ''
exe="$out/bin/postgrest"

if ! (file "$exe" | grep 'statically linked') then
echo "not a static executable, ldd output:"
ldd "$exe"
exit 1
fi

echo "Checking for references to /nix/store..."
(${pkgsStatic.binutils}/bin/strings "$exe" \
| grep -v /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee \
| grep -v -etc/etc/ssl \
| grep /nix/store || exit 0 && exit 1)
echo "No references to /nix/store found"

"$exe" --help
'';
# 1. avoid any references to /nix/store to prevent blowing up the closure size.
# 2. be able to run the executable.
(drv: drv.overrideAttrs (finalAttrs: {
allowedReferences = [
pkgsStatic.openssl.etc
];

passthru.tests.version = pkgsStatic.testers.testVersion {
package = finalAttrs.finalPackage;
};
}))
];

Expand Down
10 changes: 3 additions & 7 deletions postgrest.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ library
PostgREST.ApiRequest.QueryParams
PostgREST.ApiRequest.Types
PostgREST.Response
PostgREST.Response.OpenAPI
PostgREST.Response.GucHeader
PostgREST.Response.Performance
PostgREST.Version
Expand All @@ -109,20 +108,18 @@ library
, extra >= 1.7.0 && < 2.0
, fuzzyset >= 0.2.4 && < 0.3
, gitrev >= 1.2 && < 1.4
, hasql >= 1.6.1.1 && < 1.7
, hasql >= 1.7 && < 1.9
, hasql-dynamic-statements >= 0.3.1 && < 0.4
, hasql-notifications >= 0.2.2.0 && < 0.3
, hasql-pool >= 1.0.1 && < 1.1
, hasql-transaction >= 1.0.1 && < 1.1
, heredoc >= 0.2 && < 0.3
, hasql-pool >= 1.1 && < 1.3
, hasql-transaction >= 1.0.1 && < 1.2
, http-types >= 0.12.2 && < 0.13
, insert-ordered-containers >= 0.2.2 && < 0.3
, iproute >= 1.7.0 && < 1.8
, jose-jwt >= 0.9.6 && < 0.11
, lens >= 4.14 && < 5.3
, lens-aeson >= 1.0.1 && < 1.3
, mtl >= 2.2.2 && < 2.4
, neat-interpolation >= 0.5 && < 0.6
, network >= 2.6 && < 3.2
, network-uri >= 2.6.1 && < 2.8
, optparse-applicative >= 0.13 && < 0.19
Expand All @@ -134,7 +131,6 @@ library
, retry >= 0.7.4 && < 0.10
, scientific >= 0.3.4 && < 0.4
, streaming-commons >= 0.1.1 && < 0.3
, swagger2 >= 2.4 && < 2.9
, text >= 1.2.2 && < 2.2
, time >= 1.6 && < 1.13
, timeit >= 2.0 && < 2.1
Expand Down
Loading