nix: Bake the ODBC configuration path into unixODBC.

The previous method seems to be failing; we're not finding the drivers. Rather than using environment variables to tell unixODBC where to find odbcinst.ini, we can instead just configure it to point to the correct location and bake it into the binary.

This means we need to build unixODBC ourselves, but it's pretty quick, so doesn't seem like much of an issue.

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/8491
GitOrigin-RevId: 7d331c4205d412b7757c0f1efd5b6a00a10e2ad4
This commit is contained in:
Samir Talwar 2023-03-25 21:54:21 +01:00 committed by hasura-bot
parent e238e0f295
commit 042046bba7

View File

@ -5,7 +5,7 @@ let
# Unix ODBC Support
freetdsWithODBC = pkgs.freetds.override {
odbcSupport = true;
inherit (pkgs) unixODBC;
inherit unixODBC;
};
msodbcsql = pkgs.unixODBCDrivers.msodbcsql18;
@ -14,15 +14,20 @@ let
# 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";
odbcConfiguration = pkgs.writeTextFile {
name = "odbc-configuration";
text = ''
[${msodbcsql.fancyName}]
Description = ${msodbcsql.meta.description}
Driver = ${msodbcsql}/${msodbcsql.driver}
'';
destination = "/odbcinst.ini";
};
unixODBC = pkgs.unixODBC.overrideAttrs (oldAttrs: {
configureFlags = [ "--disable-gui" "--sysconfdir=${odbcConfiguration}" ];
});
baseInputs = [
pkgs.stdenv
pkgs.jq
@ -93,7 +98,7 @@ let
pkgs.libmysqlclient
pkgs.mariadb
pkgs.postgresql_15
pkgs.unixODBC
unixODBC
msodbcsql
]
# Linux-specific libraries.
@ -118,11 +123,6 @@ 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.