aboutsummaryrefslogtreecommitdiff
path: root/libs.nix
diff options
context:
space:
mode:
Diffstat (limited to 'libs.nix')
-rw-r--r--libs.nix18
1 files changed, 18 insertions, 0 deletions
diff --git a/libs.nix b/libs.nix
index c85808b..ad517f2 100644
--- a/libs.nix
+++ b/libs.nix
@@ -37,4 +37,22 @@ in
37 }; 37 };
38 38
39 checkEnv = var: builtins.stringLength (builtins.getEnv var) > 0; 39 checkEnv = var: builtins.stringLength (builtins.getEnv var) > 0;
40
41 wrap = { paths ? [], vars ? {}, file ? null, script ? null, name ? "wrap" }:
42 assert file != null || script != null ||
43 abort "wrap needs 'file' or 'script' argument";
44 with rec {
45 set = n: v: "--set ${pkgs.lib.escapeShellArg n} " +
46 "${pkgs.lib.escapeShellArg v}";
47 args = (map (p: "--prefix PATH : ${p}/bin") paths) ++
48 (builtins.attrValues (pkgs.lib.mapAttrs set vars));
49 };
50 runCommand name
51 {
52 f = if file == null then writeScript name script else file;
53 buildInputs = [ makeWrapper ];
54 }
55 ''
56 makeWrapper "$f" "$out" ${toString args}
57 '';
40} 58}