From f49c2fbf7a0594717a16432295983512091fba26 Mon Sep 17 00:00:00 2001 From: Sergey Mironov Date: Thu, 28 Jan 2016 01:26:40 +0300 Subject: [PATCH] trivial-builders.nix: add writeShellScriptBin builder --- pkgs/build-support/trivial-builders.nix | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/pkgs/build-support/trivial-builders.nix b/pkgs/build-support/trivial-builders.nix index 16bd4e8e4054..14553c33e039 100644 --- a/pkgs/build-support/trivial-builders.nix +++ b/pkgs/build-support/trivial-builders.nix @@ -26,6 +26,7 @@ rec { , text , executable ? false # run chmod +x ? , destination ? "" # relative path appended to $out eg "/bin/foo" + , checkPhase ? "" # syntax checks, e.g. for scripts }: runCommand name { inherit text executable; @@ -44,6 +45,8 @@ rec { echo -n "$text" > "$n" fi + ${checkPhase} + (test -n "$executable" && chmod +x "$n") || true ''; @@ -54,6 +57,20 @@ rec { writeScript = name: text: writeTextFile {inherit name text; executable = true;}; writeScriptBin = name: text: writeTextFile {inherit name text; executable = true; destination = "/bin/${name}";}; + # Create a Shell script, check its syntax + writeShellScriptBin = name : text : + writeTextFile { + inherit name; + executable = true; + destination = "/bin/${name}"; + text = '' + #!${stdenv.shell} + ${text} + ''; + checkPhase = '' + ${stdenv.shell} -n $out + ''; + }; # Create a forest of symlinks to the files in `paths'. symlinkJoin =