diff --git a/flake.nix b/flake.nix index ff0d70f..2bd9783 100644 --- a/flake.nix +++ b/flake.nix @@ -21,14 +21,12 @@ # docs: https://github.com/oxalica/rust-overlay coremem-wavefront = pkgs.rustPlatform.buildRustPackage { name = "coremem-wavefront"; - # buildInputs = [ pkgs.vulkan-loader ]; - buildInputs = with pkgs; [ - pkgconfig - mesa - xlibsWrapper xorg.libXcursor xorg.libXrandr xorg.libXi - vulkan-tools vulkan-headers vulkan-loader vulkan-validation-layers + buildInputs = [ pkgs.vulkan-loader ]; + nativeBuildInputs = with pkgs; with xorg; [ + rust-toolchain + pkgconfig rustup xlibsWrapper libxkbcommon + libX11 libXcursor libXi libXrandr vulkan-loader ]; - nativeBuildInputs = [ rust-toolchain pkgs.pkgconfig pkgs.mesa pkgs.vulkan-loader ]; src = self; cargoLock = { lockFile = ./Cargo.lock; @@ -39,33 +37,32 @@ # rgpu tests expectedly fail due to a lack of spirv adapter exposed to the builder. doCheck = false; + # enables debug builds, if we want: https://github.com/NixOS/nixpkgs/issues/60919. hardeningDisable = [ "fortify" ]; - # i guess the proper fix for this is to split rustc_codegen_spirv into its own - # package (see how we're also special-casing it in cargoLock), but this suffices too. - postInstall = '' - cp $releaseDir/deps/librustc_codegen_spirv-*.so $out/lib/ + postFixup = let + libPath = nixpkgs.lib.makeLibraryPath [ pkgs.vulkan-loader ]; + in '' + # strictly speaking not *all* binaries need this, but this is easy. + # might be better to use `wrapProgram`, not sure. + echo adding rpath "${libPath}" + patchelf --add-rpath "${libPath}" $out/bin/* ''; + LD_LIBRARY_PATH = nixpkgs.lib.makeLibraryPath [ pkgs.vulkan-loader ]; }; }; defaultPackage = packages.coremem-wavefront; devShells.default = with pkgs; mkShell { - # buildInputs = with pkgs; [ - # rust-toolchain vulkan-loader - # ]; - - # hardeningDisable = [ "fortify" ]; - - # Workaround for https://github.com/NixOS/nixpkgs/issues/60919. + # enables debug builds, if we want: https://github.com/NixOS/nixpkgs/issues/60919. hardeningDisable = [ "fortify" ]; # Allow cargo to download crates. SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt"; buildInputs = [ - pkgconfig rustup xlibsWrapper libxkbcommon + pkgconfig rust-toolchain xlibsWrapper libxkbcommon ]; # Runtime dependencies.