-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: make mkCommand signature more ergonomic in block type devel…
…opment
- Loading branch information
Showing
15 changed files
with
82 additions
and
71 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,43 @@ | ||
{nixpkgs}: currentSystem: name: description: command: args: let | ||
{nixpkgs}: currentSystem: name: description: deps: command: args: let | ||
inherit (nixpkgs.legacyPackages.${currentSystem}) pkgs; | ||
inherit (pkgs) lib stdenv haskell shellcheck runtimeShell; | ||
inherit (pkgs.haskell.lib.compose) justStaticExecutables; | ||
in | ||
args | ||
// { | ||
inherit name description; | ||
command = | ||
pkgs.writeShellScript "${name}" ('' | ||
set -e | ||
command = pkgs.writeTextFile { | ||
inherit name; | ||
executable = true; | ||
checkPhase = '' | ||
runHook preCheck | ||
${stdenv.shellDryRun} "$target" | ||
# use shellcheck which does not include docs | ||
# pandoc takes long to build and documentation isn't needed for in nixpkgs usage | ||
${lib.getExe (justStaticExecutables shellcheck.unwrapped)} "$target" | ||
runHook postCheck | ||
''; | ||
text = | ||
'' | ||
#!${runtimeShell} | ||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
if test -z "$PRJ_ROOT"; then | ||
echo "All Standard Block Type Actions require an environment that fulfills the PRJ Base Directiory Specification" | ||
echo "see: https://github.com/numtide/prj-spec" | ||
echo "Tip: To achieve that, you can enter a Standard direnv environment or run the action via the Standard CLI/TUI" | ||
exit 1 | ||
fi | ||
if test -z "$PRJ_ROOT"; then | ||
echo "All Standard Block Type Actions require an environment that fulfills the PRJ Base Directiory Specification" | ||
echo "see: https://github.com/numtide/prj-spec" | ||
echo "Tip: To achieve that, you can enter a Standard direnv environment or run the action via the Standard CLI/TUI" | ||
exit 1 | ||
fi | ||
# Action Code follows ... | ||
'' | ||
+ command); | ||
# Action Code follows ... | ||
'' | ||
+ lib.optionalString (deps != []) '' | ||
# Be optionally reproducible due to potential overhead to load some | ||
# quaasi-ubiquitous dependencies that are already generally available | ||
export PATH="${lib.makeBinPath deps}:$PATH" | ||
'' | ||
+ command; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters