From da6e292879b8e2fae3ea6bdf08343dbcdf7a43cb Mon Sep 17 00:00:00 2001 From: Max Date: Thu, 13 Mar 2025 21:38:31 +0100 Subject: [PATCH] clean up devShell templates --- DEPENDENCIES.md | 109 ++++++++++++++++++++++++++---------------------- 1 file changed, 59 insertions(+), 50 deletions(-) diff --git a/DEPENDENCIES.md b/DEPENDENCIES.md index 6ae9995e..7516d982 100644 --- a/DEPENDENCIES.md +++ b/DEPENDENCIES.md @@ -11,26 +11,33 @@ get them, if your system isn't here, add it! You can add this `shell.nix` to your project and use it by running `nix-shell`: ```nix -{ pkgs ? import {} }: +{ pkgs ? import { } }: -pkgs.mkShell rec { - buildInputs = with pkgs; [ - expat - fontconfig - freetype - freetype.dev - libGL - pkg-config - xorg.libX11 - xorg.libXcursor - xorg.libXi - xorg.libXrandr - wayland +let + dlopenLibraries = with pkgs; [ libxkbcommon + + # GPU backend + vulkan-loader + # libGL + + # Window system + wayland + # xorg.libX11 + # xorg.libXcursor + # xorg.libXi + ]; +in pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + cargo + rustc ]; - LD_LIBRARY_PATH = - builtins.foldl' (a: b: "${a}:${b}/lib") "${pkgs.vulkan-loader}/lib" buildInputs; + # additional libraries that your project + # links to at build time, e.g. OpenSSL + buildInputs = []; + + env.RUSTFLAGS = "-C link-arg=-Wl,-rpath,${pkgs.lib.makeLibraryPath dlopenLibraries}"; } ``` @@ -39,43 +46,45 @@ Alternatively, you can use this `flake.nix` to create a dev shell, activated by ```nix { inputs = { - nixpkgs.url = "nixpkgs/nixos-unstable"; - flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + systems.url = "github:nix-systems/default"; }; - outputs = { - nixpkgs, - flake-utils, - ... - }: - flake-utils.lib.eachDefaultSystem ( - system: let - pkgs = import nixpkgs { - inherit system; - }; + outputs = { nixpkgs, systems, ... }: + let + eachSystem = nixpkgs.lib.genAttrs (import systems); + pkgsFor = nixpkgs.legacyPackages; + in { + devShells = eachSystem (system: + let + pkgs = pkgsFor.${system}; + dlopenLibraries = with pkgs; [ + libxkbcommon - buildInputs = with pkgs; [ - expat - fontconfig - freetype - freetype.dev - libGL - pkg-config - xorg.libX11 - xorg.libXcursor - xorg.libXi - xorg.libXrandr - wayland - libxkbcommon - ]; - in { - devShells.default = pkgs.mkShell { - inherit buildInputs; + # GPU backend + vulkan-loader + # libGL - LD_LIBRARY_PATH = - builtins.foldl' (a: b: "${a}:${b}/lib") "${pkgs.vulkan-loader}/lib" buildInputs; - }; - } - ); + # Window system + wayland + # xorg.libX11 + # xorg.libXcursor + # xorg.libXi + ]; + in { + default = pkgs.mkShell { + nativeBuildInputs = with pkgs; [ + cargo + rustc + ]; + + # additional libraries that your project + # links to at build time, e.g. OpenSSL + buildInputs = []; + + env.RUSTFLAGS = "-C link-arg=-Wl,-rpath,${nixpkgs.lib.makeLibraryPath dlopenLibraries}"; + }; + }); + }; } ```