nix(refactor): Add buildToolbox to streamline module interface towards shell.nix

This commit is contained in:
Wolfgang Walther
2021-04-18 13:51:39 +02:00
committed by Wolfgang Walther
parent de73ced34a
commit fe497fc438
13 changed files with 94 additions and 91 deletions
+6 -10
View File
@@ -1,4 +1,4 @@
{ buildEnv
{ buildToolbox
, cabal-install
, checkedShellScript
, devCabalOptions
@@ -171,6 +171,10 @@ let
${hsieMinimalImports} graph-symbols | ${graphviz}/bin/dot -Tpng -o "$_arg_outfile"
'';
in
buildToolbox
{
name = "postgrest-devtools";
tools = [
watch
pushCachix
@@ -183,12 +187,4 @@ let
hsieGraphModules
hsieGraphSymbols
];
bashCompletion = builtins.map (tool: tool.bashCompletion) tools;
in
buildEnv
{
name = "postgrest-devtools";
paths = builtins.map (tool: tool.bin) tools;
} // { inherit bashCompletion; }
}
+10 -6
View File
@@ -1,4 +1,4 @@
{ buildEnv
{ buildToolbox
, postgrest
, dockerTools
, checkedShellScript
@@ -37,9 +37,13 @@ let
''
docker load -i ${image}
'';
in
buildEnv
{
name = "postgrest-docker";
paths = [ load.bin ];
} // { inherit image; bashCompletion = load.bashCompletion; }
buildToolbox
{
name = "postgrest-docker";
tools = [ load ];
extra = {
inherit image;
};
}
+6 -7
View File
@@ -1,7 +1,7 @@
# The memory tests have large dependencies (a profiled build of PostgREST)
# and are run less often than the spec tests, so we don't include them in
# the default test environment. We make them available through a separate module.
{ buildEnv
{ buildToolbox
, checkedShellScript
, curl
, postgrestProfiled
@@ -22,9 +22,8 @@ let
'';
in
buildEnv
{
name = "postgrest-memory";
paths = [ test.bin ];
} // { bashCompletion = test.bashCompletion; }
buildToolbox
{
name = "postgrest-memory";
tools = [ test ];
}
@@ -1,4 +1,5 @@
{ checkedShellScript
{ buildToolbox
, checkedShellScript
, curl
, jq
, nix
@@ -21,7 +22,7 @@ let
tarballUrlBase =
https://github.com/nixos/nixpkgs/archive/;
script =
upgrade =
checkedShellScript
{
inherit name;
@@ -43,5 +44,10 @@ let
}
EOF
'';
in
script
buildToolbox
{
name = "postgrest-nixpkgstools";
tools = [ upgrade ];
}
@@ -0,0 +1,16 @@
# Creates an environment that exposes bashCompletion arguments from all checkedShellScripts
{ buildEnv }:
{ name
, tools
, extra ? { }
}:
let
bashCompletion = builtins.map (tool: tool.bashCompletion) tools;
env = buildEnv {
inherit name;
paths = builtins.map (tool: tool.bin) tools;
};
in
env // { inherit bashCompletion; } // extra
+5
View File
@@ -0,0 +1,5 @@
self: super:
# Overlay that adds `buildToolbox`, an enhanced version of `buildEnv`
{
buildToolbox = super.callPackage ./build-toolbox.nix { };
}
+1
View File
@@ -1,4 +1,5 @@
{
build-toolbox = import ./build-toolbox;
checked-shell-script = import ./checked-shell-script;
ghr = import ./ghr;
gitignore = import ./gitignore.nix;
+6 -10
View File
@@ -1,4 +1,4 @@
{ buildEnv
{ buildToolbox
, checkedShellScript
, curl
, docker
@@ -166,13 +166,9 @@ let
[ "$responseCode" -eq 200 ]
'';
tools = [ github dockerLogin dockerHub dockerHubDescription ];
bashCompletion = builtins.map (tool: tool.bashCompletion) tools;
in
buildEnv
{
name = "postgrest-release";
paths = builtins.map (tool: tool.bin) tools;
} // { inherit bashCompletion; }
buildToolbox
{
name = "postgrest-release";
tools = [ github dockerLogin dockerHub dockerHubDescription ];
}
+6 -10
View File
@@ -1,5 +1,5 @@
{ black
, buildEnv
, buildToolbox
, checkedShellScript
, git
, hlint
@@ -60,13 +60,9 @@ let
${shellcheck}/bin/shellcheck test/create_test_db test/memory-tests.sh test/with_tmp_db
'';
tools = [ style styleCheck lint ];
bashCompletion = builtins.map (tool: tool.bashCompletion) tools;
in
buildEnv
{
name = "postgrest-style";
paths = builtins.map (tool: tool.bin) tools;
} // { inherit bashCompletion; }
buildToolbox
{
name = "postgrest-style";
tools = [ style styleCheck lint ];
}
+6 -16
View File
@@ -1,6 +1,4 @@
# Utilities for running the PostgREST test suite
{ buildEnv
{ buildToolbox
, cabal-install
, checkedShellScript
, devCabalOptions
@@ -156,6 +154,10 @@ let
sed -i 's|^module \(.*\):|module \1/|g' test/coverage.overlay
'';
in
buildToolbox
{
name = "postgrest-tests";
tools =
[
testSpec
@@ -165,16 +167,4 @@ let
coverage
coverageDraftOverlay
];
bashCompletion = builtins.map (tool: tool.bashCompletion) tools;
in
# Create an environment that contains all the utility scripts for running tests
# that we defined above.
buildEnv
{
name =
"postgrest-tests";
paths = builtins.map (tool: tool.bin) tools;
} // { inherit bashCompletion; }
}
+9 -16
View File
@@ -1,5 +1,5 @@
{ bashCompletion
, buildEnv
, buildToolbox
, checkedShellScript
, lib
, postgresqlVersions
@@ -77,20 +77,13 @@ let
# Create a `postgrest-with-postgresql-` for each PostgreSQL version
withVersions = builtins.map withTmpDb postgresqlVersions;
tools = [ withAll ] ++ withVersions;
bashCompletion = builtins.map (tool: tool.bashCompletion) tools;
in
buildEnv
{
name =
"postgrest-withtools";
paths = builtins.map (tool: tool.bin) tools;
} // {
inherit bashCompletion;
# make withTools.latest available for other nix files
latest = withTmpDb (builtins.head postgresqlVersions);
buildToolbox
{
name = "postgrest-withtools";
tools = [ withAll ] ++ withVersions;
extra = {
# make withTools.latest available for other nix files
latest = withTmpDb (builtins.head postgresqlVersions);
};
}