summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/builders.nix
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2016-06-13 01:30:06 +0200
committertv <tv@krebsco.de>2016-06-13 01:38:58 +0200
commit0cfce6d18d93981db251611e276d4734d4ab0cde (patch)
treeb460cfe3f5a6eb2e27518755f7d60252c95f3c85 /krebs/5pkgs/builders.nix
parente769ff083892d6e4daafee657dae4f2223ce7727 (diff)
makeScriptWriter: init
Diffstat (limited to 'krebs/5pkgs/builders.nix')
-rw-r--r--krebs/5pkgs/builders.nix43
1 files changed, 17 insertions, 26 deletions
diff --git a/krebs/5pkgs/builders.nix b/krebs/5pkgs/builders.nix
index 13f30ac41..4aad51c5e 100644
--- a/krebs/5pkgs/builders.nix
+++ b/krebs/5pkgs/builders.nix
@@ -28,20 +28,20 @@ rec {
execveBin = name: cfg: execve name (cfg // { destination = "/bin/${name}"; });
- writeBash = name: text: pkgs.writeScript name ''
- #! ${pkgs.bash}/bin/bash
- ${text}
- '';
+ makeScriptWriter = interpreter: name: text:
+ assert (with types; either absolute-pathname filename).check name;
+ pkgs.writeOut (baseNameOf name) {
+ ${optionalString (types.absolute-pathname.check name) name} = {
+ executable = true;
+ text = "#! ${interpreter}\n${text}";
+ };
+ };
- writeBashBin = name: text: pkgs.writeTextFile {
- executable = true;
- destination = "/bin/${name}";
- name = name;
- text = ''
- #! ${pkgs.bash}/bin/bash
- ${text}
- '';
- };
+ writeBash = makeScriptWriter "${pkgs.bash}/bin/bash";
+
+ writeBashBin = name:
+ assert types.filename.check name;
+ pkgs.writeBash "/bin/${name}";
writeC = name: { destination ? "" }: src: pkgs.runCommand name {} ''
PATH=${makeBinPath (with pkgs; [
@@ -56,20 +56,11 @@ rec {
strip --strip-unneeded "$exe"
'';
- writeDash = name: text: pkgs.writeScript name ''
- #! ${pkgs.dash}/bin/dash
- ${text}
- '';
+ writeDash = makeScriptWriter "${pkgs.dash}/bin/dash";
- writeDashBin = name: text: pkgs.writeTextFile {
- executable = true;
- destination = "/bin/${name}";
- name = name;
- text = ''
- #! ${pkgs.dash}/bin/dash
- ${text}
- '';
- };
+ writeDashBin = name:
+ assert types.filename.check name;
+ pkgs.writeDash "/bin/${name}";
writeEximConfig = name: text: pkgs.runCommand name {
inherit text;