summaryrefslogtreecommitdiffstats
path: root/krebs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2017-02-09 16:13:26 +0100
committertv <tv@krebsco.de>2017-02-09 16:13:26 +0100
commite78a8c0725cbcf3179d63f8f94ca77e7ccb345d8 (patch)
treee063bf08baddc3ae58baa91e00a101e11417d563 /krebs
parentbf81d1b6b97703c9e5f08c73b8a8490d25bca277 (diff)
write{Jq,Python*}: use writeOut
Diffstat (limited to 'krebs')
-rw-r--r--krebs/5pkgs/writers.nix63
1 files changed, 30 insertions, 33 deletions
diff --git a/krebs/5pkgs/writers.nix b/krebs/5pkgs/writers.nix
index 6e33a6507..fe8fe5d72 100644
--- a/krebs/5pkgs/writers.nix
+++ b/krebs/5pkgs/writers.nix
@@ -252,17 +252,16 @@ with import <stockholm/lib>;
'';
};
- writeJq = name: text: pkgs.runCommand name {
- inherit text;
- passAsFile = [ "text" ];
- } /* sh */ ''
- name=${assert types.filename.check name; name}
-
- # syntax check
- ${pkgs.jq}/bin/jq -f "$textPath" -n
-
- cp "$textPath" "$out"
- '';
+ writeJq = name: text:
+ assert (with types; either absolute-pathname filename).check name;
+ pkgs.writeOut (baseNameOf name) {
+ ${optionalString (types.absolute-pathname.check name) name} = {
+ check = pkgs.writeDash "jqcheck.sh" ''
+ exec ${pkgs.jq}/bin/jq -f "$1" -n
+ '';
+ inherit text;
+ };
+ };
writeJSON = name: value: pkgs.writeText name (toJSON value);
@@ -275,29 +274,27 @@ with import <stockholm/lib>;
${pkgs.cabal2nix}/bin/cabal2nix ${path} > $out
'');
- writePython2 = name: text: pkgs.runCommand name {
- inherit text;
- passAsFile = [ "text" ];
- } /* sh */ ''
- name=${assert types.filename.check name; name}
-
- # syntax check
- ${pkgs.python2}/bin/python -m py_compile "$textPath"
-
- cp "$textPath" "$out"
- '';
-
- writePython3 = name: text: pkgs.runCommand name {
- inherit text;
- passAsFile = [ "text" ];
- } /* sh */ ''
- name=${assert types.filename.check name; name}
-
- # syntax check
- ${pkgs.python3}/bin/python -m py_compile "$textPath"
+ writePython2 = name: text:
+ assert (with types; either absolute-pathname filename).check name;
+ pkgs.writeOut (baseNameOf name) {
+ ${optionalString (types.absolute-pathname.check name) name} = {
+ check = pkgs.writeDash "python2check.sh" ''
+ exec ${pkgs.python2}/bin/python -m py_compile "$1"
+ '';
+ inherit text;
+ };
+ };
- cp "$textPath" "$out"
- '';
+ writePython3 = name: text:
+ assert (with types; either absolute-pathname filename).check name;
+ pkgs.writeOut (baseNameOf name) {
+ ${optionalString (types.absolute-pathname.check name) name} = {
+ check = pkgs.writeDash "python3check.sh" ''
+ exec ${pkgs.python3}/bin/python -m py_compile "$textPath"
+ '';
+ inherit text;
+ };
+ };
writeSed = pkgs.makeScriptWriter "${pkgs.gnused}/bin/sed -f";
};