diff options
author | deliciouslytyped <47436522+deliciouslytyped@users.noreply.github.com> | 2019-05-06 19:08:23 +0200 |
---|---|---|
committer | deliciouslytyped <47436522+deliciouslytyped@users.noreply.github.com> | 2019-05-12 19:40:01 +0200 |
commit | 103ab24e947ba17e6e0d9111246257d50f010859 (patch) | |
tree | 96daccf50a15d2c5c42c2d257347fccff003904e /pkgs/build-support/trivial-builders.nix | |
parent | c910fe9d2929ba22b2dec9576213579d69dcb500 (diff) | |
download | nixpkgs-103ab24e947ba17e6e0d9111246257d50f010859.tar nixpkgs-103ab24e947ba17e6e0d9111246257d50f010859.tar.gz nixpkgs-103ab24e947ba17e6e0d9111246257d50f010859.tar.bz2 nixpkgs-103ab24e947ba17e6e0d9111246257d50f010859.tar.lz nixpkgs-103ab24e947ba17e6e0d9111246257d50f010859.tar.xz nixpkgs-103ab24e947ba17e6e0d9111246257d50f010859.tar.zst nixpkgs-103ab24e947ba17e6e0d9111246257d50f010859.zip |
trivial-builders: add writeShellScript and minor cleaning
Add writeShellScript Small whitespace additions Fix "Example:" docstring sections for some of the writeScript functions to use the correct function
Diffstat (limited to 'pkgs/build-support/trivial-builders.nix')
-rw-r--r-- | pkgs/build-support/trivial-builders.nix | 38 |
1 files changed, 33 insertions, 5 deletions
diff --git a/pkgs/build-support/trivial-builders.nix b/pkgs/build-support/trivial-builders.nix index e498417adf0..f56ce7bb87d 100644 --- a/pkgs/build-support/trivial-builders.nix +++ b/pkgs/build-support/trivial-builders.nix @@ -79,7 +79,6 @@ rec { (test -n "$executable" && chmod +x "$n") || true ''; - /* * Writes a text file to nix store with no optional parameters available. * @@ -92,6 +91,7 @@ rec { * */ writeText = name: text: writeTextFile {inherit name text;}; + /* * Writes a text file to nix store in a specific directory with no * optional parameters available. Name passed is the destination. @@ -105,6 +105,7 @@ rec { * */ writeTextDir = name: text: writeTextFile {inherit name text; destination = "/${name}";}; + /* * Writes a text file to /nix/store/<store path> and marks the file as executable. * @@ -117,13 +118,14 @@ rec { * */ writeScript = name: text: writeTextFile {inherit name text; executable = true;}; + /* * Writes a text file to /nix/store/<store path>/bin/<name> and * marks the file as executable. * * Example: * # Writes my-file to /nix/store/<store path>/bin/my-file and makes executable. - * writeScript "my-file" + * writeScriptBin "my-file" * '' * Contents of File * ''; @@ -132,12 +134,38 @@ rec { writeScriptBin = name: text: writeTextFile {inherit name text; executable = true; destination = "/bin/${name}";}; /* - * Writes a Shell script and check its syntax. Automatically includes interpreter - * above the contents passed. + * Similar to writeScript. Writes a Shell script and checks its syntax. + * Automatically includes interpreter above the contents passed. + * + * Example: + * # Writes my-file to /nix/store/<store path>/my-file and makes executable. + * writeShellScript "my-file" + * '' + * Contents of File + * ''; + * + */ + writeShellScript = name: text: + writeTextFile { + inherit name; + executable = true; + text = '' + #!${runtimeShell} + ${text} + ''; + checkPhase = '' + ${stdenv.shell} -n $out + ''; + }; + + /* + * Similar to writeShellScript and writeScriptBin. + * Writes an executable Shell script to /nix/store/<store path>/bin/<name> and checks its syntax. + * Automatically includes interpreter above the contents passed. * * Example: * # Writes my-file to /nix/store/<store path>/bin/my-file and makes executable. - * writeScript "my-file" + * writeShellScriptBin "my-file" * '' * Contents of File * ''; |