Building old node versions on ARM macs

Hi,

I’m following the nix-shell tutorial to build version 11 but I’ve run into issues with the build
https://nixos.wiki/wiki/Node.js#Example_nix_shell_for_Node.js_development

I’m getting a linking error as it seems to use an x86 linker rather than one for arm.

ld: symbol(s) not found for architecture x86_64
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[1]: *** [deps/v8/gypfiles/torque.host.mk:201: /private/tmp/nix-build-nodejs-11.15.0.drv-0/node-v11.15.0/out/Release/torque] Error 1
rm b12c0064e4506bb60e8cd66573509bb2c8f8a45c.intermediate
make: *** [Makefile:100: node] Error 2

How do I for nix to use the one for aarch64-darwin? nix-build --argstr system aarch64-linux didn’t work for me.

Here’s what I have in default.nix:

{ pkgs ? import <nixpkgs> {} }:

let
  lib = import <nixpkgs/lib>;
  buildNodeJs = pkgs.callPackage "${<nixpkgs>}/pkgs/development/web/nodejs/nodejs.nix" {
    python = pkgs.python27;
  };

  nodejs = buildNodeJs {
    enableNpm = true;
    version = "11.15.0";
    sha256 = "sha256-aKd2xdi4uRqPKtrCykzkOQrhgEiD7H7JwNampk0wanY=";
  };

  NPM_CONFIG_PREFIX = toString ./npm_config_prefix;

in pkgs.mkShell {
  packages = with pkgs; [
    nodejs
    nodePackages.npm
  ];

  inherit NPM_CONFIG_PREFIX;

  shellHook = ''
    export PATH="${NPM_CONFIG_PREFIX}/bin:$PATH"
  '';
}

Thanks