rust_vulkan_test/flake.nix

75 lines
2.4 KiB
Nix

{
description = "Rust ASH test rust configuration";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
nixgl = {
# Revert this to community version when https://github.com/nix-community/nixGL/pull/187 is merged
url = "github:phirsch/nixGL/fix-versionMatch";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = { self, nixpkgs, flake-utils, rust-overlay, nixgl }:
flake-utils.lib.eachSystem flake-utils.lib.allSystems (system:
let
overlays = [ (import rust-overlay) nixgl.overlay ];
pkgs = import nixpkgs {
inherit system overlays;
config.allowUnfree = true;
};
rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
rustPlatform = pkgs.recurseIntoAttrs (pkgs.makeRustPlatform {
rustc = rust;
cargo = rust;
});
buildInputs = with pkgs; [ vulkan-headers vulkan-loader vulkan-validation-layers ]
++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isLinux (with pkgs; [ libxkbcommon wayland libGL ])
++ pkgs.lib.optionals pkgs.stdenv.hostPlatform.isDarwin (with pkgs; [ darwin.apple_sdk.frameworks.SystemConfiguration ]);
nativeBuildInputs = with pkgs; [
pkg-config
cmake
python312
];
in
{
devShells = {
default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
(rust.override { extensions = [ "rust-src" "rust-analyzer" ]; })
] ++ nativeBuildInputs;
buildInputs = buildInputs
++ [ pkgs.nixgl.auto.nixVulkanNvidia pkgs.nixgl.nixVulkanMesa ];
LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs;
VK_LAYER_PATH = "${pkgs.vulkan-validation-layers}/share/vulkan/explicit_layer.d";
RUST_LOG = "info,rust_vulkan_test=trace";
};
};
packages = {
default = rustPlatform.buildRustPackage {
pname = "rust_ash_test";
version = "0.1.0";
src = self;
inherit nativeBuildInputs buildInputs;
cargoLock = {
lockFile = ./Cargo.lock;
};
};
};
});
}