Skip to content

Instantly share code, notes, and snippets.

@gustavderdrache
Created December 10, 2019 16:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gustavderdrache/8ac3d0fdb711ffad6228ec205f8403c4 to your computer and use it in GitHub Desktop.
Save gustavderdrache/8ac3d0fdb711ffad6228ec205f8403c4 to your computer and use it in GitHub Desktop.
let
musl = (import <nixpkgs/lib>).systems.examples.musl64;
in
import <nixpkgs> { crossSystem = musl; }
let
pkgs = import ./musl-pkgs.nix;
inherit (pkgs) stdenv fetchurl;
get-key = key: drv: if drv?${key} then drv.${key} else drv.out;
get-lib = get-key "lib";
get-dev = get-key "dev";
sharedLibs = {
inherit (pkgs) openssl zlib libuv;
};
sharedLibFlags = builtins.concatMap
(name: [
"--shared-${name}"
"--shared-${name}-libpath=${get-lib sharedLibs.${name}}/lib"
])
(builtins.attrNames sharedLibs);
pkgConfigPaths =
let
libs = [pkgs.icu] ++ builtins.attrValues sharedLibs;
in
builtins.map (drv: "${get-dev drv}/lib/pkgconfig") libs;
configureFlags = [
"--prefix" "$out"
"--without-npm"
# "--fully-static"
"--cross-compiling"
"--without-snapshot"
"--with-intl=system-icu"
] ++ sharedLibFlags;
in
stdenv.mkDerivation {
name = "node";
src = fetchurl {
url = "https://nodejs.org/dist/v12.13.1/node-v12.13.1.tar.xz";
sha256 = "349e3a739cc26bb0975c0ada12b11933568ecbea459297fe8ae0a2acc351b192";
};
enableParallelBuilding = true;
PKG_CONFIG_PATH = builtins.concatStringsSep ":" pkgConfigPaths;
# nativeBuildInputs = [pkgs.removeReferencesTo];
configurePhase = ''
addToSearchPath PATH ${pkgs.pkg-config}/bin
${pkgs.python2}/bin/python2 ./configure.py ${builtins.concatStringsSep " " configureFlags}
'';
outputs = ["out" "dev" "doc"];
# preFixup = ''
# remove-references-to -t ${pkgs.stdenv.cc} $out/bin/node
# '';
}
@gustavderdrache
Copy link
Author

gustavderdrache commented Dec 10, 2019

$ strings result/bin/node | grep gcc | sed -e 's/:/\n  /g'
libgcc_s.so.1
/nix/store/85y3c2bh0qk8cyg0zcg21m7z5qx8z357-zlib-1.2.11-x86_64-unknown-linux-musl/lib
  /nix/store/5nsva3gfm66f28i7whxi1njh71z6b2mf-libuv-1.33.1-x86_64-unknown-linux-musl/lib
  /nix/store/wf7yfxwpl8rrj3h8b5kn42cjkdiv6whr-openssl-1.1.1d-x86_64-unknown-linux-musl/lib
  /nix/store/9bk2gcz4n5kmgn7r0pagzhfz7y8k7ky6-icu4c-64.2-x86_64-unknown-linux-musl/lib
  /nix/store/7vs9r8304a6a2g70algfqcgikwhz4qsm-musl-1.1.24-x86_64-unknown-linux-musl/lib
  /nix/store/gbz2mydglxzww5r4x9d6qdqbwadg00bn--x86_64-unknown-linux-musl-stage-finalgcc-debug-8.3.0/x86_64-unknown-linux-musl/lib64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment