diff options
author | zimbatm <zimbatm@zimbatm.com> | 2019-02-22 13:33:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-02-22 13:33:26 +0100 |
commit | b6c82183be6c1118fd52220887722601ed86bd76 (patch) | |
tree | a6c01bb994a9287136128eafde87af3f045fbb46 /pkgs/tools/text/shab | |
parent | b275d092249b6e2899d4bf93a87d69a41b965aae (diff) | |
download | nixpkgs-b6c82183be6c1118fd52220887722601ed86bd76.tar nixpkgs-b6c82183be6c1118fd52220887722601ed86bd76.tar.gz nixpkgs-b6c82183be6c1118fd52220887722601ed86bd76.tar.bz2 nixpkgs-b6c82183be6c1118fd52220887722601ed86bd76.tar.lz nixpkgs-b6c82183be6c1118fd52220887722601ed86bd76.tar.xz nixpkgs-b6c82183be6c1118fd52220887722601ed86bd76.tar.zst nixpkgs-b6c82183be6c1118fd52220887722601ed86bd76.zip |
shab: init at 1.0.0 (#56164)
Diffstat (limited to 'pkgs/tools/text/shab')
-rw-r--r-- | pkgs/tools/text/shab/default.nix | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/pkgs/tools/text/shab/default.nix b/pkgs/tools/text/shab/default.nix new file mode 100644 index 00000000000..73323c784fd --- /dev/null +++ b/pkgs/tools/text/shab/default.nix @@ -0,0 +1,74 @@ +{ bash, stdenv, lib, runCommand, writeText, fetchFromGitHub }: +let + version = "1.0.0"; + + shab = stdenv.mkDerivation { + pname = "shab"; + inherit version; + + src = fetchFromGitHub { + owner = "zimbatm"; + repo = "shab"; + rev = "v${version}"; + sha256 = "02lf1s6plhhcfyj9xha44wij9jbphb1x5q55xj3b5bx2ji2jsvji"; + }; + + postPatch = '' + for f in test.sh test/*.sh; do + patchShebangs "$f" + done + ''; + + doBuild = false; + doCheck = true; + doInstallCheck = true; + + checkPhase = '' + ./test.sh + ''; + + installPhase = '' + mkdir -p $out/bin + cp ./shab $out/bin/shab + ''; + + installCheckPhase = '' + [[ "$(echo 'Hello $entity' | entity=world $out/bin/shab)" == 'Hello world' ]] + ''; + + passthru = { + inherit render renderText; + }; + + meta = with lib; { + description = "The bash templating language"; + homepage = https://github.com/zimbatm/shab; + license = licenses.unlicense; + maintainers = with maintainers; [ zimbatm ]; + platforms = bash.meta.platforms; + }; + }; + + /* + shabScript: a path or filename to use as a template + parameters.name: the name to use as part of the store path + parameters: variables to expose to the template + */ + render = shabScript: parameters: + let extraParams = { + inherit shabScript; + }; + in runCommand "out" (parameters // extraParams) '' + ${shab}/bin/shab "$shabScript" >$out + ''; + + /* + shabScriptText: a string to use as a template + parameters.name: the name to use as part of the store path + parameters: variables to expose to the template + */ + renderText = shabScriptText: parameters: + render (writeText "template" shabScriptText) parameters; + +in + shab |