2024-11-06 13:18:17 +01:00
|
|
|
{
|
2024-11-06 22:13:46 +01:00
|
|
|
description = "Rust ASH test rust configuration";
|
2024-11-06 13:18:17 +01:00
|
|
|
|
2024-11-06 22:13:46 +01:00
|
|
|
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";
|
2024-11-06 13:18:17 +01:00
|
|
|
};
|
2024-11-19 17:42:35 +01:00
|
|
|
nixgl = {
|
|
|
|
url = "github:nix-community/nixGL";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
inputs.flake-utils.follows = "flake-utils";
|
|
|
|
};
|
2024-11-06 13:18:17 +01:00
|
|
|
};
|
|
|
|
|
2024-11-19 17:42:35 +01:00
|
|
|
outputs = { self, nixpkgs, flake-utils, rust-overlay, nixgl }:
|
2024-11-06 22:13:46 +01:00
|
|
|
flake-utils.lib.eachSystem flake-utils.lib.allSystems (system:
|
2024-11-06 13:18:17 +01:00
|
|
|
let
|
2024-11-19 17:42:35 +01:00
|
|
|
overlays = [ (import rust-overlay) nixgl.overlay ];
|
2024-11-06 13:18:17 +01:00
|
|
|
pkgs = import nixpkgs {
|
2024-11-06 22:13:46 +01:00
|
|
|
inherit system overlays;
|
2024-11-19 17:42:35 +01:00
|
|
|
config.allowUnfree = true;
|
2024-11-06 13:18:17 +01:00
|
|
|
};
|
2024-11-06 22:13:46 +01:00
|
|
|
rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
|
2024-11-06 13:18:17 +01:00
|
|
|
|
2024-11-06 22:13:46 +01:00
|
|
|
rustPlatform = pkgs.recurseIntoAttrs (pkgs.makeRustPlatform {
|
|
|
|
rustc = rust;
|
|
|
|
cargo = rust;
|
|
|
|
});
|
|
|
|
|
2025-01-08 23:12:09 +01:00
|
|
|
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 ]);
|
|
|
|
|
2024-12-22 23:35:39 +01:00
|
|
|
nativeBuildInputs = with pkgs; [
|
|
|
|
pkg-config
|
|
|
|
cmake
|
|
|
|
python312
|
|
|
|
];
|
|
|
|
|
2025-01-08 23:12:09 +01:00
|
|
|
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";
|
|
|
|
};
|
2024-11-06 13:18:17 +01:00
|
|
|
in
|
|
|
|
{
|
2024-11-06 22:13:46 +01:00
|
|
|
devShells = {
|
2025-01-08 23:12:09 +01:00
|
|
|
default = mkRustVulkanShell {};
|
2024-12-22 23:35:39 +01:00
|
|
|
|
2025-01-08 23:12:09 +01:00
|
|
|
# Crash with error: cannot coerce null to a string: null
|
|
|
|
nixos = mkRustVulkanShell { nixGLSupport = false; };
|
2024-11-06 22:13:46 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
packages = {
|
|
|
|
default = rustPlatform.buildRustPackage {
|
|
|
|
pname = "rust_ash_test";
|
|
|
|
version = "0.1.0";
|
|
|
|
|
|
|
|
src = self;
|
|
|
|
|
2025-01-08 23:12:09 +01:00
|
|
|
inherit nativeBuildInputs buildInputs;
|
2024-11-06 13:18:17 +01:00
|
|
|
|
2024-11-06 22:13:46 +01:00
|
|
|
cargoLock = {
|
|
|
|
lockFile = ./Cargo.lock;
|
|
|
|
};
|
|
|
|
};
|
2024-11-06 13:18:17 +01:00
|
|
|
};
|
2024-11-06 22:13:46 +01:00
|
|
|
});
|
2024-11-06 13:18:17 +01:00
|
|
|
}
|