07cb47e6ac
* Improve dev tools in the nix environment Added postgrest-build, postgrest-run, postgrest-clean, postgrest-check and postgrest-watch tools. Changed order of postgrest-test-spec-all to run backwards from pg13 to pg9.5. Added shellcheck to lint shell scripts in nix environment. Co-authored-by: monacoremo <monacoremo>
44 lines
891 B
Nix
44 lines
891 B
Nix
# Create a bash script that is checked with shellcheck. You can either use it
|
|
# directly, or use the .bin attribute to get the script in a bin/ directory,
|
|
# to be used in a path for example.
|
|
{ writeTextFile
|
|
, runtimeShell
|
|
, runCommand
|
|
, stdenv
|
|
, shellcheck
|
|
}:
|
|
name: text:
|
|
let
|
|
writeBin =
|
|
name: text:
|
|
writeTextFile {
|
|
inherit name;
|
|
executable = true;
|
|
destination = "/bin/${name}";
|
|
|
|
text =
|
|
''
|
|
#!${runtimeShell}
|
|
set -euo pipefail
|
|
|
|
${text}
|
|
'';
|
|
|
|
checkPhase =
|
|
''
|
|
# check syntax
|
|
${stdenv.shell} -n $out/bin/${name}
|
|
|
|
# check for shellcheck recommendations
|
|
${shellcheck}/bin/shellcheck $out/bin/${name}
|
|
'';
|
|
};
|
|
|
|
bin =
|
|
writeBin name text;
|
|
|
|
script =
|
|
runCommand name { inherit bin name; } "ln -s $bin/bin/$name $out";
|
|
in
|
|
script // { inherit bin; }
|