servo/etc/shell.nix
Mukilan Thiyagarajan 1efecf9b50
Use system lld on NixOS instead of rust-lld (#30123)
The -Zgcc-ld=lld flag makes rust use the rust-lld
linker that is distributed as part of rust toolchain.
However, this flag doesn't work on nixos correctly
as
  1) rust-lld needs to be patched to have the correct rpath
     to find libz.so
  2) the bin/gcc-ld/ld.lld wrapper which calls rust-lld also
     needs to be patched to use the correct dynamic loader
  3) rust-lld doesn't respect NIX_LDFLAGS which contains
     the additional search path derived from buildInputs.
     The system linkers on nixos are wrapped so that
     NIX_LDFLAGS is added as the rpath to the final binary.

Signed-off-by: Mukilan Thiyagarajan <mukilan@igalia.com>
2023-08-18 06:18:05 +00:00

45 lines
1.3 KiB
Nix

# This provides a shell with all the necesarry packages required to run mach and build servo
# NOTE: This does not work offline or for nix-build
with import <nixpkgs> {};
clangStdenv.mkDerivation rec {
name = "servo-env";
buildInputs = [
# Native dependencies
fontconfig freetype openssl libunwind
xorg.libxcb
xorg.libX11
gst_all_1.gstreamer
gst_all_1.gst-plugins-base
gst_all_1.gst-plugins-bad
rustup
llvmPackages.bintools # provides lld
# Build utilities
cmake dbus gcc git pkg-config which llvm autoconf213 perl yasm m4
(python3.withPackages (ps: with ps; [virtualenv pip dbus]))
] ++ (lib.optionals stdenv.isDarwin [
darwin.apple_sdk.frameworks.AppKit
]);
LIBCLANG_PATH = llvmPackages.clang-unwrapped.lib + "/lib/";
# Allow cargo to download crates
SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
# Enable colored cargo and rustc output
TERMINFO = "${ncurses.out}/share/terminfo";
# Fix missing libraries errors (those libraries aren't linked against, so we need to dynamically supply them)
LD_LIBRARY_PATH = lib.makeLibraryPath [ xorg.libXcursor xorg.libXrandr xorg.libXi libxkbcommon ];
shellHook = ''
# Fix invalid option errors during linking
# https://github.com/mozilla/nixpkgs-mozilla/commit/c72ff151a3e25f14182569679ed4cd22ef352328
unset AS
'';
}