diff options
author | Igor Pashev <pashev.igor@gmail.com> | 2018-01-07 20:50:13 +0300 |
---|---|---|
committer | Igor Pashev <pashev.igor@gmail.com> | 2018-01-07 20:50:13 +0300 |
commit | a63ea35a7d4f1e33f9b56e6637dea441ab9783f7 (patch) | |
tree | a80af528c49907da50a35a2fabf2ee530cebed80 | |
parent | 0efa103537a6b28a884603326cac38f89ceff9f8 (diff) | |
download | nixsap-a63ea35a7d4f1e33f9b56e6637dea441ab9783f7.tar.gz |
Refactor writeFoo to use writeTextFile
-rw-r--r-- | modules/pkgs/writeBashScript.nix | 28 | ||||
-rw-r--r-- | modules/pkgs/writePHPFile.nix | 16 | ||||
-rw-r--r-- | modules/pkgs/writeXML.nix | 19 |
3 files changed, 36 insertions, 27 deletions
diff --git a/modules/pkgs/writeBashScript.nix b/modules/pkgs/writeBashScript.nix index 15e81c5..b193122 100644 --- a/modules/pkgs/writeBashScript.nix +++ b/modules/pkgs/writeBashScript.nix @@ -1,13 +1,21 @@ -{ bash, writeScript, haskellPackages, runCommand }: +{ bash, writeTextFile, haskellPackages }: -name: text: let - f = writeScript name '' - #!${bash}/bin/bash - ${text} - ''; + + shellcheck = haskellPackages.ShellCheck; + in -runCommand name { } '' - ${haskellPackages.ShellCheck}/bin/shellcheck ${f} - cp -a ${f} $out -'' + +name: text: + writeTextFile + { + inherit name; + executable = true; + text = '' + #!${bash}/bin/bash + ${text} + ''; + checkPhase = '' + ${shellcheck}/bin/shellcheck "$out" + ''; + } diff --git a/modules/pkgs/writePHPFile.nix b/modules/pkgs/writePHPFile.nix index e031efe..495083f 100644 --- a/modules/pkgs/writePHPFile.nix +++ b/modules/pkgs/writePHPFile.nix @@ -1,10 +1,10 @@ -{ php, writeText, runCommand }: +{ writeTextFile, php }: name: text: -let - f = writeText name text; -in -runCommand name { } '' - ${php}/bin/php -l '${f}' - cp -a '${f}' $out -'' + writeTextFile + { + inherit name text; + checkPhase = '' + ${php}/bin/php -l "$out" + ''; + } diff --git a/modules/pkgs/writeXML.nix b/modules/pkgs/writeXML.nix index 1cfc075..9ad3826 100644 --- a/modules/pkgs/writeXML.nix +++ b/modules/pkgs/writeXML.nix @@ -1,11 +1,12 @@ -{ writeText, runCommand, libxml2 }: +{ writeTextFile, libxml2 }: name: text: - let - f = writeText "${name}.raw" text; - in - runCommand name { } '' - ${libxml2}/bin/xmllint \ - --format --noblanks --nocdata ${f} \ - > $out - '' + writeTextFile + { + inherit name text; + checkPhase = '' + ${libxml2.bin}/bin/xmllint \ + --format --noblanks --nocdata "$out" > linted + mv linted "$out" + ''; + } |