-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
update nix files to use gradle2nix v2
- Loading branch information
Showing
3 changed files
with
28 additions
and
103 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,110 +1,34 @@ | ||
{ lib | ||
, stdenv | ||
, makeWrapper | ||
, substituteAll | ||
, gradle_8 | ||
, jdk | ||
, clang | ||
, gcc | ||
, coreutils | ||
, findutils | ||
, gnused | ||
, perl | ||
{ | ||
lib, | ||
buildGradlePackage, | ||
jdk, | ||
coreutils, | ||
findutils, | ||
gnused, | ||
gcc, | ||
}: | ||
|
||
stdenv.mkDerivation (finalAttrs: { | ||
buildGradlePackage rec { | ||
pname = "c-worksheet-instrumentor"; | ||
version = lib.strings.removeSuffix "\n" (builtins.readFile ./version); | ||
|
||
src = builtins.path { path = ./.; name = finalAttrs.pname; }; | ||
|
||
patches = [ | ||
# use `deps` maven repo so that gradle can build offline. | ||
(substituteAll { | ||
src = ./use-fod-maven-repo.patch; | ||
inherit (finalAttrs) deps; | ||
}) | ||
]; | ||
|
||
# helper build to pre-download deps into fixed-output derivation | ||
deps = stdenv.mkDerivation { | ||
name = "${finalAttrs.pname}-${finalAttrs.version}-deps"; | ||
inherit (finalAttrs) src; | ||
|
||
nativeBuildInputs = [ | ||
clang | ||
gradle_8 | ||
perl | ||
]; | ||
|
||
buildPhase = '' | ||
runHook preBuild | ||
export GRADLE_USER_HOME=$(mktemp -d) | ||
gradle --no-daemon --console=plain build | ||
runHook postBuild | ||
''; | ||
|
||
# perl code mavenizes pathes (com.example.foo/foo/1.0.0/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/foo-1.0.0.jar -> com/example/foo/foo/1.0.0/foo-1.0.0.jar) | ||
installPhase = '' | ||
runHook preInstall | ||
find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\(jar\|pom\|module\)' \ | ||
| perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \ | ||
| sh | ||
runHook postInstall | ||
''; | ||
|
||
# Remember to update FOD outputHash whenever build.gradle dependencies change | ||
outputHashAlgo = "sha256"; | ||
outputHashMode = "recursive"; | ||
outputHash = "sha256-xw7DoUKkGYsGxVHxgl3qhWjQRanHvGDyP2jVt3ynjGw="; | ||
lockFile = ./gradle.lock; | ||
src = builtins.path { | ||
path = ./.; | ||
name = pname; | ||
}; | ||
|
||
nativeBuildInputs = [ | ||
makeWrapper | ||
clang | ||
gradle_8 | ||
]; | ||
|
||
buildPhase = '' | ||
runHook preBuild | ||
export GRADLE_USER_HOME=$(mktemp -d) | ||
gradle --offline --no-daemon --console=plain build | ||
runHook postBuild | ||
''; | ||
|
||
doCheck = true; | ||
checkPhase = '' | ||
runHook preCheck | ||
gradle --offline --no-daemon --console=plain testIntegration | ||
runHook postCheck | ||
''; | ||
|
||
installPhase = let | ||
gradleDistScriptDeps = [ coreutils findutils gnused ]; | ||
gradleFlags = ["build" "testIntegration" "installDist"]; | ||
installPhase = let | ||
gradleDistScriptDeps = [coreutils findutils gnused]; | ||
in '' | ||
runHook preInstall | ||
gradle --offline --no-daemon installDist | ||
mkdir -p $out | ||
cp -r build/install/${pname}/* $out | ||
mkdir -p $out/ | ||
cp -r build/install/${finalAttrs.pname}/* $out/ | ||
rm $out/bin/*.bat | ||
wrapProgram $out/bin/c-worksheet-instrumentor \ | ||
--set JAVA_HOME ${jdk.home} \ | ||
--suffix PATH : ${lib.makeBinPath (gradleDistScriptDeps ++ [ gcc ])} | ||
--suffix PATH : ${lib.makeBinPath (gradleDistScriptDeps ++ [gcc])} | ||
wrapProgram $out/bin/c-worksheetify-server \ | ||
--set JAVA_HOME ${jdk.home} \ | ||
--suffix PATH : ${lib.makeBinPath (gradleDistScriptDeps ++ [ gcc ])} | ||
runHook postInstall | ||
--suffix PATH : ${lib.makeBinPath (gradleDistScriptDeps ++ [gcc])} | ||
''; | ||
}) | ||
} |
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 |
---|---|---|
@@ -1,3 +1,5 @@ | ||
{ pkgs ? import <nixpkgs> {} }: | ||
|
||
pkgs.callPackage ./c-worksheet-instrumentor.nix { } | ||
{pkgs ? import <nixpkgs> {}}: let | ||
# my fork | ||
gradle2nix = import (fetchTarball "https://github.com/rgoulter/gradle2nix/archive/v2--always-set-gradle-user-home.tar.gz") {}; | ||
in | ||
pkgs.callPackage ./c-worksheet-instrumentor.nix {inherit (gradle2nix) buildGradlePackage;} |
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