Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

non-workspace packages? #188

Open
humancalico opened this issue Aug 12, 2021 · 3 comments
Open

non-workspace packages? #188

humancalico opened this issue Aug 12, 2021 · 3 comments

Comments

@humancalico
Copy link

humancalico commented Aug 12, 2021

Before anything else sorry for this very vague title.

I am trying to build containers/youki@01acab9 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 ];
      };
    });
}
@Anderssorby
Copy link
Collaborator

I have the same problem. I guess this could be solved by searching through the cargoToml and adding local dependencies to members.

@FlorianFranzen
Copy link
Contributor

Maybe using cargo metadata | jq .workspace_members would be a better solution then to just use what is in the Cargo.toml.

@tv42
Copy link

tv42 commented Jul 20, 2022

I think this is a duplicate of #133 and that issue mentions workarounds, in this case I guess copySources = [ "oci_spec" ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants