-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add :deps/prep-lib support for git dependencies
Source dependencies may require a "prep" step e.g. to compile Java source[1]. This patch adds support for this but only for git dependencies since that's the only dependency type which implements this at the moment anyway[2]. This is achieved by extracing the necessary info from `deps.edn` to the lockfile. A second pass over the constructed Clojure home derived from the lockfile then picks out all the git libs which need prepping, runs the respective command for them and finally constructs a new home with the prepped libs. 1: See https://clojure.org/guides/deps_and_cli#prep_libs 2: Technically, :local/root dependencies also implement it but `clojure-nix-locker` doesn't have to handle these.
- Loading branch information
1 parent
a5e03fb
commit 7d3a7a8
Showing
4 changed files
with
95 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
{ 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. | ||
''; | ||
}; | ||
}; | ||
wrapClojure = homeDirectory: clojure: | ||
(pkgs.runCommandNoCC "locked-clojure" { buildInputs = [ pkgs.makeWrapper ]; } '' | ||
mkdir -p $out/bin | ||
makeWrapper ${clojure}/bin/clojure $out/bin/clojure \ | ||
--run "source ${shellEnv homeDirectory}" | ||
makeWrapper ${clojure}/bin/clj $out/bin/clj \ | ||
--run "source ${shellEnv homeDirectory}" | ||
''); | ||
} |