From f26f3c6aa0bce3e811a5ddb8e89153f3dc2dc3e0 Mon Sep 17 00:00:00 2001 From: sternenseemann Date: Fri, 26 Sep 2025 12:31:20 +0200 Subject: [PATCH] haskellPackages: postgresqlTestHook overrides to configuration-nix.nix --- .../haskell-modules/configuration-common.nix | 100 +----------------- .../haskell-modules/configuration-nix.nix | 100 +++++++++++++++++- 2 files changed, 100 insertions(+), 100 deletions(-) diff --git a/pkgs/development/haskell-modules/configuration-common.nix b/pkgs/development/haskell-modules/configuration-common.nix index 12bd2839f569..9ac0952076b6 100644 --- a/pkgs/development/haskell-modules/configuration-common.nix +++ b/pkgs/development/haskell-modules/configuration-common.nix @@ -757,18 +757,7 @@ with haskellLib; migrant-core = doJailbreak super.migrant-core; migrant-sqlite-simple = doJailbreak super.migrant-sqlite-simple; migrant-hdbc = doJailbreak super.migrant-hdbc; - migrant-postgresql-simple = lib.pipe super.migrant-postgresql-simple [ - (overrideCabal { - preCheck = '' - postgresqlTestUserOptions="LOGIN SUPERUSER" - ''; - }) - (addTestToolDepends [ - pkgs.postgresql - pkgs.postgresqlTestHook - ]) - doJailbreak - ]; + migrant-postgresql-simple = doJailbreak super.migrant-postgresql-simple; # https://github.com/froozen/kademlia/issues/2 kademlia = dontCheck super.kademlia; @@ -1574,33 +1563,6 @@ with haskellLib; # https://github.com/mgajda/json-autotype/issues/25 json-autotype = dontCheck super.json-autotype; - postgresql-simple-migration = overrideCabal (drv: { - preCheck = '' - PGUSER=test - PGDATABASE=test - ''; - testToolDepends = drv.testToolDepends or [ ] ++ [ - pkgs.postgresql - pkgs.postgresqlTestHook - ]; - }) (doJailbreak super.postgresql-simple-migration); - - postgresql-simple = addTestToolDepends [ - pkgs.postgresql - pkgs.postgresqlTestHook - ] super.postgresql-simple; - - beam-postgres = lib.pipe super.beam-postgres [ - # Requires pg_ctl command during tests - (addTestToolDepends [ pkgs.postgresql ]) - (dontCheckIf (!pkgs.postgresql.doInstallCheck || !self.testcontainers.doCheck)) - ]; - - users-postgresql-simple = addTestToolDepends [ - pkgs.postgresql - pkgs.postgresqlTestHook - ] super.users-postgresql-simple; - gargoyle-postgresql-nix = addBuildTool [ pkgs.postgresql ] super.gargoyle-postgresql-nix; # PortMidi needs an environment variable to have ALSA find its plugins: @@ -1631,31 +1593,6 @@ with haskellLib; # Fix build with attr-2.4.48 (see #53716) xattr = appendPatch ./patches/xattr-fix-build.patch super.xattr; - esqueleto = - overrideCabal - (drv: { - postPatch = drv.postPatch or "" + '' - # patch out TCP usage: https://nixos.org/manual/nixpkgs/stable/#sec-postgresqlTestHook-tcp - sed -i test/PostgreSQL/Test.hs \ - -e s^host=localhost^^ - ''; - # Match the test suite defaults (or hardcoded values?) - preCheck = drv.preCheck or "" + '' - PGUSER=esqutest - PGDATABASE=esqutest - ''; - testFlags = drv.testFlags or [ ] ++ [ - # We don't have a MySQL test hook yet - "--skip=/Esqueleto/MySQL" - ]; - testToolDepends = drv.testToolDepends or [ ] ++ [ - pkgs.postgresql - pkgs.postgresqlTestHook - ]; - }) - # https://github.com/NixOS/nixpkgs/issues/198495 - (dontCheckIf (pkgs.postgresqlTestHook.meta.broken) super.esqueleto); - # Requires API keys to run tests algolia = dontCheck super.algolia; openai-hs = dontCheck super.openai-hs; @@ -1714,27 +1651,6 @@ with haskellLib; # Test suite requires database persistent-mysql = dontCheck super.persistent-mysql; - persistent-postgresql = - # TODO: move this override to configuration-nix.nix - overrideCabal - (drv: { - postPatch = drv.postPath or "" + '' - # patch out TCP usage: https://nixos.org/manual/nixpkgs/stable/#sec-postgresqlTestHook-tcp - # NOTE: upstream host variable takes only two values... - sed -i test/PgInit.hs \ - -e s^'host=" <> host <> "'^^ - ''; - preCheck = drv.preCheck or "" + '' - PGDATABASE=test - PGUSER=test - ''; - testToolDepends = drv.testToolDepends or [ ] ++ [ - pkgs.postgresql - pkgs.postgresqlTestHook - ]; - }) - # https://github.com/NixOS/nixpkgs/issues/198495 - (dontCheckIf (pkgs.postgresqlTestHook.meta.broken) super.persistent-postgresql); dhall-lsp-server = appendPatches [ # Add support for lsp >= 2.7 @@ -2878,20 +2794,6 @@ with haskellLib; # https://github.com/brandonchinn178/tasty-autocollect/issues/54 tasty-autocollect = dontCheck super.tasty-autocollect; - postgres-websockets = lib.pipe super.postgres-websockets [ - (addTestToolDepends [ - pkgs.postgresql - pkgs.postgresqlTestHook - ]) - (dontCheckIf pkgs.postgresqlTestHook.meta.broken) - (overrideCabal { - preCheck = '' - export postgresqlEnableTCP=1 - export PGDATABASE=postgres_ws_test - ''; - }) - ]; - postgrest = lib.pipe (super.postgrest.overrideScope ( diff --git a/pkgs/development/haskell-modules/configuration-nix.nix b/pkgs/development/haskell-modules/configuration-nix.nix index 6ebd6eb8a002..2d32dbc5a664 100644 --- a/pkgs/development/haskell-modules/configuration-nix.nix +++ b/pkgs/development/haskell-modules/configuration-nix.nix @@ -460,9 +460,21 @@ builtins.intersectAttrs super { ]; # Avoid compiling twice by providing executable as a separate output (with small closure size), + # add postgresqlTestHook to allow test executiion postgres-websockets = lib.pipe super.postgres-websockets [ enableSeparateBinOutput - (overrideCabal { passthru.tests = pkgs.nixosTests.postgres-websockets; }) + (overrideCabal { + passthru.tests = pkgs.nixosTests.postgres-websockets; + preCheck = '' + export postgresqlEnableTCP=1 + export PGDATABASE=postgres_ws_test + ''; + }) + (addTestToolDepends [ + pkgs.postgresql + pkgs.postgresqlTestHook + ]) + (dontCheckIf pkgs.postgresqlTestHook.meta.broken) ]; # Test suite requires a running postgresql server, @@ -1220,6 +1232,92 @@ builtins.intersectAttrs super { ]; }) super.haskell-pgmq; + migrant-postgresql-simple = lib.pipe super.migrant-postgresql-simple [ + (overrideCabal { + preCheck = '' + postgresqlTestUserOptions="LOGIN SUPERUSER" + ''; + }) + (addTestToolDepends [ + pkgs.postgresql + pkgs.postgresqlTestHook + ]) + ]; + + postgresql-simple-migration = overrideCabal (drv: { + preCheck = '' + PGUSER=test + PGDATABASE=test + ''; + testToolDepends = drv.testToolDepends or [ ] ++ [ + pkgs.postgresql + pkgs.postgresqlTestHook + ]; + }) (doJailbreak super.postgresql-simple-migration); + + postgresql-simple = addTestToolDepends [ + pkgs.postgresql + pkgs.postgresqlTestHook + ] super.postgresql-simple; + + beam-postgres = lib.pipe super.beam-postgres [ + # Requires pg_ctl command during tests + (addTestToolDepends [ pkgs.postgresql ]) + (dontCheckIf (!pkgs.postgresql.doInstallCheck || !self.testcontainers.doCheck)) + ]; + + users-postgresql-simple = addTestToolDepends [ + pkgs.postgresql + pkgs.postgresqlTestHook + ] super.users-postgresql-simple; + + esqueleto = + overrideCabal + (drv: { + postPatch = drv.postPatch or "" + '' + # patch out TCP usage: https://nixos.org/manual/nixpkgs/stable/#sec-postgresqlTestHook-tcp + sed -i test/PostgreSQL/Test.hs \ + -e s^host=localhost^^ + ''; + # Match the test suite defaults (or hardcoded values?) + preCheck = drv.preCheck or "" + '' + PGUSER=esqutest + PGDATABASE=esqutest + ''; + testFlags = drv.testFlags or [ ] ++ [ + # We don't have a MySQL test hook yet + "--skip=/Esqueleto/MySQL" + ]; + testToolDepends = drv.testToolDepends or [ ] ++ [ + pkgs.postgresql + pkgs.postgresqlTestHook + ]; + }) + # https://github.com/NixOS/nixpkgs/issues/198495 + (dontCheckIf (pkgs.postgresqlTestHook.meta.broken) super.esqueleto); + + persistent-postgresql = + # TODO: move this override to configuration-nix.nix + overrideCabal + (drv: { + postPatch = drv.postPath or "" + '' + # patch out TCP usage: https://nixos.org/manual/nixpkgs/stable/#sec-postgresqlTestHook-tcp + # NOTE: upstream host variable takes only two values... + sed -i test/PgInit.hs \ + -e s^'host=" <> host <> "'^^ + ''; + preCheck = drv.preCheck or "" + '' + PGDATABASE=test + PGUSER=test + ''; + testToolDepends = drv.testToolDepends or [ ] ++ [ + pkgs.postgresql + pkgs.postgresqlTestHook + ]; + }) + # https://github.com/NixOS/nixpkgs/issues/198495 + (dontCheckIf (pkgs.postgresqlTestHook.meta.broken) super.persistent-postgresql); + # https://gitlab.iscpif.fr/gargantext/haskell-bee/blob/19c8775f0d960c669235bf91131053cb6f69a1c1/README.md#redis haskell-bee-redis = overrideCabal (drv: { testToolDepends = drv.testToolDepends or [ ] ++ [