graphql-engine/nix/msodbcsql18-linux.nix
Samir Talwar c3afa0fdd7 Install and use ODBC Driver 18 for SQL Server (msodbcsql18).
This installs the ODBC Driver 18 for SQL Server in all our shipped Docker images, and update our tests and documentation accordingly.

This version supports arm64, and therefore can run natively (or via Docker) on macOS on aarch64.

`msodbcsql17` is still installed in production-targeted Docker images so that users do not _have_ to migrate to the new driver.

Nix expressions are packaged for the new driver, as it is not yet available in nixpkgs.

In this version, [the default encryption setting was changed from "no" to "yes"](https://techcommunity.microsoft.com/t5/sql-server-blog/odbc-driver-18-0-for-sql-server-released/ba-p/3169228). In addition, "mandatory" and "optional" were added as synonyms for "yes" and "no" respectively.

I have therefore modified all connection strings in tests to specify `Encrypt=optional` (and changed some from `Encrypt=no`). I chose "optional" rather than "no" because I feel it's more honest; these connection strings will work with or without an encrypted connection.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6241
GitOrigin-RevId: 959f88dd1f271ef06a3616bc46b358f364f6cdfd
2022-10-21 16:25:04 +00:00

55 lines
1.9 KiB
Nix

# Copied from nixpkgs/pkgs/development/libraries/unixODBCDrivers/default.nix and modified.
{ fetchurl, stdenv, unixODBC, dpkg, lib, openssl, libkrb5, libuuid, patchelf }:
stdenv.mkDerivation rec {
pname = "msodbcsql${versionMajor}";
version = "${versionMajor}.${versionMinor}.${versionAdditional}-1";
versionMajor = "18";
versionMinor = "1";
versionAdditional = "1.1";
src =
if stdenv.targetPlatform.isAarch64
then
fetchurl
{
url = "https://packages.microsoft.com/debian/11/prod/pool/main/m/${pname}/${pname}_${version}_arm64.deb";
sha256 = "0zphnbvkqdbkcv6lvv63p7pyl68h5bs2dy6vv44wm6bi89svms4a";
}
else
fetchurl
{
url = "https://packages.microsoft.com/debian/11/prod/pool/main/m/${pname}/${pname}_${version}_amd64.deb";
sha256 = "1f0rmh1aynf1sqmjclbsyh2wz5jby0fixrwz71zp6impxpwvil52";
};
nativeBuildInputs = [ dpkg patchelf ];
unpackPhase = "dpkg -x $src ./";
buildPhase = "";
installPhase = ''
mkdir -p $out
mkdir -p $out/lib
cp -r opt/microsoft/msodbcsql${versionMajor}/lib64 opt/microsoft/msodbcsql${versionMajor}/share $out/
'';
postFixup = ''
patchelf --set-rpath ${lib.makeLibraryPath [ unixODBC openssl libkrb5 libuuid stdenv.cc.cc ]} \
$out/lib/libmsodbcsql-${versionMajor}.${versionMinor}.so.${versionAdditional}
'';
passthru = {
fancyName = "ODBC Driver ${versionMajor} for SQL Server";
driver = "lib/libmsodbcsql-${versionMajor}.${versionMinor}.so.${versionAdditional}";
};
meta = with lib; {
description = "ODBC Driver ${versionMajor} for SQL Server";
homepage = "https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-2017";
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
platforms = platforms.linux;
license = licenses.unfree;
};
}