Skip to content

Commit

Permalink
nix: Add deadnix to postgrest-lint and remove dead nix code
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfgangwalther committed Feb 24, 2024
1 parent caf0a70 commit ccc386c
Show file tree
Hide file tree
Showing 14 changed files with 18 additions and 46 deletions.
4 changes: 2 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ let
"-f dev --test-show-detail=direct";

profiledHaskellPackages =
pkgs.haskell.packages."${compiler}".extend (self: super:
pkgs.haskell.packages."${compiler}".extend (_: super:
{
mkDerivation =
args:
Expand Down Expand Up @@ -118,7 +118,7 @@ rec {
pkgs.callPackage nix/tools/cabalTools.nix { inherit devCabalOptions postgrest; };

withTools =
pkgs.callPackage nix/tools/withTools.nix { inherit cabalTools devCabalOptions postgresqlVersions postgrest; };
pkgs.callPackage nix/tools/withTools.nix { inherit postgresqlVersions postgrest; };

# Development tools.
devTools =
Expand Down
1 change: 0 additions & 1 deletion nix/libpq.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
, openssl
, zlib
, libkrb5
, icu
, postgresql
, pkg-config
, tzdata
Expand Down
2 changes: 1 addition & 1 deletion nix/overlays/build-toolbox/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
self: super:
_: super:
# Overlay that adds `buildToolbox`, an enhanced version of `buildEnv`
{
buildToolbox = super.callPackage ./build-toolbox.nix { };
Expand Down
2 changes: 1 addition & 1 deletion nix/overlays/checked-shell-script/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
self: super:
_: super:
# Overlay that adds `checkedShellScript`, an enhanced version of
# writeShellScript and writeShellScriptBin
{
Expand Down
2 changes: 1 addition & 1 deletion nix/overlays/gitignore.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
self: super:
_: super:
# Overlay that adds the `gitignoreSource` function from Hercules-CI.
# This function is useful for filtering which files are added to the Nix store.
# See: https://github.com/hercules-ci/gitignore.nix
Expand Down
2 changes: 1 addition & 1 deletion nix/overlays/haskell-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ let
inherit (self.haskell) lib;

overrides =
final: prev:
_: prev:
rec {
# To pin custom versions of Haskell packages:
# protolude =
Expand Down
2 changes: 1 addition & 1 deletion nix/overlays/postgresql-future.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
self: super:
_: _:
# Overlay that adds future versions of PostgreSQL that are supported by
# PostgREST.
{
Expand Down
2 changes: 1 addition & 1 deletion nix/overlays/postgresql-legacy.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
self: super:
_: _:
# Overlay that adds legacy versions of PostgreSQL that are supported by
# PostgREST.
{
Expand Down
2 changes: 1 addition & 1 deletion nix/overlays/postgresql-libpq.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
self: super:
_: super:
{
libpq = super.callPackage ../libpq.nix {
postgresql = super.postgresql_16;
Expand Down
2 changes: 1 addition & 1 deletion nix/overlays/slocat.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
final: prev:
_: prev:
{
slocat = prev.buildGoModule {
name = "slocat";
Expand Down
6 changes: 3 additions & 3 deletions nix/static.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ let
enableNativeBignum = true;
};

overrides = pkgs.lib.composeExtensions old.overrides (final: prev: {
overrides = pkgs.lib.composeExtensions old.overrides (_: prev: {
postgresql-libpq = (prev.postgresql-libpq.override {
# postgresql doesn't build in the fully static overlay - but the default
# derivation is built with static libraries anyway.
postgresql = pkgsCross.libpq;
}).overrideAttrs (finalAttrs: prevAttrs: {
}).overrideAttrs (_: prevAttrs: {
# Using use-pkg-config flag, because pg_config won't work when cross-compiling
configureFlags = prevAttrs.configureFlags ++ [
"-fuse-pkg-config"
Expand All @@ -38,7 +38,7 @@ let
nativeBuildInputs = prevAttrs.nativeBuildInputs ++ [ pkgsCross.pkgsBuildHost.pkg-config ];

buildInputs = prevAttrs.buildInputs ++ [
(pkgsStatic.libkrb5.overrideAttrs (finalAttrs: prevAttrs: {
(pkgsStatic.libkrb5.overrideAttrs (_: prevAttrs: {
configureFlags = prevAttrs.configureFlags ++ [
"--sysconfdir=/etc"
# disable keyutils dependency, to avoid linking errors
Expand Down
2 changes: 0 additions & 2 deletions nix/tools/devTools.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
, devCabalOptions
, entr
, git
, gnugrep
, graphviz
, haskellPackages
, hsie
, nix
, silver-searcher
Expand Down
5 changes: 4 additions & 1 deletion nix/tools/style.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
, black
, buildToolbox
, checkedShellScript
, deadnix
, git
, hlint
, hsie
Expand Down Expand Up @@ -65,10 +66,12 @@ let
echo "Linting workflows..."
${actionlint}/bin/actionlint
echo "Scanning nix files for unused code..."
${deadnix}/bin/deadnix
echo "Checking consistency of import aliases in Haskell code..."
${hsie} check-aliases main src
echo "Linting Haskell files..."
# --vimgrep fixes a bug in ag: https://github.com/ggreer/the_silver_searcher/issues/753
${silver-searcher}/bin/ag -l --vimgrep -g '\.l?hs$' . \
Expand Down
30 changes: 1 addition & 29 deletions nix/tools/withTools.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
{ bash-completion
, buildToolbox
, cabal-install
, cabalTools
{ buildToolbox
, checkedShellScript
, curl
, devCabalOptions
, git
, lib
, postgresqlVersions
Expand Down Expand Up @@ -276,30 +272,6 @@ let
log-level="$(PGRST_LOG_LEVEL)"
'';

waitForPgrstPid =
checkedShellScript
{
name = "postgrest-wait-for-pgrst-pid";
docs = "Wait for PostgREST to be running. Needs to be a separate command for timeout to work below.";
args = [
"ARG_USE_ENV([PGRST_SERVER_UNIX_SOCKET], [], [Unix socket to check for running PostgREST instance])"
];
}
''
# ARG_USE_ENV only adds defaults or docs for environment variables
# We manually implement a required check here
# See also: https://github.com/matejak/argbash/issues/80
: "''${PGRST_SERVER_UNIX_SOCKET:?PGRST_SERVER_UNIX_SOCKET is required}"
until [ -S "$PGRST_SERVER_UNIX_SOCKET" ]
do
sleep 0.1
done
# return pid of postgrest process
lsof -t -c '/^postgrest$/' "$PGRST_SERVER_UNIX_SOCKET"
'';

waitForPgrstReady =
checkedShellScript
{
Expand Down

0 comments on commit ccc386c

Please sign in to comment.