naersk
naersk copied to clipboard
non-workspace packages?
Before anything else sorry for this very vague title.
I am trying to build https://github.com/containers/youki/commit/01acab90d0c6969814f57759a0e1bf3f0466baf1 which refers to a package oci_spec
as follows in its Cargo.toml
oci_spec = { version = "0.1.0", path = "./oci_spec" }
but build it fails with this error
warning: Git tree '/home/humancalico/repos/youki' is dirty
error: builder for '/nix/store/phm55ih3ij69x9w9vwyvnj8i0v2kx2f0-youki-deps-0.0.1.drv' failed with exit code 101;
last 10 log lines:
>
> Caused by:
> Unable to update /build/dummy-src/oci_spec
>
> Caused by:
> failed to read `/build/dummy-src/oci_spec/Cargo.toml`
>
> Caused by:
> No such file or directory (os error 2)
> [naersk] cargo returned with exit code 101, exiting
For full logs, run 'nix log /nix/store/phm55ih3ij69x9w9vwyvnj8i0v2kx2f0-youki-deps-0.0.1.drv'.
error: 1 dependencies of derivation '/nix/store/m6bnkq1bkg4h51s5rd3igvq611dsz526-youki-0.0.1.drv' failed to build
adding the package as a workspace like this in Cargo.toml fixes it
[workspace]
members = [
"oci_spec",
]
flake.nix
{
description = "A container runtime written in Rust";
inputs = {
utils.url = "github:numtide/flake-utils";
naersk.url = "github:nmattia/naersk";
};
outputs = { self, nixpkgs, utils, naersk }:
utils.lib.eachDefaultSystem (system: let
# cargoToml = (builtins.fromTOML (builtins.readFile ./Cargo.toml));
pkgs = nixpkgs.legacyPackages."${system}";
naersk-lib = naersk.lib."${system}";
in rec {
# `nix build`
packages.youki = naersk-lib.buildPackage {
pname = "youki";
root = ./.;
buildInputs = with pkgs; [ pkg-config systemd dbus ];
};
defaultPackage = packages.youki;
# `nix run`
apps.youki = utils.lib.mkApp {
drv = packages.youki;
};
defaultApp = apps.youki;
# `nix develop`
devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [ rustc cargo rustfmt systemd dbus go ];
};
});
}
I have the same problem. I guess this could be solved by searching through the cargoToml and adding local dependencies to members
.
Maybe using cargo metadata | jq .workspace_members
would be a better solution then to just use what is in the Cargo.toml
.
I think this is a duplicate of #133 and that issue mentions workarounds, in this case I guess copySources = [ "oci_spec" ]