From 042046bba7077dd0c8b122df66f535f1e79f02e9 Mon Sep 17 00:00:00 2001 From: Samir Talwar Date: Sat, 25 Mar 2023 21:54:21 +0100 Subject: [PATCH] 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 --- nix/shell.nix | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/nix/shell.nix b/nix/shell.nix index 3ef614ddb15..df8193d5fed 100644 --- a/nix/shell.nix +++ b/nix/shell.nix @@ -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.