-
Notifications
You must be signed in to change notification settings - Fork 1
/
default.nix
87 lines (79 loc) · 2.73 KB
/
default.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
{
sources ? import ./nix/sources.nix,
system ? builtins.currentSystem,
pkgs ?
import sources.nixpkgs {
overlays = [];
config = {};
inherit system;
},
}: let
DiffDetective =
import (builtins.fetchGit {
url = "https://github.com/VariantSync/DiffDetective.git";
rev = "913e714089496feb627eaed0d47282330d371df1";
ref = "main";
shallow = true;
}) {
inherit sources;
inherit system;
buildGitHubPages = false;
};
demo = pkgs.maven.buildMavenPackage rec {
pname = "DiffDetective-Demo";
# The single source of truth for the version number is stored in `pom.xml`.
# Hence, this XML file needs to be parsed to extract the current version.
version = pkgs.lib.removeSuffix "\n" (pkgs.lib.readFile
(pkgs.runCommandLocal "DiffDetective-version" {}
"${pkgs.xq-xml}/bin/xq -x '/project/version' ${./pom.xml} > $out"));
src = with pkgs.lib.fileset;
toSource {
root = ./.;
fileset = gitTracked ./.;
};
mvnHash = "sha256-8qh6MaHpmIG+DOX69J2CqzFJ+h0RBdRQKsXVC1MKgS4=";
mvnFetchExtraArgs = {
preBuild = ''
echo "Build dir: $out/.m2"
mkdir -p $out/.m2
# Copy the DiffDetective.jar into this build folder because Maven fails
# when an absolute path is provided.
cp ${DiffDetective}/share/java/DiffDetective/DiffDetective.jar .
mvn deploy:deploy-file -e -Durl=file:$out/.m2 -Dmaven.repo.local=$out/.m2 -Dfile=./DiffDetective.jar -Dversion=${DiffDetective.version} -DgroupId=org.variantsync -DartifactId=diffdetective
# Fix the reproducibility issues of `mvn deploy:deploy-file`
for f in $(find $out/.m2 -name '*.xml')
do
sed -i '/lastUpdated/ c\ <lastUpdated>2</lastUpdated>' "$f"
if [ -f "$f.md5" ]
then
md5sum "$f" | cut -f 1 -d ' ' > "$f.md5"
fi
if [ -f "$f.sha1" ]
then
sha1sum "$f" | cut -f 1 -d ' ' > "$f.sha1"
fi
done
'';
};
passthru = {
data-wrapper = pkgs.writeShellScriptBin "DiffDetective-Demo" ''
if ! [ -d data ]
then
cp -r ${src}/data .
chmod u+w -R data
fi
${demo}/bin/DiffDetective-Demo
'';
};
nativeBuildInputs = [pkgs.makeWrapper];
postInstall = ''
local jar="$out/share/java/DiffDetective-Demo.jar"
install -Dm644 "target/diffdetectivedemo-${version}-jar-with-dependencies.jar" "$jar"
makeWrapper "${pkgs.jre}/bin/java" "$out/bin/DiffDetective-Demo" \
--add-flags "-cp '$jar' org.variantsync.diffdetectivedemo.Main" \
--prefix PATH : "${pkgs.graphviz}/bin"
'';
meta.mainProgram = "DiffDetective-Demo";
};
in
demo