I’m having some trouble packaging my desktop Rust app with CraneLib. I initialized the flake with Crane’s quick-start
template, then added the desktopItem
attribute to the craneLib.buildPackage
arguments in order to add a desktop entry for my app to the user’s system. Of course, a necessary step when adding a desktop entry is to also install an icon image somewhere on the system. I borrowed from a previous iteration of the flake that was written by someone else, and added this line to the buildPackage
arguments:
postInstall = "install -Dm644 NuhxBoard.png $out/share/icons/hicolor/128x128/apps/NuhxBoard.png";
However, this doesn’t work. The install
command throws an error, claming that NuhxBoard.png
doesn’t exist. I tried again, updating the path to $src/NuhxBoard.png
. I was then able to inspect the source directory, only to find that it had been cleaned of everything but the src
directory, Cargo.toml
, and Cargo.lock
.
This is pretty simple: the quick-start template uses craneLib.cleanCargoSource
to clear out the source directory before building. However, it became not so simple when I removed the call to that function, only to find that the source directory was still being cleaned in the same manner.
To complicate things further, this image file is being include_bytes!()
ed in my code, which means that when the code compiles, the image file is accessible, but during the postInstall
, it isn’t.
What’s going on here? Is there some automatic source cleaning that craneLib
does that I’m unaware of? Should I use something other than postInstall
to install the app icon?
Here’s a link to the repo if you want to inspect the flake. The last commit with the old flake was 3c9b5947.