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

examples/multiple-binaries does not respect name and version #347

Open
i-am-logger opened this issue Feb 14, 2025 · 2 comments
Open

examples/multiple-binaries does not respect name and version #347

i-am-logger opened this issue Feb 14, 2025 · 2 comments

Comments

@i-am-logger
Copy link

i-am-logger commented Feb 14, 2025

executing

nix eval --raw .#bar

results is

/nix/store/wf1kyxmlghmq0l2mxksidxq3w7xwjly3-rust-workspace-unknown⏎

expected having version

bar-0.1.0⏎

same goes for foo

@i-am-logger
Copy link
Author

i-am-logger commented Feb 14, 2025

also, i actually think that it will be better if we can import the package name from Cargo.toml then define it in nix

that will require to point directly to the package toml file rather then the workspace directory

# For `nix build .#bar` and `nix run .#bar`:
packages.bar = naersk'.buildPackage {
  src = ./crates/bar;
};

# For `nix build .#foo` and `nix run .#foo`:
packages.foo = naersk'.buildPackage {
  src = ./crates/foo;
};

@i-am-logger i-am-logger changed the title examples/multiple-binaries do not respect name and version in Cargo.toml examples/multiple-binaries does not respect name and version Feb 14, 2025
@i-am-logger
Copy link
Author

I ended up making it work as follow:

let
  naersk' = pkgs.callPackage naersk { };

  readCargoToml =
    path:
    let
      toml = builtins.fromTOML (builtins.readFile path);
    in
    {
      version = toml.package.version or "unknown";
      name = toml.package.name;
    };

  cargo = readCargoToml ./api/Cargo.toml;
in
naersk'.buildPackage {
  name = cargo.name;
  pname = cargo.name;
  src = ./.;
  doCheck = true;
  release = true;
  version = cargo.version;

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

1 participant