diff options
Diffstat (limited to 'libs.nix')
-rw-r--r-- | libs.nix | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -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 | } |