From 01a74ab9a6f3fcaad143d2836737bcdd47906d22 Mon Sep 17 00:00:00 2001 From: SeanOMik Date: Thu, 4 Apr 2024 23:58:59 -0400 Subject: [PATCH] Rewrite nix-shell, use mold for the linker --- shell.nix | 56 +++++++++++++++++++++++++++---------------------------- 1 file changed, 27 insertions(+), 29 deletions(-) mode change 100755 => 100644 shell.nix diff --git a/shell.nix b/shell.nix old mode 100755 new mode 100644 index a4c7fef..fdd102f --- a/shell.nix +++ b/shell.nix @@ -1,32 +1,30 @@ let - rust_overlay = import (builtins.fetchTarball https://github.com/oxalica/rust-overlay/archive/master.tar.gz); - nixpkgs = import { overlays = [ rust_overlay ]; }; - - rust = (nixpkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml).override { - extensions = [ "rust-analysis" "rust-src" "miri-preview" ]; + rust_overlay = import (builtins.fetchTarball "https://github.com/oxalica/rust-overlay/archive/master.tar.gz"); + pkgs = import { overlays = [ rust_overlay ]; }; + + rust = (pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml).override { + extensions = [ + "rust-analyzer" + "rust-src" + "miri-preview" + ]; }; in - with nixpkgs; - stdenv.mkDerivation rec { - name = "lyra_engine_dev"; - nativeBuildInputs = [ - pkg-config - openssl - wasm-pack - trunk - valgrind - heaptrack - mold - udev - lua5_4_compat - rust - ]; - buildInputs = [ - udev alsa-lib libGL gcc - vulkan-loader vulkan-headers vulkan-tools - xorg.libX11 xorg.libXcursor xorg.libXi xorg.libXrandr # To use the x11 feature - libxkbcommon wayland # To use the wayland feature - - ]; - LD_LIBRARY_PATH = lib.makeLibraryPath buildInputs; - } +pkgs.mkShell.override { + stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.clangStdenv; +} rec { + buildInputs = [ + rust + ] ++ (with pkgs; [ + pkg-config openssl udev + wasm-pack trunk + heaptrack valgrind + lua5_4_compat + alsa-lib libGL + vulkan-loader vulkan-headers vulkan-tools + libxkbcommon wayland # To use the wayland feature + xorg.libX11 xorg.libXcursor xorg.libXi xorg.libXrandr # To use the x11 feature + ]); + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs; + #RUST_BACKTRACE = 1; +} \ No newline at end of file