-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathutils.nix
More file actions
31 lines (30 loc) · 1002 Bytes
/
utils.nix
File metadata and controls
31 lines (30 loc) · 1002 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
{ pkgs }:
rec {
shellEnv = homeDirectory: pkgs.writeTextFile {
name = "clojure-nix-locker.shell-env";
text = ''
export HOME="${homeDirectory}"
export JAVA_TOOL_OPTIONS="-Duser.home=${homeDirectory}"
'';
meta = {
description = ''
Can be sourced in shell scripts to export environment
variables so that `clojure` uses the locked dependencies.
'';
};
};
wrapPrograms = homeDirectory: name: paths:
let script = pkgs.lib.concatMapStrings (path: ''
makeWrapper "${path}" "$out/bin/$(basename "${path}")" \
--run "source ${shellEnv homeDirectory}"
'')
paths;
in
pkgs.runCommand name { buildInputs = [ pkgs.makeWrapper ]; } ''
mkdir -p $out/bin
${script}
'';
wrapClojure = homeDirectory: clojure:
wrapPrograms homeDirectory "locked-clojure" ["${clojure}/bin/clojure"
"${clojure}/bin/clj"];
}