-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
111 lines (92 loc) · 3.35 KB
/
flake.nix
File metadata and controls
111 lines (92 loc) · 3.35 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
{
description = "";
inputs.nixpkgs.url = "github:nixos/nixpkgs";
outputs = { self, nixpkgs }: let
forAllSystems = nixpkgs.lib.genAttrs [ "aarch64-linux" "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ];
in
rec {
packages = forAllSystems (system: let
pkgs = nixpkgs.legacyPackages.${system};
deps = pkgs.stdenv.mkDerivation {
pname = "RRSS-deps";
version = "0.0";
src = ./.;
nativeBuildInputs = [ pkgs.gradle pkgs.perl ] ++ pkgs.lib.optional pkgs.stdenv.isDarwin pkgs.xcbuild;
buildPhase = ''
export GRADLE_USER_HOME=$(mktemp -d)
gradle --no-daemon -x test build
'';
# perl code mavenizes pathes (com.squareup.okio/okio/1.13.0/a9283170b7305c8d92d25aff02a6ab7e45d06cbe/okio-1.13.0.jar -> com/squareup/okio/okio/1.13.0/okio-1.13.0.jar)
installPhase = ''
find $GRADLE_USER_HOME -type f -regex '.*/modules.*\.\(jar\|pom\)' \
| perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \
| sh
rm -rf $out/tmp
'';
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = "sha256-XEU1vf1wXJouud3ny9wWd9gE5Xb4I5tI9f1fDCuwSt4=";
};
in
{
default = pkgs.stdenv.mkDerivation {
name = "RRSS";
version = "0.1";
src = ./.;
nativeBuildInputs = with pkgs; [ gradle openjdk21 makeWrapper ];
patchPhase = ''
runHook prePatch
sed -i '/docker-compose/d' build.gradle
substituteInPlace build.gradle --replace 'mavenCentral()' 'mavenLocal() maven { url uri("${deps}") }'
mkdir -p ../.m2/
ln -s ${deps} ../.m2/repository
runHook postPatch
'';
buildPhase = ''
runHook preBuild
echo "***This does not build as Gradle is a 'fast, dependable, and adaptable open-source build automation tool with an elegant and extensible declarative build language.'***"
false
export M2_HOME="${deps}"
gradle --no-daemon -x test build
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/lib $out/bin
cp -r build/libs/*.jar $out/lib/rrss.jar
makeWrapper ${pkgs.jre}/bin/java $out/bin/rrss
runHook postInstall
'';
};
});
devShells = forAllSystems (system: let
pkgs = nixpkgs.legacyPackages.${system};
in
{
default = pkgs.mkShell {
nativeBuildInputs = packages.${system}.default.nativeBuildInputs ++ [ pkgs.clang-tools ];
};
}
);
checks = forAllSystems (system: let
pkgs = nixpkgs.legacyPackages.${system};
in
rec {
default = rrss-java-fmt;
rrss-java-fmt = pkgs.runCommand "rrss-java-fmt" { src = self; buildInputs = [ pkgs.clang-tools ]; } ''
mkdir -p $out
cp -r $src/* $out
chmod -R u+w $out
JAVA_FILES="$(find $out/src -name '*.java')"
if ! clang-format -n --Werror --style=file $JAVA_FILES; then
clang-format --style=file -i $JAVA_FILES
for f in $JAVA_FILES; do
diff --color=always -u $(sed "s|$out|$src|" <<< "$f") "$f" || true
done
exit 1
fi
'';
}
);
};
}