nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 callPackage,
5 fetchurl,
6 fetchMavenArtifact,
7 gitUpdater,
8 mkRubyVersion,
9 makeBinaryWrapper,
10 jre,
11}:
12
13let
14 # The version number here is whatever is reported by the RUBY_VERSION string
15 rubyVersion = mkRubyVersion "3" "4" "2" "";
16in
17stdenv.mkDerivation (finalAttrs: {
18 pname = "jruby";
19 version = "10.0.2.0";
20
21 src = fetchurl {
22 url = "https://repo1.maven.org/maven2/org/jruby/jruby-dist/${finalAttrs.version}/jruby-dist-${finalAttrs.version}-bin.tar.gz";
23 hash = "sha256-uKAm84qphGGgTtCqCyCJHOJX7L5T4SRxnOnuW4BFJfE=";
24 };
25
26 nativeBuildInputs = [ makeBinaryWrapper ];
27
28 installPhase = ''
29 mkdir -pv $out/share/jruby/docs
30 mv * $out
31 rm $out/bin/*.{bat,dll,exe}
32 mv $out/samples $out/share/jruby/
33 mv $out/BSDL $out/COPYING $out/LEGAL $out/LICENSE* $out/share/jruby/docs/
34
35 for i in $out/bin/jruby; do
36 wrapProgram $i \
37 --set JAVA_HOME ${jre.home}
38 done
39
40 # Bundler tries to create this directory
41 mkdir -pv $out/${finalAttrs.passthru.gemPath}
42 mkdir -p $out/nix-support
43 cat > $out/nix-support/setup-hook <<EOF
44 addGemPath() {
45 addToSearchPath GEM_PATH \$1/${finalAttrs.passthru.gemPath}
46 }
47
48 addEnvHooks "$hostOffset" addGemPath
49 EOF
50 '';
51
52 postFixup = ''
53 PATH=$out/bin:$PATH patchShebangs $out/bin
54 '';
55
56 passthru = rec {
57 rubyEngine = "jruby";
58 gemPath = "lib/${rubyEngine}/gems/${rubyVersion.libDir}";
59 libPath = "lib/${rubyEngine}/${rubyVersion.libDir}";
60 devEnv = callPackage ../ruby/dev.nix {
61 ruby = finalAttrs.finalPackage;
62 };
63 updateScript = gitUpdater {
64 url = "https://github.com/jruby/jruby.git";
65 };
66 };
67
68 meta = {
69 description = "Ruby interpreter written in Java";
70 homepage = "https://www.jruby.org/";
71 changelog = "https://github.com/jruby/jruby/releases/tag/${finalAttrs.version}";
72 license = with lib.licenses; [
73 cpl10
74 gpl2
75 lgpl21
76 ];
77 platforms = jre.meta.platforms;
78 maintainers = [ lib.maintainers.fzakaria ];
79 sourceProvenance = with lib.sourceTypes; [ binaryBytecode ];
80 };
81})