-
I have a problem by using crane with bevy. If I run my quickstart template with bevy using thread 'main' panicked at 'Failed to create root directory "/nix/store/xc03jppghc27vffpvi4w303026x4ilv9-pong-rs-0.1.0/bin/assets" for file asset reader: Os { code: 30, kind: ReadOnlyFilesystem, message: "Read-only file system" }', /nix/store/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee-vendor-cargo-deps/c19b7c6f923b580ac259164a89f2577984ad5ab09ee9d583b888f934adbbe8d0/bevy_asset-0.12.0/src/io/file/mod.rs:48:13
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace The bevy executable tries to create the /assets folder in the install directory. Sorry if this a kind of noob question, however how can I deal with this. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Also I got this problem: I can work around this while manually setting LD_LIBARY_PATH with the path that pkg-config returns, however it still doesn't work like it should |
Beta Was this translation helpful? Give feedback.
-
Hi @LDprg! When Nix builds a derivation it will put the results in It's easy to create that directory as part of the build, you'd need to add another phase which can create it. One example is to use craneLib.buildPackage {
# other args omitted...
postInstall = ''
mkdir -p $out/bin/assets
'';
} For |
Beta Was this translation helpful? Give feedback.
-
Hi @LDprg, I managed to get Bevy building with this Flake: {
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, crane, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
craneLib = crane.lib.${system};
buildDeps = (with pkgs; [
pkg-config
makeWrapper
clang
mold
]);
runtimeDeps = (with pkgs; [
libxkbcommon
alsa-lib
udev
vulkan-loader
wayland
] ++ (with xorg; [
libXcursor
libXrandr
libXi
libX11
]));
my-crate = craneLib.buildPackage rec {
pname = "bevy-flake-template";
src = ./.;
nativeBuildInputs = buildDeps;
buildInputs = runtimeDeps;
postInstall = ''
wrapProgram $out/bin/${pname} \
--prefix LD_LIBRARY_PATH : ${pkgs.lib.makeLibraryPath runtimeDeps} \
--prefix XCURSOR_THEME : "Adwaita"
mkdir -p $out/bin/assets
cp -a assets $out/bin
'';
};
in
{
checks = {
inherit my-crate;
};
packages.default = my-crate;
devShells.default = craneLib.devShell {
checks = self.checks.${system};
RUST_SRC_PATH = "${pkgs.rustPlatform.rustLibSrc}";
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath runtimeDeps}";
XCURSOR_THEME = "Adwaita";
};
});
} I have a full template on my Github here, hopefully this helps you or anyone else looking 🙂. |
Beta Was this translation helpful? Give feedback.
Hi @LDprg, I managed to get Bevy building with this Flake: