Skip to content

Commit

Permalink
nix: Update nixpkgs and build with GHC 9.4.8
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfgangwalther committed Jan 14, 2024
1 parent 735849c commit 846f12c
Show file tree
Hide file tree
Showing 21 changed files with 113 additions and 66 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ jobs:
Build-Cabal:
strategy:
matrix:
ghc: ['9.0.2', '9.2.4']
ghc: ['9.4.8']
fail-fast: false
name: Build Linux (Cabal, GHC ${{ matrix.ghc }})
runs-on: ubuntu-latest
Expand Down Expand Up @@ -284,7 +284,7 @@ jobs:
Build-Cabal-Arm:
strategy:
matrix:
ghc: ['9.2.4']
ghc: ['9.4.8']
fail-fast: false
name: Build aarch64 (Cabal, GHC ${{ matrix.ghc }})
if: ${{ github.ref == 'refs/heads/main' || startsWith(github.ref, 'refs/tags/v') || startsWith(github.ref, 'refs/heads/rel-') }}
Expand Down
2 changes: 2 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
packages: postgrest.cabal
tests: true
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 2023-10-13T13:54:33Z
index-state: hackage.haskell.org 2024-01-06T00:00:00Z
18 changes: 3 additions & 15 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let
"postgrest";

compiler =
"ghc924";
"ghc948";

# PostgREST source files, filtered based on the rules in the .gitignore files
# and file extensions. We want to include as litte as possible, as the files
Expand Down Expand Up @@ -36,10 +36,10 @@ let
allOverlays.build-toolbox
allOverlays.checked-shell-script
allOverlays.gitignore
allOverlays.postgis
(allOverlays.postgresql-default { inherit patches; })
allOverlays.postgresql-legacy
allOverlays.postgresql-future
allOverlays.postgis
(allOverlays.haskell-packages { inherit compiler; })
allOverlays.slocat
];
Expand All @@ -50,19 +50,7 @@ let

postgresqlVersions =
[
{
name = "postgresql-16";
postgresql = pkgs.postgresql_16.withPackages (p: [
p.postgis
(p.pg_safeupdate.overrideAttrs (old: {
installPhase = ''
mkdir -p $out/bin
cp safeupdate.dylib safeupdate.so || true
install -D safeupdate.so -t $out/lib
'';
}))
]);
}
{ name = "postgresql-16"; postgresql = pkgs.postgresql_16.withPackages (p: [ p.postgis p.pg_safeupdate ]); }
{ 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 ]); }
Expand Down
9 changes: 4 additions & 5 deletions nix/hsie/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ module Main (main) where
import qualified Data.Aeson as JSON
import qualified Data.ByteString.Lazy.Char8 as LBS8
import qualified Data.Csv as Csv
import qualified Data.List as List
import qualified Data.Map as Map
import qualified Data.Set as Set
import qualified Data.Text as T
Expand All @@ -34,12 +33,13 @@ import Data.Function ((&))
import Data.List (intercalate)
import Data.Maybe (catMaybes, mapMaybe)
import Data.Text (Text)
import GHC.Data.Bag (bagToList)
import GHC.Generics (Generic)
import GHC.Hs.Extension (GhcPs)
import GHC.Types.Error (getMessages)
import GHC.Types.Name.Occurrence (occNameString)
import GHC.Types.Name.Reader (rdrNameOcc)
import GHC.Unit.Module.Name (moduleNameString)
import GHC.Utils.Error (pprMsgEnvelopeBagWithLoc)
import System.Directory.Recursive (getFilesRecursive)
import System.Exit (exitFailure)

Expand Down Expand Up @@ -206,7 +206,7 @@ parseModule filepath = do
return $ GHC.unLoc hsmod
Left errs ->
fail $ "Errors with " <> show filepath <> ":\n "
<> List.intercalate "\n " (show <$> bagToList errs)
<> show (pprMsgEnvelopeBagWithLoc $ getMessages errs)

-- | Symbols imported in an import declaration.
--
Expand Down Expand Up @@ -250,8 +250,7 @@ dump OutputJson = encodePretty
-- | Find modules that are imported under different aliases
inconsistentAliases :: [ImportedSymbol] -> ModuleAliases
inconsistentAliases symbols =
fmap moduleAlias symbols
& foldr insertSetMapMap Map.empty
foldr (insertSetMapMap . moduleAlias) Map.empty symbols
& Map.map (aliases . Map.toList)
& Map.filter ((<) 1 . length)
& Map.toList
Expand Down
1 change: 1 addition & 0 deletions nix/hsie/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ let
ps.dir-traverse
ps.dot
ps.ghc-exactprint
ps.ghc-paths
ps.optparse-applicative
];
ghc = ghcWithPackages modules;
Expand Down
6 changes: 3 additions & 3 deletions nix/nixpkgs-version.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Pinned version of Nixpkgs, generated with postgrest-nixpkgs-upgrade.
{
date = "2023-03-25";
rev = "dbf5322e93bcc6cfc52268367a8ad21c09d76fea";
tarballHash = "0lwk4v9dkvd28xpqch0b0jrac4xl9lwm6snrnzx8k5lby72kmkng";
date = "2024-01-06";
rev = "4bbf5a2eb6046c54f7a29a0964c642ebfe912cbc";
tarballHash = "03p45qdcxqxc41mmzmmyzbkff29vv95vv643z0kd3mf1s2nnsy5b";
}
19 changes: 19 additions & 0 deletions nix/overlays/haskell-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,25 @@ let
# To fill in the sha256:
# update-nix-fetchgit nix/overlays/haskell-packages.nix

configurator-pg =
prev.callHackageDirect
{
pkg = "configurator-pg";
ver = "0.2.9";
sha256 = "sha256-UqFiOgPlksbIdHBVO0wYhCnboB+mxKJcXVhY9C1V7Hg=";
}
{ };

# Marked as broken (?)
fuzzyset =
prev.callHackageDirect
{
pkg = "fuzzyset";
ver = "0.3.1";
sha256 = "sha256-VHwGVB87UAxoPi6NHVGZueEiwyNg+eWbiX/YJaU4YxI=";
}
{ };

postgresql-libpq = lib.dontCheck
(prev.callCabal2nix "postgresql-libpq"
(super.fetchFromGitHub {
Expand Down
1 change: 1 addition & 0 deletions nix/overlays/postgis.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ let
url = "https://download.osgeo.org/postgis/source/postgis-${version}.tar.gz";
sha256 = "sha256-G02LXHVuWrpZ77wYM7Iu/k1lYneO7KVvpJf+susTZow=";
};
meta.broken = false;
};
in
{
Expand Down
24 changes: 12 additions & 12 deletions nix/overlays/postgresql-future.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ self: super:
{
## Example for including a postgresql version from a specific nixpks commit:
##
postgresql_16 =
let
rev = "5148520bfab61f99fd25fb9ff7bfbb50dad3c9db";
tarballHash = "1dfjmz65h8z4lk845724vypzmf3dbgsdndjpj8ydlhx6c7rpcq3p";

pinnedPkgs =
builtins.fetchTarball {
url = "https://github.com/nixos/nixpkgs/archive/${rev}.tar.gz";
sha256 = tarballHash;
};
in
(import pinnedPkgs { }).pkgs.postgresql_16;
# postgresql_16 =
# let
# rev = "5148520bfab61f99fd25fb9ff7bfbb50dad3c9db";
# tarballHash = "1dfjmz65h8z4lk845724vypzmf3dbgsdndjpj8ydlhx6c7rpcq3p";
#
# pinnedPkgs =
# builtins.fetchTarball {
# url = "https://github.com/nixos/nixpkgs/archive/${rev}.tar.gz";
# sha256 = tarballHash;
# };
# in
# (import pinnedPkgs { }).pkgs.postgresql_16;
}
15 changes: 15 additions & 0 deletions nix/overlays/postgresql-legacy.nix
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,19 @@ self: super:
};
in
(import pinnedPkgs { }).pkgs.postgresql_10;

# PostgreSQL 11 was removed from Nixpkgs with
# https://github.com/NixOS/nixpkgs/commit/1220a4d4dd1a4590780a5e1c18d1333a121be366
# We pin its parent commit to get the last version that was available.
postgresql_11 =
let
rev = "f5458516e42cc5cb4123cc2d93f45c240548aa18";
tarballHash = "1h03621sxfhw4z6ya74k6c2lyx3z7pvf2jcg4vs7i01yz2m6w3cv";
pinnedPkgs =
builtins.fetchTarball {
url = "https://github.com/nixos/nixpkgs/archive/${rev}.tar.gz";
sha256 = tarballHash;
};
in
(import pinnedPkgs { }).pkgs.postgresql_11;
}
2 changes: 1 addition & 1 deletion nix/overlays/slocat.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ final: prev:
rev = "52e7512c6029fd00483e41ccce260a3b4b9b3b64";
sha256 = "sha256-qn6luuh5wqREu3s8RfuMCP5PKdS2WdwPrujRYTpfzQ8=";
};
vendorSha256 = "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=";
vendorHash = "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=";
};
}
2 changes: 1 addition & 1 deletion nix/static-haskell-package.nix
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ let

defaultCabalPackageVersionComingWithGhc =
{
ghc924 = "Cabal_3_6_3_0";
ghc948 = "Cabal_3_8_1_0";
}."${compiler}";

# The static-haskell-nix 'survey' derives a full static set of Haskell
Expand Down
2 changes: 1 addition & 1 deletion nix/tools/loadtest.nix
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ let
}
''
find loadtest -type f -iname '*.bin' -exec ${reporter} {} \; \
| ${jq}/bin/jq '[leaf_paths as $path | {param: $path | join("."), (.branch): getpath($path)}]' \
| ${jq}/bin/jq '[paths(scalars) as $path | {param: $path | join("."), (.branch): getpath($path)}]' \
| ${jq}/bin/jq --slurp 'flatten | group_by(.param) | map(add)' \
| ${toMarkdown}
'';
Expand Down
2 changes: 1 addition & 1 deletion nix/tools/tests.nix
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ let
(
trap 'echo Found dead code: Check file list above.' ERR ;
${weeder}/bin/weeder --config=./test/weeder.dhall
${weeder}/bin/weeder --config=./test/weeder.toml
)
# collect all tests
Expand Down
20 changes: 10 additions & 10 deletions postgrest.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ library
PostgREST.Response.Performance
PostgREST.Version
other-modules: Paths_postgrest
build-depends: base >= 4.9 && < 4.17
build-depends: base >= 4.9 && < 4.18
, HTTP >= 4000.3.7 && < 4000.5
, Ranged-sets >= 0.3 && < 0.5
, aeson >= 2.0.3 && < 2.2
Expand All @@ -93,7 +93,7 @@ library
, directory >= 1.2.6 && < 1.4
, either >= 4.4.1 && < 5.1
, extra >= 1.7.0 && < 2.0
, fuzzyset >= 0.2.3
, fuzzyset >= 0.3.0
, gitrev >= 1.2 && < 1.4
, hasql >= 1.6.1.1 && < 1.7
, hasql-dynamic-statements >= 0.3.1 && < 0.4
Expand All @@ -118,11 +118,11 @@ library
, scientific >= 0.3.4 && < 0.4
, streaming-commons >= 0.1.1 && < 0.3
, swagger2 >= 2.4 && < 2.9
, text >= 1.2.2 && < 1.3
, time >= 1.6 && < 1.12
, text >= 1.2.2 && < 2.1
, time >= 1.6 && < 1.13
, timeit >= 2.0 && < 2.1
, unordered-containers >= 0.2.8 && < 0.3
, unix-compat >= 0.5.4 && < 0.6
, unix-compat >= 0.5.4 && < 0.8
, vault >= 0.3.1.5 && < 0.4
, vector >= 0.11 && < 0.14
, wai >= 3.2.1 && < 3.3
Expand Down Expand Up @@ -159,7 +159,7 @@ executable postgrest
NoImplicitPrelude
hs-source-dirs: main
main-is: Main.hs
build-depends: base >= 4.9 && < 4.17
build-depends: base >= 4.9 && < 4.18
, containers >= 0.5.7 && < 0.7
, postgrest
, protolude >= 0.3.1 && < 0.4
Expand Down Expand Up @@ -233,7 +233,7 @@ test-suite spec
Feature.RollbackSpec
Feature.RpcPreRequestGucsSpec
SpecHelper
build-depends: base >= 4.9 && < 4.17
build-depends: base >= 4.9 && < 4.18
, aeson >= 2.0.3 && < 2.2
, aeson-qq >= 0.8.1 && < 0.9
, async >= 2.1.1 && < 2.3
Expand All @@ -245,7 +245,7 @@ test-suite spec
, hasql-pool >= 0.10 && < 0.11
, hasql-transaction >= 1.0.1 && < 1.1
, heredoc >= 0.2 && < 0.3
, hspec >= 2.3 && < 2.10
, hspec >= 2.3 && < 2.11
, hspec-wai >= 0.10 && < 0.12
, hspec-wai-json >= 0.10 && < 0.12
, http-types >= 0.12.3 && < 0.13
Expand All @@ -257,7 +257,7 @@ test-suite spec
, protolude >= 0.3.1 && < 0.4
, regex-tdfa >= 1.2.2 && < 1.4
, scientific >= 0.3.4 && < 0.4
, text >= 1.2.2 && < 1.3
, text >= 1.2.2 && < 2.1
, transformers-base >= 0.4.4 && < 0.5
, wai >= 3.2.1 && < 3.3
, wai-extra >= 3.0.19 && < 3.2
Expand All @@ -275,7 +275,7 @@ test-suite doctests
NoImplicitPrelude
hs-source-dirs: test/doc
main-is: Main.hs
build-depends: base >= 4.9 && < 4.17
build-depends: base >= 4.9 && < 4.18
, doctest >= 0.8
, postgrest
, pretty-simple
Expand Down
10 changes: 5 additions & 5 deletions src/PostgREST/Error.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module PostgREST.Error
import qualified Data.Aeson as JSON
import qualified Data.ByteString.Char8 as BS
import qualified Data.CaseInsensitive as CI
import qualified Data.FuzzySet as Fuzzy
import qualified Data.FuzzySet.Simple as Fuzzy
import qualified Data.HashMap.Strict as HM
import qualified Data.Map.Internal as M
import qualified Data.Text as T
Expand Down Expand Up @@ -293,9 +293,9 @@ noRelBetweenHint parent child schema allRels = ("Perhaps you meant '" <>) <$>
findParent = HM.lookup (QualifiedIdentifier schema parent, schema) allRels
fuzzySetOfParents = Fuzzy.fromList [qiName (fst p) | p <- HM.keys allRels, snd p == schema]
fuzzySetOfChildren = Fuzzy.fromList [qiName (relForeignTable c) | c <- fromMaybe [] findParent]
suggestParent = Fuzzy.getOne fuzzySetOfParents parent
suggestParent = snd <$> Fuzzy.findOne parent fuzzySetOfParents
-- Do not give suggestion if the child is found in the relations (weight = 1.0)
suggestChild = headMay [snd k | k <- Fuzzy.get fuzzySetOfChildren child, fst k < 1.0]
suggestChild = headMay [snd k | k <- Fuzzy.find child fuzzySetOfChildren, fst k < 1.0]

-- |
-- If no function is found with the given name, it does a fuzzy search to all the functions
Expand Down Expand Up @@ -345,8 +345,8 @@ noRpcHint schema procName params allProcs overloadedProcs =
-- E.g. ["val", "param", "name"] into "(name, param, val)"
listToText = ("(" <>) . (<> ")") . T.intercalate ", " . sort
possibleProcs
| null overloadedProcs = Fuzzy.getOne fuzzySetOfProcs procName
| otherwise = (procName <>) <$> Fuzzy.getOne fuzzySetOfParams (listToText params)
| null overloadedProcs = snd <$> Fuzzy.findOne procName fuzzySetOfProcs
| otherwise = (procName <>) . snd <$> Fuzzy.findOne (listToText params) fuzzySetOfParams

compressedRel :: Relationship -> JSON.Value
-- An ambiguousness error cannot happen for computed relationships TODO refactor so this mempty is not needed
Expand Down
5 changes: 4 additions & 1 deletion stack.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
resolver: lts-20.6 # 2023-01-09, GHC 9.2.5
resolver: lts-21.7 # 2023-08-14, GHC 9.4.5

nix:
packages:
Expand All @@ -10,7 +10,10 @@ nix:
pure: false

extra-deps:
- configurator-pg-0.2.7
- git: https://github.com/PostgREST/postgresql-libpq.git
commit: 890a0a16cf57dd401420fdc6c7d576fb696003bc
- hasql-notifications-0.2.0.6
- hasql-pool-0.10
- fuzzyset-0.3.1
- megaparsec-9.2.2
Loading

0 comments on commit 846f12c

Please sign in to comment.