about summary refs log tree commit diff
path: root/nixpkgs/pkgs/development/libraries/java/junixsocket/default.nix
blob: bc34957b9c3e6ed5655ba1ba0e9ee83b98439c92 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
{ stdenv, fetchurl, ant, jdk, junit }:

stdenv.mkDerivation rec {
  name = "junixsocket-1.3";

  src = fetchurl {
    url = "https://storage.googleapis.com/google-code-archive-downloads/v2/code.google.com/junixsocket/${name}-src.tar.bz2";
    sha256 = "0c6p8vmiv5nk8i6g1hgivnl3mpb2k3lhjjz0ss9dlirisfrxf1ym";
  };

  patches = [ ./darwin.patch ];

  buildInputs = [ ant jdk junit ];

  preConfigure =
    ''
      substituteInPlace src/main/org/newsclub/net/unix/NativeUnixSocketConfig.java \
        --replace /opt/newsclub/lib-native $out/lib
    '';

  buildPhase = "ant";

  ANT_ARGS =
    # Note that our OpenJDK on Darwin is currently 32-bit, so we have to build a 32-bit dylib.
    (if stdenv.is64bit then [ "-Dskip32=true" ] else [ "-Dskip64=true" ])
    ++ [ "-Dgcc=cc" "-Dant.build.javac.source=1.6" ]
    ++ stdenv.lib.optional stdenv.isDarwin "-DisMac=true";

  installPhase =
    ''
      mkdir -p $out/share/java $out/lib
      cp -v dist/*.jar $out/share/java
      cp -v lib-native/*.so lib-native/*.dylib $out/lib/
    '';

  meta = {
    description = "A Java/JNI library for using Unix Domain Sockets from Java";
    homepage = https://github.com/kohlschutter/junixsocket;
    license = stdenv.lib.licenses.asl20;
    platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
  };
}