summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/writers.nix
diff options
context:
space:
mode:
Diffstat (limited to 'krebs/5pkgs/writers.nix')
-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";
};