Darwin use of nix is too unpredictable
Currently GHC's CI infrastructure relies on nix
on Darwin to provide the native toolchain, GHC, and associated build dependencies. While convenient, it is not convinced that this configuration provides us with the environment that a non-Nix Darwin user would see. For instance,
$ cat > toolchain.nix <<EOF
let
sources = import ./nix/sources.nix;
#nixpkgsSrc = sources.nixpkgs;
nixpkgsSrc = <nixpkgs>;
#nixpkgsSrc = /Users/administrator/nixpkgs;
aarch64Pkgs = import nixpkgsSrc { system = "aarch64-darwin"; };
x86Pkgs = import nixpkgsSrc { system = "x86_64-darwin"; };
in
let
ghcVer = "ghc8105Binary";
ghc = aarch64Pkgs.haskell.compiler."${ghcVer}";
alex = hsPkgs.alex;
happy = hsPkgs.happy;
hsPkgs = x86Pkgs.haskellPackages;
in
aarch64Pkgs.writeTextFile {
name = "toolchain";
text = ''
export PATH
PATH="${aarch64Pkgs.autoconf}/bin:$PATH"
PATH="${aarch64Pkgs.automake}/bin:$PATH"
PATH="${aarch64Pkgs.clang}/bin:$PATH"
PATH="${aarch64Pkgs.llvm_11}/bin:$PATH"
PATH="${aarch64Pkgs.coreutils}/bin:$PATH"
export HAPPY="${happy}/bin/happy"
export ALEX="${alex}/bin/alex"
export GHC="${ghc}/bin/ghc"
export SPHINX_BUILD="${aarch64Pkgs.python3Packages.sphinx}/bin/sphinx-build"
export CABAL_INSTALL="${hsPkgs.cabal-install}/bin/cabal"
export CABAL="$CABAL_INSTALL"
export CURSES_LIB_DIRS="${aarch64Pkgs.ncurses}/lib"
'';
}
EOF
$ nix build -I nixpkgs=https://github.com/bgamari/nixpkgs/archive/faf319a81bf.tar.gz -f toolchain.nix
$ source result
$ $CABAL update
$ $CABAL install -w $GHC --lib clock
will fail with a slew of warnings from the system's stdio.h
since the clang
provided by nixpkgs
is incompatible with the system's libc
headers, e.g.:
/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/stdio.h:388:41: error:
warning: pointer is missing a nullability type specifier (_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int (* _Nullable)(void *));
On the other hand, if I drop clang
from PATH
I rather get assembler errors as the assembler is trying to assemble AArch64 assembly as x86 syntax.
Edited by Ben Gamari