{ 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 = { url = "github:nix-community/nixGL"; 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 ]; mkRustVulkanShell = { nixGLSupport ? true }: pkgs.mkShell { nativeBuildInputs = with pkgs; [ (rust.override { extensions = ["rust-src" "rust-analyzer"]; }) ] ++ nativeBuildInputs; buildInputs = buildInputs ++ pkgs.lib.optionals nixGLSupport [ pkgs.nixgl.auto.nixVulkanNvidia pkgs.nixgl.nixVulkanIntel ]; LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath buildInputs; VK_LAYER_PATH = "${pkgs.vulkan-validation-layers}/share/vulkan/explicit_layer.d"; }; in { devShells = { default = mkRustVulkanShell {}; # Crash with error: cannot coerce null to a string: null nixos = mkRustVulkanShell { nixGLSupport = false; }; }; packages = { default = rustPlatform.buildRustPackage { pname = "rust_ash_test"; version = "0.1.0"; src = self; inherit nativeBuildInputs buildInputs; cargoLock = { lockFile = ./Cargo.lock; }; }; }; }); }