|
| 1 | +# This file is only relevant for Nix and NixOS users. |
| 2 | +# What's actually meant by "Nix" here is not UNIX, but the *package manager* Nix, see https://nixos.org/. |
| 3 | +# If you are |
| 4 | +# on macOS (and not using nix-darwin) |
| 5 | +# or on Windows (and not using Nix in WSL), |
| 6 | +# you can carelessly ignore this file. |
| 7 | +# |
| 8 | +# Otherwise, if you *do* use Nix the package manager, |
| 9 | +# this file declares |
| 10 | +# common dependencies |
| 11 | +# and some nice tools |
| 12 | +# which you'll most likely need when working with wgpu. |
| 13 | +# Feel free to copy it into your own project if deemed useful. |
| 14 | +# |
| 15 | +# To use this file, just run `nix-shell` in this folder, |
| 16 | +# which will drop you into a shell |
| 17 | +# with all the deps needed for building wgpu available. |
| 18 | +# |
| 19 | +# Or if you're using direnv (https://direnv.net/), |
| 20 | +# use `direnv allow` to automatically always use this file |
| 21 | +# if you're navigating into this or a subfolder. |
| 22 | + |
| 23 | +{ pkgs ? import <nixpkgs> {} }: |
| 24 | + |
| 25 | +pkgs.mkShell rec { |
| 26 | + buildInputs = with pkgs; [ |
| 27 | + # necessary for building wgpu in 3rd party packages (in most cases) |
| 28 | + libxkbcommon |
| 29 | + wayland xorg.libX11 xorg.libXcursor xorg.libXrandr xorg.libXi |
| 30 | + alsa-lib |
| 31 | + fontconfig freetype |
| 32 | + shaderc directx-shader-compiler |
| 33 | + pkg-config cmake |
| 34 | + mold # could use any linker, needed for rustix (but mold is fast) |
| 35 | + |
| 36 | + libGL |
| 37 | + vulkan-headers vulkan-loader |
| 38 | + vulkan-tools vulkan-tools-lunarg |
| 39 | + vulkan-extension-layer |
| 40 | + vulkan-validation-layers # don't need them *strictly* but immensely helpful |
| 41 | + |
| 42 | + # necessary for developing (all of) wgpu itself |
| 43 | + cargo-nextest cargo-fuzz |
| 44 | + |
| 45 | + # nice for developing wgpu itself |
| 46 | + typos |
| 47 | + |
| 48 | + # if you don't already have rust installed through other means, |
| 49 | + # this shell.nix can do that for you with this below |
| 50 | + yq # for tomlq below |
| 51 | + rustup |
| 52 | + |
| 53 | + # nice tools |
| 54 | + gdb rr |
| 55 | + evcxr |
| 56 | + valgrind |
| 57 | + renderdoc |
| 58 | + ]; |
| 59 | + |
| 60 | + shellHook = '' |
| 61 | + export RUSTC_VERSION="$(tomlq -r .toolchain.channel rust-toolchain.toml)" |
| 62 | + export PATH="$PATH:''${CARGO_HOME:-~/.cargo}/bin" |
| 63 | + export PATH="$PATH:''${RUSTUP_HOME:-~/.rustup/toolchains/$RUSTC_VERSION-x86_64-unknown-linux/bin}" |
| 64 | + export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${builtins.toString (pkgs.lib.makeLibraryPath buildInputs)}"; |
| 65 | +
|
| 66 | + rustup default $RUSTC_VERSION |
| 67 | + rustup component add rust-src rust-analyzer |
| 68 | + ''; |
| 69 | +} |
0 commit comments