nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
fork

Configure Feed

Select the types of activity you want to include in your feed.

at python-updates 155 lines 5.4 kB view raw
1{ 2 fetchzip, 3 gtk3, 4 jdk, 5 lib, 6 libGLU, 7 pkg-config, 8 stdenv, 9 stripJavaArchivesHook, 10}: 11 12stdenv.mkDerivation (finalAttrs: { 13 pname = "swt"; 14 # NOTE: In case you wish to override, don't override version, override 15 # `fullVersion`. 16 version = builtins.elemAt (lib.splitString "-" finalAttrs.fullVersion) 1; 17 fullVersion = "R-4.34-202411201800"; 18 19 hardeningDisable = [ "format" ]; 20 21 passthru.srcMetadataByPlatform = { 22 # Note: This may look like an error but the content of the src.zip is in fact 23 # equal on all linux systems as well as all darwin systems. Even though each 24 # of these zip archives themselves contains a different hash. 25 x86_64-linux.platform = "gtk-linux-x86_64"; 26 x86_64-linux.hash = "sha256-lKAB2aCI3dZdt3pE7uSvSfxc8vc3oMSTCx5R+71Aqdk="; 27 aarch64-linux.platform = "gtk-linux-aarch64"; 28 aarch64-linux.hash = "sha256-lKAB2aCI3dZdt3pE7uSvSfxc8vc3oMSTCx5R+71Aqdk="; 29 ppc64le-linux.platform = "gtk-linux-ppc64le"; 30 ppc64le-linux.hash = "sha256-lKAB2aCI3dZdt3pE7uSvSfxc8vc3oMSTCx5R+71Aqdk="; 31 riscv64-linux.platform = "gtk-linux-riscv64"; 32 riscv64-linux.hash = "sha256-lKAB2aCI3dZdt3pE7uSvSfxc8vc3oMSTCx5R+71Aqdk="; 33 x86_64-darwin.platform = "cocoa-macosx-x86_64"; 34 x86_64-darwin.hash = "sha256-Uns3fMoetbZAIrL/N0eVd42/3uygXakDdxpaxf5SWDI="; 35 aarch64-darwin.platform = "cocoa-macosx-aarch64"; 36 aarch64-darwin.hash = "sha256-jvxmoRFGquYClPgMqWi2ylw26YiGSG5bONnM1PcjlTM="; 37 }; 38 passthru.srcMetadata = 39 finalAttrs.passthru.srcMetadataByPlatform.${stdenv.hostPlatform.system} or null; 40 # Alas, the Eclipse Project apparently doesn't produce source-only 41 # releases of SWT. So we just grab a binary release and extract 42 # "src.zip" from that. 43 src = 44 let 45 inherit (finalAttrs.passthru) srcMetadata; 46 in 47 assert srcMetadata != null; 48 fetchzip { 49 url = "https://download.eclipse.org/eclipse/downloads/drops4/${finalAttrs.fullVersion}/swt-${finalAttrs.version}-${srcMetadata.platform}.zip"; 50 inherit (srcMetadata) hash; 51 stripRoot = false; 52 postFetch = 53 # On Linux, extract and use only the sources from src.zip 54 lib.optionalString stdenv.hostPlatform.isLinux '' 55 mkdir "$unpackDir" 56 cd "$unpackDir" 57 58 renamed="$TMPDIR/src.zip" 59 mv -- "$out/src.zip" "$renamed" 60 unpackFile "$renamed" 61 rm -r -- "$out" 62 63 mv -- "$unpackDir" "$out" 64 ''; 65 }; 66 67 nativeBuildInputs = [ 68 jdk 69 stripJavaArchivesHook 70 ] 71 ++ lib.optionals stdenv.hostPlatform.isLinux [ 72 pkg-config 73 ]; 74 buildInputs = lib.optionals stdenv.hostPlatform.isLinux [ 75 gtk3 76 libGLU 77 ]; 78 79 SWT_JAVA_HOME = jdk; 80 AWT_LIB_PATH = "${jdk}/lib/openjdk/lib"; 81 # Used by the makefile which is responsible for the shared objects only 82 OUTPUT_DIR = "${placeholder "out"}/lib"; 83 # GTK4 is not supported yet. See: 84 # https://github.com/eclipse-platform/eclipse.platform.swt/issues/652 85 makeFlags = lib.optionals stdenv.hostPlatform.isLinux [ "gtk3" ]; 86 87 NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isLinux "-std=gnu17"; 88 postPatch = lib.optionalString stdenv.hostPlatform.isLinux "substituteInPlace library/make_linux.mak --replace-fail 'CFLAGS += -Werror' ''"; 89 preBuild = lib.optionalString stdenv.hostPlatform.isLinux '' 90 cd library 91 mkdir -p ${finalAttrs.OUTPUT_DIR} 92 ''; 93 94 # Build the jar (Linux only, Darwin uses prebuilt) 95 postBuild = lib.optionalString stdenv.hostPlatform.isLinux '' 96 cd ../ 97 mkdir out 98 find org/ -name '*.java' -type f -exec javac -encoding utf8 -d out/ {} + 99 # Copy non Java resource files 100 find org/ -not -name '*.java' -not -name '*.html' -type f -exec cp {} out/{} \; 101 ''; 102 103 # The makefile doesn't have an install target, the installation of the shared 104 # objects is part of the `all` target. 105 installPhase = '' 106 runHook preInstall 107 108 install -d -- "$out/jars" 109 110 '' 111 # On Darwin, use the prebuilt swt.jar which includes native libraries 112 + lib.optionalString stdenv.hostPlatform.isDarwin '' 113 # Remove signature files to avoid validation errors after stripJavaArchivesHook modifies the jar 114 mkdir -p jar-temp 115 cd jar-temp 116 ${jdk}/bin/jar -xf ../swt.jar 117 rm -f META-INF/*.SF META-INF/*.RSA META-INF/*.DSA 118 ${jdk}/bin/jar -cf "$out/jars/swt.jar" * 119 cd .. 120 rm -rf jar-temp 121 122 '' 123 # On Linux, build from source 124 + lib.optionalString stdenv.hostPlatform.isLinux '' 125 install -m 644 -t out -- version.txt 126 (cd out && jar -c *) > "$out/jars/swt.jar" 127 128 '' 129 + '' 130 runHook postInstall 131 ''; 132 133 meta = { 134 homepage = "https://www.eclipse.org/swt/"; 135 description = '' 136 A widget toolkit for Java to access the user-interface facilities of 137 the operating systems on which it is implemented. 138 ''; 139 license = with lib.licenses; [ 140 # All of these are located in the about_files directory of the source 141 ijg 142 lgpl21 143 mpl11 144 mpl20 145 ]; 146 maintainers = with lib.maintainers; [ mio ]; 147 # The darwin src zip file holds simply a prebuilt swt.jar file 148 sourceProvenance = lib.optionals stdenv.hostPlatform.isDarwin [ 149 lib.sourceTypes.binaryNativeCode 150 ]; 151 platforms = lib.attrNames finalAttrs.passthru.srcMetadataByPlatform; 152 # Fails with: `java.nio.file.NoSuchFileException: ../swt.jar` 153 broken = stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64; 154 }; 155})