nix-community / naersk

Build Rust projects in Nix - no configuration, no code generation, no IFD, sandbox friendly.
MIT License
668 stars 84 forks source link

[help] Assets folder for bevy engine #225

Open ghost opened 2 years ago

ghost commented 2 years ago

Assets folder doesnt get copyed into build env.

lithdew commented 2 years ago

I've encountered the same issue building projects that include the bytes of files into their source code using include_bytes!, as the files themselves get removed from the source tree in amidst the build phase.

Did you manage to find any workaround to this?

ghost commented 2 years ago

Sorry no luck yet but I will likly move away from naesrsk to try the nixpkg rustPlatform tools

On Sun, Jan 23, 2022, 8:17 PM Kenta Iwasaki @.***> wrote:

I've encountered the same issue building projects that include the bytes of files into their source code using include_bytes!, as the files themselves get removed from the source tree in amidst the build phase.

Did you manage to find any workaround to this?

— Reply to this email directly, view it on GitHub https://github.com/nix-community/naersk/issues/225#issuecomment-1019650987, or unsubscribe https://github.com/notifications/unsubscribe-auth/AMM2DGUANMLGDEXVV3P44DLUXSZCPANCNFSM5MEW2PQA . You are receiving this because you authored the thread.Message ID: @.***>

ry755 commented 1 year ago

I'm also running into this issue with my project that uses include_bytes!, it would be great if there was a way to specify extra files/folders that would get copied into the build environment.

Patryk27 commented 1 year ago

Hi, I've just checked it and include_bytes!() seems to be working correctly on current Naersk; would you mind checking again on your side and posting some failing code, if it still doesn't compile?

As for the assets, I'd recommend using a postInstall hook - something in terms of:

naersk.buildPackage {
  # ...

  postInstall = ''
    ln -s ${./assets} $out/assets
  '';
}
ry755 commented 1 year ago

After doing some experimenting I found out that Nix's nix build command only seems to copy the contents of the git repo, not the actual contents of the source directory. The file used in my include_bytes! macro call doesn't actually exist in the git repo, it's a built binary file that is placed there by the user. I found that if I git add that file before running nix build, then it works properly.