1- { stdenv , lib , fetchFromGitHub , writeText , gradle_7 , pkg-config , perl , cmake
2- , gperf , gtk2 , gtk3 , libXtst , libXxf86vm , glib , alsa-lib , ffmpeg_4-headless , python3 , ruby , fetchurl , runCommand
1+ { stdenv , lib , pkgs , fetchFromGitHub , writeText , gradle_7 , pkg-config , perl , cmake
2+ , gperf , gtk2 , gtk3 , libXtst , libXxf86vm , glib , alsa-lib , ffmpeg_4-headless , python3 , ruby
33, openjdk11-bootstrap
44, withMedia ? true
55, withWebKit ? false
66} :
77
88let
9+ pname = "openjfx-modular-sdk" ;
910 major = "11" ;
1011 update = ".0.20" ;
1112 build = "1" ;
1213 repover = "${ major } ${ update } +${ build } " ;
13- gradle_ = ( gradle_7 . override {
14- java = openjdk11-bootstrap ;
15- } ) ;
16-
17- icuVersionWithSep = s : "71${ s } 1" ;
18- icuPath = "download/release-${ icuVersionWithSep "-" } /icu4c-${ icuVersionWithSep "_" } -data-bin-l.zip" ;
19- icuData = fetchurl {
20- url = "https://github.com/unicode-org/icu/releases/${ icuPath } " ;
21- hash = "sha256-pVWIy0BkICsthA5mxhR9SJQHleMNnaEcGl/AaLi5qZM=" ;
14+ jdk = openjdk11-bootstrap ;
15+ gradle = gradle_7 ;
16+
17+ in stdenv . mkDerivation {
18+ inherit pname ;
19+ version = "${ major } ${ update } -${ build } " ;
20+
21+ src = fetchFromGitHub {
22+ owner = "openjdk" ;
23+ repo = "jfx${ major } u" ;
24+ rev = repover ;
25+ sha256 = "sha256-BbBP2DiPZTSn1SBYMCgyiNdF9GD+NqR6YjeVNOQHHn4=" ;
2226 } ;
23- icuFakeRepository = runCommand "icu-data-repository" { } ''
24- install -Dm644 ${ icuData } $out/${ icuPath }
25- '' ;
2627
27- makePackage = args : stdenv . mkDerivation ( {
28- version = "${ major } ${ update } -${ build } " ;
29-
30- src = fetchFromGitHub {
31- owner = "openjdk" ;
32- repo = "jfx${ major } u" ;
33- rev = repover ;
34- sha256 = "sha256-BbBP2DiPZTSn1SBYMCgyiNdF9GD+NqR6YjeVNOQHHn4=" ;
35- } ;
36-
37- buildInputs = [ gtk2 gtk3 libXtst libXxf86vm glib alsa-lib ffmpeg_4-headless ] ;
38- nativeBuildInputs = [ gradle_ perl pkg-config cmake gperf python3 ruby ] ;
39-
40- dontUseCmakeConfigure = true ;
41-
42- postPatch = ''
43- substituteInPlace buildSrc/linux.gradle \
44- --replace ', "-Werror=implicit-function-declaration"' ""
45-
46- # Add missing includes for gcc-13 for webkit build:
47- sed -e '1i #include <cstdio>' \
48- -i modules/javafx.web/src/main/native/Source/bmalloc/bmalloc/Heap.cpp \
49- modules/javafx.web/src/main/native/Source/bmalloc/bmalloc/IsoSharedPageInlines.h
50- '' ;
51-
52- config = writeText "gradle.properties" ( ''
53- CONF = Release
54- JDK_HOME = ${ openjdk11-bootstrap . home }
55- '' + args . gradleProperties or "" ) ;
56-
57- buildPhase = ''
58- runHook preBuild
59-
60- export NUMBER_OF_PROCESSORS=$NIX_BUILD_CORES
61- export GRADLE_USER_HOME=$(mktemp -d)
62- ln -s $config gradle.properties
63- export NIX_CFLAGS_COMPILE="$(pkg-config --cflags glib-2.0) $NIX_CFLAGS_COMPILE"
64- gradle --no-daemon --console=plain $gradleFlags sdk
65-
66- runHook postBuild
67- '' ;
68- } // args ) ;
69-
70- # Fake build to pre-download deps into fixed-output derivation.
71- # We run nearly full build because I see no other way to download everything that's needed.
72- # Anyone who knows a better way?
73- deps = makePackage {
74- pname = "openjfx-deps" ;
75-
76- # 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)
77- installPhase = ''
78- find $GRADLE_USER_HOME -type f -regex '.*/modules.*\.\(jar\|pom\)' \
79- | perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# ($x = $2) =~ tr|\.|/|; "install -Dm444 $1 \$out/$x/$3/$4/$5" #e' \
80- | sh
81- rm -rf $out/tmp
82- '' ;
83-
84- outputHashAlgo = "sha256" ;
85- outputHashMode = "recursive" ;
86- outputHash = "sha256-syceJMUEknBDCHK8eGs6rUU3IQn+HnQfURfCrDxYPa9=" ;
87- } ;
28+ buildInputs = [ gtk2 gtk3 libXtst libXxf86vm glib alsa-lib ffmpeg_4-headless ] ;
29+ nativeBuildInputs = [ gradle perl pkg-config cmake gperf python3 ruby ] ;
8830
89- in makePackage {
90- pname = "openjfx-modular-sdk" ;
31+ dontUseCmakeConfigure = true ;
9132
92- gradleProperties = ''
33+ config = writeText "gradle.properties" ''
34+ CONF = Release
35+ JDK_HOME = ${ jdk . home }
9336 COMPILE_MEDIA = ${ lib . boolToString withMedia }
9437 COMPILE_WEBKIT = ${ lib . boolToString withWebKit }
95- ${ lib . optionalString withWebKit "icuRepositoryURL = file://${ icuFakeRepository } " }
9638 '' ;
9739
40+ postPatch = ''
41+ substituteInPlace buildSrc/linux.gradle \
42+ --replace ', "-Werror=implicit-function-declaration"' ""
43+
44+ # Add missing includes for gcc-13 for webkit build:
45+ sed -e '1i #include <cstdio>' \
46+ -i modules/javafx.web/src/main/native/Source/bmalloc/bmalloc/Heap.cpp \
47+ modules/javafx.web/src/main/native/Source/bmalloc/bmalloc/IsoSharedPageInlines.h
48+
49+ ln -s $config gradle.properties
50+ '' ;
51+
52+ mitmCache = gradle . fetchDeps {
53+ attrPath = "openjfx${ major } " ;
54+ pkg = pkgs . "openjfx${ major } " . override { withWebKit = true ; } ;
55+ data = ./deps.json ;
56+ } ;
57+
58+ __darwinAllowLocalNetworking = true ;
59+
9860 preBuild = ''
99- swtJar="$(find ${ deps } -name org.eclipse.swt\*.jar)"
100- substituteInPlace build.gradle \
101- --replace 'mavenCentral()' 'mavenLocal(); maven { url uri("${ deps } ") }' \
102- --replace 'name: SWT_FILE_NAME' "files('$swtJar')"
61+ export NUMBER_OF_PROCESSORS=$NIX_BUILD_CORES
62+ export NIX_CFLAGS_COMPILE="$(pkg-config --cflags glib-2.0) $NIX_CFLAGS_COMPILE"
10363 '' ;
10464
65+ enableParallelBuilding = false ;
66+
67+ gradleBuildTask = "sdk" ;
68+
10569 installPhase = ''
10670 cp -r build/modular-sdk $out
10771 '' ;
@@ -110,18 +74,16 @@ in makePackage {
11074
11175 postFixup = ''
11276 # Remove references to bootstrap.
77+ export openjdkOutPath='${ jdk . outPath } '
11378 find "$out" -name \*.so | while read lib; do
114- new_refs="$(patchelf --print-rpath "$lib" | sed -E 's,:?${ openjdk11-bootstrap } [^:]*,,')"
79+ new_refs="$(patchelf --print-rpath "$lib" | perl -pe 's,:?\Q$ENV{openjdkOutPath}\E [^:]*,,')"
11580 patchelf --set-rpath "$new_refs" "$lib"
11681 done
117-
11882 # Remove licenses, otherwise they may conflict with the ones included in the openjdk
11983 rm -rf $out/modules_legal/*
12084 '' ;
12185
122- disallowedReferences = [ openjdk11-bootstrap ] ;
123-
124- passthru . deps = deps ;
86+ disallowedReferences = [ jdk gradle . jdk ] ;
12587
12688 # Uses a lot of RAM, OOMs otherwise
12789 requiredSystemFeatures = [ "big-parallel" ] ;
0 commit comments