From e769ff083892d6e4daafee657dae4f2223ce7727 Mon Sep 17 00:00:00 2001 From: tv Date: Mon, 13 Jun 2016 01:28:43 +0200 Subject: lib.write{Files => Out}: admit file mode --- krebs/5pkgs/builders.nix | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'krebs/5pkgs') diff --git a/krebs/5pkgs/builders.nix b/krebs/5pkgs/builders.nix index 8ba0ab5a7..13f30ac41 100644 --- a/krebs/5pkgs/builders.nix +++ b/krebs/5pkgs/builders.nix @@ -81,12 +81,23 @@ rec { mv "$textPath" $out ''; - writeFiles = name: specs0: + writeOut = name: specs0: let - specs = mapAttrsToList (path: spec0: { - path = assert types.pathname.check path; path; + specs = mapAttrsToList (path0: spec0: rec { + path = guard { + type = types.pathname; + value = path0; + }; var = "file_${hashString "sha1" path}"; text = spec0.text; + executable = guard { + type = types.bool; + value = spec0.executable or false; + }; + mode = guard { + type = types.file-mode; + value = spec0.mode or (if executable then "0755" else "0644"); + }; }) specs0; filevars = genAttrs' specs (spec: nameValuePair spec.var spec.text); @@ -97,7 +108,7 @@ rec { set -efu PATH=${makeBinPath [pkgs.coreutils]} ${concatMapStrings (spec: /* sh */ '' - install -D ''$${spec.var}Path $out${spec.path} + install -m ${spec.mode} -D ''$${spec.var}Path $out${spec.path} '') specs} ''; -- cgit v1.2.3