graphql-engine/nix/shell.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

132 lines
3.5 KiB
Nix

{ pkgs }:
let
versions = import ./versions.nix { inherit pkgs; };
# Unix ODBC Support
freetdsWithODBC = pkgs.freetds.override {
odbcSupport = true;
inherit (pkgs) unixODBC;
};
msodbcsql = pkgs.unixODBCDrivers.msodbcsql18;
# Verify this works by running `odbcinst -q -d`.
# The output should be the headings from the odbcinst.ini file.
# (You can easily see the generated file by running `cat $ODBCINSTINI`.)
# If you see any errors, please contact your friendly MSSQL and/or Nix expert.
odbcinstFile = pkgs.writeTextFile {
name = "odbcinst.ini";
text = ''
[${msodbcsql.fancyName}]
Description = ${msodbcsql.meta.description}
Driver = ${msodbcsql}/${msodbcsql.driver}
'';
};
baseInputs = [
pkgs.stdenv
pkgs.jq
];
consoleInputs = [
pkgs.google-cloud-sdk
pkgs."nodejs-${versions.nodejsVersion}_x"
];
docsInputs = [
pkgs.yarn
];
integrationTestInputs = [
pkgs.python3
];
# The version of GHC in `ghcName` is set in nix/overlays/ghc.nix.
#
# We list top-level packages before packages scoped to the GHC version, so
# that they appear first in the PATH. Otherwise we might end up with older
# versions of transitive dependencies (e.g. HLS depending on Ormolu).
haskellInputs = [
pkgs.cabal2nix
# The correct version of GHC.
pkgs.haskell.compiler.${pkgs.ghcName}
# We use the default versions of these packages.
(versions.ensureVersion pkgs.haskellPackages.ormolu)
# We build these packages using our custom GHC.
pkgs.haskell.packages.${pkgs.ghcName}.alex
pkgs.haskell.packages.${pkgs.ghcName}.apply-refact
pkgs.haskell.packages.${pkgs.ghcName}.cabal-install
pkgs.haskell.packages.${pkgs.ghcName}.ghcid
pkgs.haskell.packages.${pkgs.ghcName}.happy
pkgs.haskell.packages.${pkgs.ghcName}.haskell-language-server
(versions.ensureVersion pkgs.haskell.packages.${pkgs.ghcName}.hlint)
(versions.ensureVersion pkgs.haskell.packages.${pkgs.ghcName}.hpack)
pkgs.haskell.packages.${pkgs.ghcName}.hoogle
pkgs.haskell.packages.${pkgs.ghcName}.hspec-discover
];
devInputs = [
pkgs.nixpkgs-fmt
pkgs.shellcheck
];
ciInputs = [
pkgs.go
pkgs.gox
];
dynamicLibraries = [
pkgs.gmp
pkgs.libkrb5 # Includes required `gssapi` headers.
pkgs.libiconv
pkgs.ncurses
pkgs.openssl_3
pkgs.pcre
pkgs.zlib
pkgs.zstd
# PostgreSQL, Microsoft SQL Server, & MySQL dependencies.
freetdsWithODBC
pkgs.libmysqlclient
pkgs.mariadb
pkgs.postgresql
pkgs.unixODBC
msodbcsql
]
# Linux-specific libraries.
++ pkgs.lib.optionals pkgs.stdenv.targetPlatform.isLinux [
pkgs.stdenv.cc.cc.lib
];
includeLibraries = [
pkgs.libkrb5.dev
pkgs.ncurses.dev
pkgs.openssl_3.dev
pkgs.pcre.dev
pkgs.zlib.dev
];
serverDeps =
haskellInputs
++ dynamicLibraries
++ includeLibraries
++ integrationTestInputs;
in
pkgs.mkShell {
buildInputs = baseInputs ++ consoleInputs ++ docsInputs ++ serverDeps ++ devInputs ++ ciInputs;
# We set the ODBCINSTINI to the file defined above, which points to the MSSQL ODBC driver.
# The path is relative to `ODBCSYSINI`, which we set to empty.
ODBCSYSINI = "";
ODBCINSTINI = "${odbcinstFile}";
LD_LIBRARY_PATH = pkgs.lib.strings.makeLibraryPath dynamicLibraries;
shellHook = pkgs.lib.strings.optionalString pkgs.stdenv.targetPlatform.isDarwin ''
# Without this, GHC will use the system `libcrypto` and `libssl` libraries, which fail.
export DYLD_LIBRARY_PATH="$LD_LIBRARY_PATH";
'';
}