graphql-engine/nix/shell.nix
Samir Talwar f2fe9f9579 Nix: Upgrade Ormolu to v0.7.0.0.
This requires serious monkey-patching.

We start with v0.6.0.1, upgrade its `src`, and override dependencies to make the version constraints happy.

We build it with GHC 9.4 because it bundles text v2, which is required for Ormolu v0.5.3 and up. This means we can't just override the Hackage package; instead, we override the root-level package and use that directly.

Because of this, HLS will use the wrong Ormolu version. We can resolve this once we upgrade to GHC 9.4 *and* a version of hls-ormolu-plugin is released which supports this version of Ormolu (at the time of writing, only v0.5.x and older are supported).

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/9289
GitOrigin-RevId: 438fe045bc74834d99b80b8822bfb609ac11ada1
2023-05-24 23:02:03 +00:00

164 lines
4.5 KiB
Nix

{ pkgs, system }:
let
versions = import ./versions.nix { inherit pkgs; };
# empty package, for shenanigans
empty = builtins.derivation {
inherit system;
name = "empty";
builder = pkgs.writeShellScript "null.sh" "${pkgs.coreutils}/bin/mkdir $out";
};
# Unix ODBC Support
freetdsWithODBC = pkgs.freetds.override {
odbcSupport = true;
inherit 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.
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}" ];
});
# Ensure that GHC and HLS have access to all the dynamic libraries we have kicking around.
ghc =
let original = pkgs.haskell.compiler.${pkgs.ghcName};
in pkgs.stdenv.mkDerivation
{
name = original.name;
src = empty;
buildInputs = [ original pkgs.makeWrapper ];
installPhase = ''
mkdir -p "$out/bin"
makeWrapper ${original}/bin/ghc "$out/bin/ghc" \
--set LD_LIBRARY_PATH ${pkgs.lib.strings.makeLibraryPath dynamicLibraries} \
--set DYLD_LIBRARY_PATH ${pkgs.lib.strings.makeLibraryPath dynamicLibraries}
'';
};
hls =
let original = pkgs.haskell.packages.${pkgs.ghcName}.haskell-language-server;
in pkgs.stdenv.mkDerivation
{
name = original.name;
src = empty;
buildInputs = [ original pkgs.makeWrapper ];
installPhase = ''
mkdir -p "$out/bin"
makeWrapper ${original}/bin/haskell-language-server "$out/bin/haskell-language-server" \
--set LD_LIBRARY_PATH ${pkgs.lib.strings.makeLibraryPath dynamicLibraries} \
--set DYLD_LIBRARY_PATH ${pkgs.lib.strings.makeLibraryPath dynamicLibraries}
makeWrapper ${original}/bin/haskell-language-server-wrapper "$out/bin/haskell-language-server-wrapper" \
--set LD_LIBRARY_PATH ${pkgs.lib.strings.makeLibraryPath dynamicLibraries} \
--set DYLD_LIBRARY_PATH ${pkgs.lib.strings.makeLibraryPath dynamicLibraries}
'';
};
baseInputs = [
pkgs.stdenv
pkgs.jq
];
consoleInputs = [
pkgs.google-cloud-sdk
pkgs."nodejs-${versions.nodejsVersion}_x"
pkgs."nodejs-${versions.nodejsVersion}_x".pkgs.typescript-language-server
];
docsInputs = [
pkgs.yarn
];
integrationTestInputs = [
pkgs.python3
pkgs.pyright # Python type checker
];
# The version of GHC in `ghcName` is set in nix/overlays/ghc.nix.
haskellInputs = [
pkgs.cabal2nix
# Ormolu is special; it's provided by our overlay.
pkgs.ormolu
ghc
hls
pkgs.haskell.packages.${pkgs.ghcName}.alex
pkgs.haskell.packages.${pkgs.ghcName}.apply-refact
(versions.ensureVersion pkgs.haskell.packages.${pkgs.ghcName}.cabal-install)
pkgs.haskell.packages.${pkgs.ghcName}.ghcid
pkgs.haskell.packages.${pkgs.ghcName}.happy
(versions.ensureVersion pkgs.haskell.packages.${pkgs.ghcName}.hlint)
pkgs.haskell.packages.${pkgs.ghcName}.hoogle
pkgs.haskell.packages.${pkgs.ghcName}.hspec-discover
];
devInputs = [
pkgs.nixpkgs-fmt
pkgs.shellcheck
pkgs.terraform
pkgs.gopls
];
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_15
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;
}