clean up devShell templates

This commit is contained in:
Max 2025-03-13 21:38:31 +01:00 committed by Héctor Ramón Jiménez
parent a81f0a2459
commit da6e292879
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -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`: You can add this `shell.nix` to your project and use it by running `nix-shell`:
```nix ```nix
{ pkgs ? import <nixpkgs> {} }: { pkgs ? import <nixpkgs> { } }:
pkgs.mkShell rec { let
buildInputs = with pkgs; [ dlopenLibraries = with pkgs; [
expat
fontconfig
freetype
freetype.dev
libGL
pkg-config
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr
wayland
libxkbcommon 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 = # additional libraries that your project
builtins.foldl' (a: b: "${a}:${b}/lib") "${pkgs.vulkan-loader}/lib" buildInputs; # 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 ```nix
{ {
inputs = { inputs = {
nixpkgs.url = "nixpkgs/nixos-unstable"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils"; systems.url = "github:nix-systems/default";
}; };
outputs = { outputs = { nixpkgs, systems, ... }:
nixpkgs, let
flake-utils, eachSystem = nixpkgs.lib.genAttrs (import systems);
... pkgsFor = nixpkgs.legacyPackages;
}: in {
flake-utils.lib.eachDefaultSystem ( devShells = eachSystem (system:
system: let let
pkgs = import nixpkgs { pkgs = pkgsFor.${system};
inherit system; dlopenLibraries = with pkgs; [
}; libxkbcommon
buildInputs = with pkgs; [ # GPU backend
expat vulkan-loader
fontconfig # libGL
freetype
freetype.dev
libGL
pkg-config
xorg.libX11
xorg.libXcursor
xorg.libXi
xorg.libXrandr
wayland
libxkbcommon
];
in {
devShells.default = pkgs.mkShell {
inherit buildInputs;
LD_LIBRARY_PATH = # Window system
builtins.foldl' (a: b: "${a}:${b}/lib") "${pkgs.vulkan-loader}/lib" buildInputs; 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}";
};
});
};
} }
``` ```