Nix: Get the Nix shell working on macOS/aarch64.

Improvements to the Nix configuration so that macOS is supported.

Microsoft SQL Server is still not supported (yet; I have something in mind there), but the rest works. You can still use Homebrew to install the SQL Server drivers.

I had to make the following changes:

* I updated nixpkgs, because it's been a while.

* I made `ODBCINSTINI` optional so that it's not loaded on macOS, as it depends on `msodbcsql17`, which is broken on macOS.

* I upgraded OpenSSL.

* I set `DYLD_LIBRARY_PATH` on macOS so GHC finds OpenSSL; otherwise, it uses the wrong version of `libcrypto`, and fails with a fun error:

  > WARNING: ghc is loading libcrypto in an unsafe way

* I patched GHC to fix compilation on macOS (copied from https://github.com/NixOS/nixpkgs/pull/149942).

To test this out, you can run `nix develop` (or install [direnv][] and add `use flake` to _.envrc.local_), and then try building HGE in the shell provided.

Fair warning: GHC needs to be built, and takes _aaages_ the first time. If this becomes useful to others, we can set up a shared cache.

[direnv]: https://direnv.net/

PR-URL: https://github.com/hasura/graphql-engine-mono/pull/5989
GitOrigin-RevId: 7130738d47709c37778b31c134061758ce23e959
This commit is contained in:
Samir Talwar 2022-09-30 21:14:53 +02:00 committed by hasura-bot
parent c46a50d950
commit b52dc90663
2 changed files with 7 additions and 9 deletions

View File

@ -1,13 +1,13 @@
#!/usr/bin/env bash
# This is an example .envrc.local file you can start with. Uncomment the parts
# you'd like to use, and copy this to `.envrc.local`
### This is an example .envrc.local file you can start with. Uncomment the parts
### you'd like to use, and copy this to `.envrc.local`.
# Enable providing tooling with the Nix package manager
### Enable providing tooling with the Nix package manager:
# use flake
# Enable providing NodeJS versions with `nvm`
### Enable providing NodeJS versions with `nvm`:
# use nvm
# Enable providing GHC versions with `ghcup`
### Enable providing GHC versions with `ghcup`:
# use ghcup

View File

@ -10,7 +10,7 @@ PANE_HEIGHT = $(shell tmux display -p "\#{pane_height}" || echo 30 )
# this needs to make it into ghcid: https://github.com/biegunka/terminal-size/pull/16
define run_ghcid_hspec_tests
@if [[ $$(uname -p) == 'arm' ]]; then \
HSPEC_MATCH="$(2)" ghcid -c "cabal repl $(1) $(GHCID_TESTS_FLAGS)" \
HSPEC_MATCH="$(2)" ghcid -c "DYLD_LIBRARY_PATH=$$DYLD_LIBRARY_PATH cabal repl $(1) $(GHCID_TESTS_FLAGS)" \
--test "main" \
--width=$(PANE_WIDTH) \
--height=$(PANE_HEIGHT); \
@ -22,7 +22,7 @@ endef
define run_ghcid_main_tests
@if [[ $$(uname -p) == 'arm' ]]; then \
HSPEC_MATCH="$(3)" ghcid -c "cabal repl $(1) $(GHCID_TESTS_FLAGS)" \
HSPEC_MATCH="$(3)" ghcid -c "DYLD_LIBRARY_PATH=$$DYLD_LIBRARY_PATH cabal repl $(1) $(GHCID_TESTS_FLAGS)" \
--test "main" \
--setup ":set args $(2)" \
--width=$(PANE_WIDTH) \
@ -103,5 +103,3 @@ ghcid-library-pro:
## ghcid-test-unit: build and run unit tests in ghcid
ghcid-test-unit: remove-tix-file
$(call run_ghcid_main_tests,graphql-engine:graphql-engine-tests,unit)