-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
maven.nix
35 lines (34 loc) · 1.28 KB
/
maven.nix
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
32
33
34
35
{ lib, fetchurl, linkFarm }:
with lib; rec {
# Create a maven environment from the output of the mvn2nix command
# the resulting store path can be used as the a .m2 repository for subsequent
# maven invocations.
# ex.
# mvn package --offline -Dmaven.repo.local=${repository}
#
# @param dependencies: A attrset of dependencies to build the repository
buildMavenRepository = { dependencies }:
let
dependenciesAsDrv = (forEach (attrValues dependencies) (dependency: {
drv = fetchurl {
url = dependency.url;
sha256 = dependency.sha256;
};
layout = dependency.layout;
}));
in linkFarm "mvn2nix-repository" (forEach dependenciesAsDrv (dependency: {
name = dependency.layout;
path = dependency.drv;
}));
# Create a maven environment from the output of the mvn2nix command
# the resulting store path can be used as the a .m2 repository for subsequent
# maven invocations.
# ex.
# mvn package --offline -Dmaven.repo.local=${repository}
#
# @param file: A path to a file containing the JSON output of running mvn2nix
buildMavenRepositoryFromLockFile = { file }:
let
dependencies = (builtins.fromJSON (builtins.readFile file)).dependencies;
in buildMavenRepository { inherit dependencies; };
}