From 7ed254f1839cfd2eb7a0970518dc9285a98257bb Mon Sep 17 00:00:00 2001 From: Florian RICHER Date: Wed, 8 Jan 2025 23:12:09 +0100 Subject: [PATCH] Fix NixOS not running --- .envrc | 2 +- flake.nix | 41 +++++++++++++++++++---------------------- src/renderer/app.rs | 2 -- 3 files changed, 20 insertions(+), 25 deletions(-) diff --git a/.envrc b/.envrc index 3550a30..2f8e1d3 100644 --- a/.envrc +++ b/.envrc @@ -1 +1 @@ -use flake +use flake --impure diff --git a/flake.nix b/flake.nix index 8386939..687120b 100644 --- a/flake.nix +++ b/flake.nix @@ -30,36 +30,34 @@ 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; [ - (rust.override { extensions = ["rust-src" "rust-analyzer"]; }) pkg-config cmake python312 ]; - libs = 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 ]); + 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 = pkgs.mkShell { - inherit nativeBuildInputs; + default = mkRustVulkanShell {}; - buildInputs = libs; - - LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (with pkgs; [ libxkbcommon wayland libGL ]); - }; - - with_compatibility = pkgs.mkShell { - inherit nativeBuildInputs; - - buildInputs = libs ++ [ - pkgs.nixgl.auto.nixVulkanNvidia pkgs.nixgl.nixVulkanIntel - ]; - - LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath (with pkgs; [ libxkbcommon wayland libGL ]); - }; + # Crash with error: cannot coerce null to a string: null + nixos = mkRustVulkanShell { nixGLSupport = false; }; }; packages = { @@ -69,8 +67,7 @@ src = self; - nativeBuildInputs = with pkgs; [ pkg-config shaderc ]; - buildInputs = libs; + inherit nativeBuildInputs buildInputs; cargoLock = { lockFile = ./Cargo.lock; diff --git a/src/renderer/app.rs b/src/renderer/app.rs index 9788aa2..0c562fd 100644 --- a/src/renderer/app.rs +++ b/src/renderer/app.rs @@ -52,8 +52,6 @@ impl App { enabled_extensions: required_extensions, enabled_layers: vec![ String::from("VK_LAYER_KHRONOS_validation"), - String::from("VK_LAYER_MANGOHUD_overlay_x86_64"), - String::from("VK_LAYER_NV_optimus"), ], ..Default::default() },