12 assert odbcSupport -> unixODBC != null;
15 inherit (lib) optional optionals optionalString;
17 throwSystem = throw "Unsupported system: ${stdenv.hostPlatform.system}";
19 # assemble list of components
20 components = [ "basic" "sdk" "sqlplus" ] ++ optional odbcSupport "odbc";
22 # determine the version number, there might be different ones per architecture
24 x86_64-linux = "19.3.0.0.0";
25 x86_64-darwin = "19.3.0.0.0";
26 }.${stdenv.hostPlatform.system} or throwSystem;
28 # hashes per component and architecture
31 basic = "1yk4ng3a9ka1mzgfph9br6rwclagbgfvmg6kja11nl5dapxdzaxy";
32 sdk = "115v1gqr0czy7dcf2idwxhc6ja5b0nind0mf1rn8iawgrw560l99";
33 sqlplus = "0zj5h84ypv4n4678kfix6jih9yakb277l9hc0819iddc0a5slbi5";
34 odbc = "1g1z6pdn76dp440fh49pm8ijfgjazx4cvxdi665fsr62h62xkvch";
37 basic = "f4335c1d53e8188a3a8cdfb97494ff87c4d0f481309284cf086dc64080a60abd";
38 sdk = "b46b4b87af593f7cfe447cfb903d1ae5073cec34049143ad8cdc9f3e78b23b27";
39 sqlplus = "f7565c3cbf898b0a7953fbb0017c5edd9d11d1863781588b7caf3a69937a2e9e";
40 odbc = "f91da40684abaa866aa059eb26b1322f2d527670a1937d678404c991eadeb725";
42 }.${stdenv.hostPlatform.system} or throwSystem;
44 # rels per component and architecture, optional
46 }.${stdenv.hostPlatform.system} or {};
48 # convert platform to oracle architecture names
50 x86_64-linux = "linux.x64";
51 x86_64-darwin = "macos.x64";
52 }.${stdenv.hostPlatform.system} or throwSystem;
55 x86_64-linux = "linux";
56 x86_64-darwin = "mac";
57 }.${stdenv.hostPlatform.system} or throwSystem;
59 # calculate the filename of a single zip file
60 srcFilename = component: arch: version: rel:
61 "instantclient-${component}-${arch}-${version}" +
62 (optionalString (rel != "") "-${rel}") +
63 (optionalString (arch == "linux.x64" || arch == "macos.x64") "dbru") + # ¯\_(ツ)_/¯
66 # fetcher for the non clickthrough artifacts
67 fetcher = srcFilename: hash: fetchurl {
68 url = "https://download.oracle.com/otn_software/${shortArch}/instantclient/193000/${srcFilename}";
73 srcs = map (component:
74 (fetcher (srcFilename component arch version rels.${component} or "") hashes.${component} or ""))
77 pname = "oracle-instantclient";
78 extLib = stdenv.hostPlatform.extensions.sharedLibrary;
79 in stdenv.mkDerivation {
80 inherit pname version srcs;
82 buildInputs = [ stdenv.cc.cc.lib ]
83 ++ optional stdenv.isLinux libaio
84 ++ optional odbcSupport unixODBC;
86 nativeBuildInputs = [ makeWrapper unzip ]
87 ++ optional stdenv.isLinux autoPatchelfHook
88 ++ optional stdenv.isDarwin fixDarwinDylibNames;
90 outputs = [ "out" "dev" "lib"];
92 unpackCmd = "unzip $curSrc";
95 mkdir -p "$out/"{bin,include,lib,"share/java","share/${pname}-${version}/demo/"} $lib/lib
96 install -Dm755 {adrci,genezi,uidrvci,sqlplus} $out/bin
98 # cp to preserve symlinks
99 cp -P *${extLib}* $lib/lib
101 install -Dm644 *.jar $out/share/java
102 install -Dm644 sdk/include/* $out/include
103 install -Dm644 sdk/demo/* $out/share/${pname}-${version}/demo
106 ln -sfn $out/bin/sqlplus $out/bin/sqlplus64
109 postFixup = optionalString stdenv.isDarwin ''
110 for exe in "$out/bin/"* ; do
111 if [ ! -L "$exe" ]; then
112 install_name_tool -add_rpath "$lib/lib" "$exe"
118 description = "Oracle instant client libraries and sqlplus CLI";
120 Oracle instant client provides access to Oracle databases (OCI,
121 OCCI, Pro*C, ODBC or JDBC). This package includes the sqlplus
122 command line SQL client.
124 license = licenses.unfree;
125 platforms = [ "x86_64-linux" "x86_64-darwin" ];
126 maintainers = with maintainers; [ pesterhazy flokli ];