summary refs log tree commit diff
path: root/pkgs/servers/sql/oracle-xe/default.nix
blob: cb150fc5fd4caf7f95257948b4d8c17c25d459a3 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
{ stdenv, makeWrapper, requireFile, patchelf, rpmextract, libaio }:

assert stdenv.system == "x86_64-linux";

with stdenv.lib;

stdenv.mkDerivation rec {
  name = "oracle-xe-${version}";
  version = "11.2.0";

  src = requireFile {
    name = "${name}-1.0.x86_64.rpm";
    sha256 = "0s2jj2xn56v5ys6hxb7l7045hw9c1mm1lhj4p2fvqbs02kqchab6";

    url = "http://www.oracle.com/technetwork/"
        + "products/express-edition/downloads/";
  };

  buildInputs = [ makeWrapper ];

  unpackCmd = ''
    (mkdir -p "${name}" && cd "${name}" &&
      ${rpmextract}/bin/rpmextract "$curSrc")
  '';

  buildPhase = let
    libs = makeLibraryPath [ libaio ];
  in ''
    basedir="u01/app/oracle/product/${version}/xe"
    cat > "$basedir/network/admin/listener.ora" <<SQL
    # listener.ora Network Configuration File:

    SID_LIST_LISTENER =
      (SID_LIST =
        (SID_DESC =
          (SID_NAME = PLSExtProc)
          (ORACLE_HOME = ''${out}/libexec/oracle)
          (PROGRAM = extproc)
        )
      )

    LISTENER =
      (DESCRIPTION_LIST =
        (DESCRIPTION =
          (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC_FOR_XE))
          (ADDRESS = (PROTOCOL = TCP)(HOST = %hostname%)(PORT = %port%))
        )
      )

    DEFAULT_SERVICE_LISTENER = (XE)
    SQL

    find u01 \
      \( -name '*.sh' \
      -o -path "$basedir/bin/*" \
      \) -print -exec "${patchelf}/bin/patchelf" \
           --interpreter "$(cat "$NIX_CC/nix-support/dynamic-linker")" \
           --set-rpath "${libs}:$out/libexec/oracle/lib" \
           --force-rpath '{}' \;
  '';

  dontStrip = true;
  dontPatchELF = true;

  installPhase = ''
    mkdir -p "$out/libexec"
    cp -r "u01/app/oracle/product/${version}/xe" "$out/libexec/oracle"

    for i in "$out/libexec/oracle/bin"/*; do
      makeWrapper "$i" "$out/bin/''${i##*/}" \
        --set ORACLE_HOME "$out/libexec/oracle" \
        --set ORACLE_SID XE \
        --set NLS_LANG '$("'"$out"'/libexec/oracle/bin/nls_lang.sh")' \
        --prefix PATH : "$out/libexec/oracle/bin"
    done
  '';

  meta = {
    description = "Oracle Database Express Edition";
    homepage = "http://www.oracle.com/technetwork/products/express-edition/";
    license = licenses.unfree;
  };
}