Skip to content

Commit

Permalink
Nix: Get the Nix shell working on macOS/aarch64.
Browse files Browse the repository at this point in the history
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 NixOS/nixpkgs#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: hasura/graphql-engine-mono#5989
GitOrigin-RevId: 7130738d47709c37778b31c134061758ce23e959
  • Loading branch information
SamirTalwar authored and hasura-bot committed Sep 30, 2022
1 parent c46a50d commit b52dc90
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
10 changes: 5 additions & 5 deletions .envrc.local.example
Original file line number Diff line number Diff line change
@@ -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
6 changes: 2 additions & 4 deletions scripts/make/ghcid.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
Expand All @@ -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) \
Expand Down Expand Up @@ -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)


0 comments on commit b52dc90

Please sign in to comment.