lol

oracle-instantclient: add optional odbc support

+35 -15
+35 -15
pkgs/development/libraries/oracle-instantclient/default.nix
··· 1 - { stdenv, requireFile, libelf, gcc, glibc, patchelf, unzip, rpmextract, libaio }: 1 + { stdenv, requireFile, libelf, gcc, glibc, patchelf, unzip, rpmextract, libaio 2 + , odbcSupport ? false, unixODBC 3 + }: 2 4 3 - let requireSource = version: part: hash: (requireFile rec { 4 - name = "oracle-instantclient12.1-${part}-${version}.x86_64.rpm"; 5 - message = '' 6 - This Nix expression requires that ${name} already 7 - be part of the store. Download the file 8 - manually at 5 + assert odbcSupport -> unixODBC != null; 9 6 10 - http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html 7 + let optional = stdenv.lib.optional; 8 + optionalString = stdenv.lib.optionalString; 9 + requireSource = version: part: hash: (requireFile rec { 10 + name = "oracle-instantclient12.1-${part}-${version}.x86_64.rpm"; 11 + message = '' 12 + This Nix expression requires that ${name} already 13 + be part of the store. Download the file 14 + manually at 11 15 12 - and add it to the Nix store with the following command: 16 + http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html 13 17 14 - nix-prefetch-url file://${name} ${hash} --type sha256 15 - ''; 16 - url = "http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html"; 17 - sha256 = hash; 18 - }); in stdenv.mkDerivation rec { 18 + and add it to the Nix store using either: 19 + nix-store --add-fixed sha256 ${name} 20 + or 21 + nix-prefetch-url --type sha256 file:///path/to/${name} 22 + ''; 23 + url = "http://www.oracle.com/technetwork/topics/linuxx86-64soft-092277.html"; 24 + sha256 = hash; 25 + }); 26 + in stdenv.mkDerivation rec { 19 27 version = "12.1.0.2.0-1"; 20 28 name = "oracle-instantclient-${version}"; 21 29 22 30 srcBase = (requireSource version "basic" "f0e51e247cc3f210b950fd939ab1f696de9ca678d1eb179ba49ac73acb9a20ed"); 23 31 srcDevel = (requireSource version "devel" "13b638882f07d6cfc06c85dc6b9eb5cac37064d3d594194b6b09d33483a08296"); 24 32 srcSqlplus = (requireSource version "sqlplus" "16d87w1lii0ag47c8srnr7v4wfm9q4hy6gka8m3v6gp9cc065vam"); 33 + srcOdbc = optionalString odbcSupport (requireSource version "odbc" "d3aa1a4957a2f15ced05921dab551ba823aa7925d8fcb58d5b3a7f624e4df063"); 25 34 26 - buildInputs = [ glibc patchelf rpmextract ]; 35 + buildInputs = [ glibc patchelf rpmextract ] ++ 36 + optional odbcSupport unixODBC; 27 37 28 38 buildCommand = '' 29 39 mkdir -p "${name}" ··· 31 41 ${rpmextract}/bin/rpmextract "${srcBase}" 32 42 ${rpmextract}/bin/rpmextract "${srcDevel}" 33 43 ${rpmextract}/bin/rpmextract "${srcSqlplus}" 44 + ${optionalString odbcSupport '' 45 + ${rpmextract}/bin/rpmextract "${srcOdbc}" 46 + ''} 34 47 35 48 mkdir -p "$out/"{bin,include,lib,"share/${name}/demo/"} 36 49 mv "usr/share/oracle/12.1/client64/demo/"* "$out/share/${name}/demo/" ··· 43 56 test -f $lib || continue 44 57 chmod +x $lib 45 58 patchelf --force-rpath --set-rpath "$out/lib:${libaio}/lib" \ 59 + $lib 60 + done 61 + 62 + for lib in $out/lib/libsqora*; do 63 + test -f $lib || continue 64 + chmod +x $lib 65 + patchelf --force-rpath --set-rpath "$out/lib:${unixODBC}/lib" \ 46 66 $lib 47 67 done 48 68