From d59facd88c7d33d0ac125eb93392d2a67b46aea4 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 25 Nov 2016 00:15:13 +0100 Subject: writeOut: add support for text checking --- krebs/5pkgs/builders.nix | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'krebs/5pkgs/builders.nix') diff --git a/krebs/5pkgs/builders.nix b/krebs/5pkgs/builders.nix index 5860b9a15..77055d16a 100644 --- a/krebs/5pkgs/builders.nix +++ b/krebs/5pkgs/builders.nix @@ -91,6 +91,7 @@ rec { writers.text = { path + , check ? null , executable ? false , mode ? if executable then "0755" else "0644" , text @@ -102,6 +103,9 @@ rec { var = "file_${hashString "sha1" path}"; val = text; install = /* sh */ '' + ${optionalString (check != null) /* sh */ '' + ${check} ''$${var}Path + ''} ${pkgs.coreutils}/bin/install -m ${mode} -D ''$${var}Path $out${path} ''; }; -- cgit v1.2.3 From b3c6e9a2bde5d1c911d1bb17ca3218acab7285b8 Mon Sep 17 00:00:00 2001 From: tv Date: Fri, 25 Nov 2016 00:17:57 +0100 Subject: writeBash*: use shellcheck (for warnings only) --- krebs/5pkgs/builders.nix | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'krebs/5pkgs/builders.nix') diff --git a/krebs/5pkgs/builders.nix b/krebs/5pkgs/builders.nix index 77055d16a..49d04be4d 100644 --- a/krebs/5pkgs/builders.nix +++ b/krebs/5pkgs/builders.nix @@ -37,7 +37,17 @@ rec { }; }; - writeBash = makeScriptWriter "${pkgs.bash}/bin/bash"; + writeBash = 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 "shellcheck.sh" '' + ${pkgs.haskellPackages.ShellCheck}/bin/shellcheck "$1" || : + ''; + executable = true; + text = "#! ${pkgs.bash}/bin/bash\n${text}"; + }; + }; writeBashBin = name: assert types.filename.check name; -- cgit v1.2.3