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`:
```nix
{ pkgs ? import <nixpkgs> {} }:
{ pkgs ? import <nixpkgs> { } }:
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}";
};
});
};
}
```