Skip to content

Commit

Permalink
Merge branch 'ci-fix-reuse_previous_caches' of github.com:develop7/po…
Browse files Browse the repository at this point in the history
…stgrest into ci-fix-reuse_previous_caches
  • Loading branch information
develop7 committed Jan 29, 2024
2 parents 1f8b67f + 02c7882 commit e6e6942
Show file tree
Hide file tree
Showing 23 changed files with 203 additions and 249 deletions.
2 changes: 1 addition & 1 deletion .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
freebsd_instance:
image_family: freebsd-13-1
image_family: freebsd-14-0

build_task:
name: Build FreeBSD (Stack)
Expand Down
8 changes: 1 addition & 7 deletions .github/workflows/cachix.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,7 @@ jobs:
- name: Seed static toolchain
if: matrix.os == 'Linux'
run: |
nix-build -A packagesStatic.haskellPackages.hello
postgrest-push-cachix
- name: Seed static postgresql build (for libpq)
if: matrix.os == 'Linux'
run: |
nix-build -A packagesStatic.pkgs.postgresql
nix-build -A packagesStatic.hello
postgrest-push-cachix
- name: Seed static postgrest build
Expand Down
18 changes: 3 additions & 15 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,8 @@ jobs:
uses: ./.github/actions/setup-nix
with:
cache-id: common
- name: Put all tools to store to be cached afterwards
run: |
# shellcheck disable=SC2046
nix-store -v --realize $( nix-instantiate default.nix \
-A style -A withTools -A memory -A tests -A release -A postgrestPackage \
)
shell: bash

tools: style withTools memory tests release postgrestPackage

Lint-Style:
name: Lint & check code style
runs-on: ubuntu-latest
Expand Down Expand Up @@ -135,19 +129,13 @@ jobs:
Build-Static-Nix:
name: Build Linux static (Nix)
runs-on: ubuntu-latest
needs: [Prepopulate-Nix-Cache-Linux]
steps:
- uses: actions/checkout@v4
- name: Setup Nix Environment
uses: ./.github/actions/setup-nix
with:
tools: tests
cache-id: common

- name: Build static executable
run: nix-build -A postgrestStatic
- name: Check static executable
run: postgrest-check-static result/bin/postgrest
- name: Save built executable as artifact
uses: actions/upload-artifact@v4
with:
Expand Down Expand Up @@ -251,7 +239,7 @@ jobs:
Build-Cabal:
strategy:
matrix:
ghc: ['9.4.8']
ghc: ['9.4.8', '9.6.4', '9.8.1']
fail-fast: false
name: Build Linux (Cabal, GHC ${{ matrix.ghc }})
runs-on: ubuntu-latest
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Fixed

- #3149, Misleading "Starting PostgREST.." logs on schema cache reloading - @steve-chavez
- #2815, Build static executable with GSSAPI support - @wolfgangwalther

### Deprecated

Expand Down
2 changes: 1 addition & 1 deletion cabal.project.freeze
Original file line number Diff line number Diff line change
@@ -1 +1 @@
index-state: hackage.haskell.org 2024-01-06T00:00:00Z
index-state: hackage.haskell.org 2024-01-22T00:00:00Z
31 changes: 29 additions & 2 deletions cabal.project.non-nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,32 @@ packages: .

source-repository-package
type: git
location: https://github.com/PostgREST/postgresql-libpq.git
tag: 890a0a16cf57dd401420fdc6c7d576fb696003bc
location: https://github.com/postgrest/configurator-pg.git
tag: e4d2dd34da2746af2fdf927d3f0a5baf9d4c5baf

source-repository-package
type: git
location: https://github.com/phadej/insert-ordered-containers.git
tag: 61de4ad588f3d5e8935368abf87312c0d2560d55

source-repository-package
type: git
location: https://github.com/well-typed/optics.git
tag: f82800306797f255974829e7b87380f20217dff3
subdir: optics-extra optics-th

source-repository-package
type: git
location: https://github.com/haskellari/postgresql-libpq.git
tag: 05417491872ba4b74382673e834518610b993b28

source-repository-package
type: git
location: https://github.com/qfpl/tasty-hedgehog.git
tag: 1ec8ee4c5e4e231026363673bc460eaf5c649b2d

source-repository-package
type: git
location: https://github.com/wolfgangwalther/swagger2.git
tag: dcc6fbec4b650c779f1a2ffbdc6464b006001def

20 changes: 4 additions & 16 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ let
allOverlays.build-toolbox
allOverlays.checked-shell-script
allOverlays.gitignore
(allOverlays.postgresql-default { inherit patches; })
allOverlays.postgresql-libpq
allOverlays.postgresql-legacy
allOverlays.postgresql-future
allOverlays.postgis
Expand All @@ -60,23 +60,11 @@ let
{ name = "postgresql-9.6"; postgresql = pkgs.postgresql_9_6.withPackages (p: [ p.postgis p.pg_safeupdate ]); }
];

patches =
pkgs.callPackage nix/patches { };

# Dynamic derivation for PostgREST
postgrest =
pkgs.haskell.packages."${compiler}".callCabal2nix name src { };

# Functionality that derives a fully static Haskell package based on
# nh2/static-haskell-nix
staticHaskellPackage =
import nix/static-haskell-package.nix { inherit nixpkgs system compiler patches allOverlays; };

# Static executable.
postgrestStatic =
lib.justStaticExecutables (lib.dontCheck (staticHaskellPackage name src).package);

packagesStatic = (staticHaskellPackage name src).survey;
staticHaskellPackage = import nix/static.nix { inherit compiler name pkgs src; };

# Options passed to cabal in dev tools and tests
devCabalOptions =
Expand Down Expand Up @@ -160,8 +148,8 @@ rec {
};
} // pkgs.lib.optionalAttrs pkgs.stdenv.isLinux rec {
# Static executable.
inherit postgrestStatic;
inherit packagesStatic;
inherit (staticHaskellPackage) postgrestStatic;
inherit (staticHaskellPackage) packagesStatic;

# Docker images and loading script.
docker =
Expand Down
9 changes: 0 additions & 9 deletions nix/UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@ postgrest-nixpkgs-upgrade

```

## Update pinned version of `static-haskell-nix`

We pin [`static-haskell-nix`](https://github.com/nh2/static-haskell-nix) in
[`nix/static-haskell-package.nix`](static-haskell-package.nix). Upgrade the
pinned revision and the tarball hash if necessary. See
[`nix/nixpkgs-upgrade.nix`](nixpkgs-upgrade.nix) for how to get the correct
tarball hash, or just change the hash to an arbitrary value of correct length,
run `nix-build` and use the expected value from the resulting error message.

## Review overlays

Check whether the individual [overlays](overlays) are still required.
Expand Down
65 changes: 65 additions & 0 deletions nix/libpq.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Creating a separate libpq package is is discussed in
# https://github.com/NixOS/nixpkgs/issues/61580, but nixpkgs has not moved
# forward, yet.
# This package is passed to postgresql-libpq (haskell) which needs to be
# cross-compiled to the static build and possibly other architectures as
# as well. To reduce the number of dependencies that need to be built with
# it, this derivation focuses on building the client libraries only. No
# server, no tests.
{ stdenv
, lib
, openssl
, zlib
, libkrb5
, icu
, postgresql
, pkg-config
, tzdata
}:

stdenv.mkDerivation {
pname = "libpq";
inherit (postgresql) src version;

configureFlags = [
"--without-gssapi"
"--without-icu"
"--without-readline"
"--with-gssapi"
"--with-openssl"
"--with-system-tzdata=${tzdata}/share/zoneinfo"
];

nativeBuildInputs = [ pkg-config tzdata ];
buildInputs = [ libkrb5 openssl zlib ];

buildFlags = [ "submake-libpq" "submake-libpgport" ];

installPhase = ''
runHook preInstall
make -C src/bin/pg_config install
make -C src/common install
make -C src/include install
make -C src/interfaces/libpq install
make -C src/port install
rm -rfv $out/share
runHook postInstall
'';

# To avoid linking errors in the static build with gssapi
postInstall = ''
substituteInPlace $out/lib/pkgconfig/libpq.pc\
--replace "Requires.private:" "Requires.private: krb5-gssapi,"
'';

outputs = [ "out" ];

meta = with lib; {
homepage = "https://www.postgresql.org";
description = "Client API library for PostgreSQL";
license = licenses.postgresql;
};
}
2 changes: 1 addition & 1 deletion nix/overlays/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
gitignore = import ./gitignore.nix;
haskell-packages = import ./haskell-packages.nix;
postgis = import ./postgis.nix;
postgresql-default = import ./postgresql-default.nix;
postgresql-libpq = import ./postgresql-libpq.nix;
postgresql-legacy = import ./postgresql-legacy.nix;
postgresql-future = import ./postgresql-future.nix;
slocat = import ./slocat.nix;
Expand Down
15 changes: 5 additions & 10 deletions nix/overlays/haskell-packages.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ compiler, extraOverrides ? (final: prev: { }) }:
{ compiler }:

self: super:
let
Expand Down Expand Up @@ -42,18 +42,13 @@ let
fuzzyset = lib.markUnbroken prev.fuzzyset;

postgresql-libpq = lib.dontCheck
(prev.callCabal2nix "postgresql-libpq"
(super.fetchFromGitHub {
owner = "PostgREST";
repo = "postgresql-libpq";
rev = "890a0a16cf57dd401420fdc6c7d576fb696003bc"; # master
sha256 = "1wmyhldk0k14y8whp1p4akrkqxf5snh8qsbm7fv5f7kz95nyffd0";
})
{ });
(prev.postgresql-libpq_0_10_0_0.override {
postgresql = super.libpq;
});

hasql-pool = lib.dontCheck prev.hasql-pool_0_10;

} // extraOverrides final prev;
};
in
{
haskell =
Expand Down
8 changes: 0 additions & 8 deletions nix/overlays/postgresql-default.nix

This file was deleted.

6 changes: 6 additions & 0 deletions nix/overlays/postgresql-libpq.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
self: super:
{
libpq = super.callPackage ../libpq.nix {
postgresql = super.postgresql_16;
};
}
29 changes: 0 additions & 29 deletions nix/patches/default.nix

This file was deleted.

11 changes: 0 additions & 11 deletions nix/patches/postgresql-atexit.patch

This file was deleted.

12 changes: 0 additions & 12 deletions nix/patches/static-haskell-nix-ghc-bignum.patch

This file was deleted.

13 changes: 0 additions & 13 deletions nix/patches/static-haskell-nix-ncurses.patch

This file was deleted.

12 changes: 0 additions & 12 deletions nix/patches/static-haskell-nix-openssl.patch

This file was deleted.

Loading

0 comments on commit e6e6942

Please sign in to comment.