Open leo60228 opened 3 years ago
cargoBuildOptions = x: x ++ [ "-p" "crate" ];
cargoTestOptions = x: x ++ [ "-p" "crate" ];
worked for me.
I figured that out but forgot to update the issue. I think it's probably worth having its own argument, though.
Thanks for the advice. That worked for me.
Since people here are also using workspaces, has anyone gotten this to work? https://github.com/nmattia/naersk/issues/177
I feel like this is what the targets
option is supposed to do, but it doesn't work. Setting cargoBuildOptions
does the trick indeed
@petabyteboy 's trick works for building the derivation, but I am getting another error when I tried to deploy the derivation from another flake.
I have derivation like this:
defaultPackage = naersk-lib.buildPackage {
root = ../.;
cargoBuildOptions = x: x ++ [ "-p" "jyutping-microservice" ];
cargoTestOptions = x: x ++ [ "-p" "jyutping-microservice" ];
};
and this derivation is used in the member crate(so that I have to use ../.
to reference the workspace)
And I am getting this error when I tried to deploy it with a flake:
error: access to path '/nix/store/Cargo.toml' is forbidden in restricted mode
How should I go about that? any solution on this right now?
Flakes can't reference files outside of the flake. I think to handle this correctly you should either move the flake to the root of the workspace or split the flake into its own repo. As a hacky solution, I think you could reference the entire workspace as an input to the flake.
ty ghost and @leo60228!
I've tried both:
and
The former doesn't work because the argument is in the wrong location, and the latter doesn't work because it's looking for
Cargo.lock
in the wrong location.