Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 153 lines 4.2 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 makeDesktopItem, 6 makeWrapper, 7 freetype, 8 fontconfig, 9 libX11, 10 libXrender, 11 zlib, 12 glib, 13 gtk3, 14 gtk2, 15 libXtst, 16 jdk, 17 jdk8, 18 gsettings-desktop-schemas, 19 webkitgtk_4_1 ? null, # for internal web browser 20 buildEnv, 21 runCommand, 22 callPackage, 23}: 24 25# use ./update.sh to help with updating for each quarterly release 26# 27# then, to test: 28# for e in cpp dsl embedcpp modeling platform sdk java jee committers rcp; do for s in pkgs pkgsCross.aarch64-multiplatform; do echo; echo $s $e; nix-build -A ${s}.eclipses.eclipse-${e} -o eclipse-${s}-${e}; done; done 29 30let 31 eclipses = lib.trivial.importJSON ./eclipses.json; 32 inherit (eclipses) 33 platform_major 34 platform_minor 35 year 36 # release month sometimes differs from build month 37 month 38 buildmonth 39 dayHourMinute 40 ; 41 timestamp = "${year}${buildmonth}${dayHourMinute}"; 42 43 gtk = gtk3; 44 arch = 45 if stdenv.hostPlatform.isx86_64 then 46 "x86_64" 47 else if stdenv.hostPlatform.isAarch64 then 48 "aarch64" 49 else 50 throw "don't know what platform suffix for ${stdenv.hostPlatform.system} will be"; 51 52 # work around https://bugs.eclipse.org/bugs/show_bug.cgi?id=476075#c3 53 buildEclipseUnversioned = callPackage ./build-eclipse.nix { 54 inherit 55 stdenv 56 makeDesktopItem 57 freetype 58 fontconfig 59 libX11 60 libXrender 61 zlib 62 jdk 63 glib 64 gtk 65 libXtst 66 gsettings-desktop-schemas 67 webkitgtk_4_1 68 makeWrapper 69 ; 70 }; 71 buildEclipse = 72 eclipseData: 73 buildEclipseUnversioned (eclipseData // { version = "${platform_major}.${platform_minor}"; }); 74 75 generateEclipse = 76 id: 77 { 78 description, 79 hashes, 80 dropUrl, 81 }: 82 builtins.listToAttrs [ 83 { 84 name = "eclipse-${lib.strings.toLower id}"; 85 value = buildEclipse { 86 pname = "eclipse-${lib.strings.toLower id}"; 87 inherit description; 88 src = fetchurl { 89 url = 90 if dropUrl then 91 "https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/eclipse/downloads/drops${platform_major}/R-${platform_major}.${platform_minor}-${timestamp}/eclipse-${id}-${platform_major}.${platform_minor}-linux-gtk-${arch}.tar.gz" 92 else 93 "https://www.eclipse.org/downloads/download.php?r=1&nf=1&file=/technology/epp/downloads/release/${year}-${month}/R/eclipse-${id}-${year}-${month}-R-linux-gtk-${arch}.tar.gz"; 94 hash = hashes.${arch}; 95 }; 96 }; 97 } 98 ]; 99 100 generatedEclipses = lib.attrsets.concatMapAttrs generateEclipse eclipses.eclipses; 101 102in 103generatedEclipses 104// { 105 # expose this function so users can build their own eclipses if needed 106 inherit buildEclipse; 107 108 ### Environments 109 110 # Function that assembles a complete Eclipse environment from an 111 # Eclipse package and list of Eclipse plugins. 112 eclipseWithPlugins = 113 { 114 eclipse, 115 plugins ? [ ], 116 jvmArgs ? [ ], 117 }: 118 let 119 # Gather up the desired plugins. 120 pluginEnv = buildEnv { 121 name = "eclipse-plugins"; 122 paths = lib.filter (x: x ? isEclipsePlugin) (lib.closePropagation plugins); 123 }; 124 125 # Prepare the JVM arguments to add to the ini file. We here also 126 # add the property indicating the plugin directory. 127 dropinPropName = "org.eclipse.equinox.p2.reconciler.dropins.directory"; 128 dropinProp = "-D${dropinPropName}=${pluginEnv}/eclipse/dropins"; 129 jvmArgsText = lib.concatStringsSep "\n" (jvmArgs ++ [ dropinProp ]); 130 131 # Base the derivation name on the name of the underlying 132 # Eclipse. 133 name = (lib.meta.appendToName "with-plugins" eclipse).name; 134 in 135 runCommand name { nativeBuildInputs = [ makeWrapper ]; } '' 136 mkdir -p $out/bin $out/etc 137 138 # Prepare an eclipse.ini with the plugin directory. 139 cat ${eclipse}/eclipse/eclipse.ini - > $out/etc/eclipse.ini <<EOF 140 ${jvmArgsText} 141 EOF 142 143 makeWrapper ${eclipse}/bin/eclipse $out/bin/eclipse \ 144 --add-flags "--launcher.ini $out/etc/eclipse.ini" 145 146 ln -s ${eclipse}/share $out/ 147 ''; 148 149 ### Plugins 150 151 plugins = callPackage ./plugins.nix { }; 152 153}