Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions config.nix
Original file line number Diff line number Diff line change
Expand Up @@ -427,9 +427,15 @@ let
packageVersion =
if ! isNull attrs.version
then attrs.version
else toplevelCargotoml.package.version
or toplevelCargotoml."workspace.package".version
or "unknown";
else
let
toppackver = toplevelCargotoml.package.version or null;
in
if lib.isString toppackver || lib.isInt toppackver then
toppackver
else if (toppackver.workspace or false) then
toplevelCargotoml.workspace.package.version or "unknown"
else "unknown";
};
in
buildPlanConfig // { inherit buildConfig; }
5 changes: 3 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,11 @@ let
else if builtins.pathExists (toString config.root + "/.cargo/config")
then (config.root + "/.cargo/config")
else null;
version_ = config.packageVersion;
version = if version_ == "unknown" then builtins.trace config version_ else version_;
build = args: import ./build.nix (
{
inherit gitDependencies;
version = config.packageVersion;
inherit gitDependencies version;
} // config.buildConfig // defaultBuildAttrs // args
);

Expand Down
2 changes: 2 additions & 0 deletions test/fast/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,7 @@
workspace = pkgs.callPackage ./workspace { inherit naersk; };
workspace-build-rs = pkgs.callPackage ./workspace-build-rs { inherit naersk; };
workspace-deps = pkgs.callPackage ./workspace-deps { inherit naersk; };
workspace-meta = pkgs.callPackage ./workspace-meta { inherit naersk; };
workspace-meta-single = pkgs.callPackage ./workspace-meta-single { inherit naersk; };
workspace-patched = pkgs.callPackage ./workspace-patched { inherit naersk; };
}
13 changes: 13 additions & 0 deletions test/fast/workspace-meta-single/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# workspace-meta

Tests that metadata can be read from the workspace via the workspace's `[package]`:

```toml
[workspace.package]
version = "0.0.1"
...

[package]
version = { workspace = true }
...
```
6 changes: 6 additions & 0 deletions test/fast/workspace-meta-single/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ naersk, ... }:

naersk.buildPackage {
src = ./fixtures;
doCheck = true;
}
7 changes: 7 additions & 0 deletions test/fast/workspace-meta-single/fixtures/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions test/fast/workspace-meta-single/fixtures/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
[workspace]

resolver = "2"

[workspace.package]
version = "0.0.1"
edition = "2021"



[package]
name = "foo"
version = { workspace = true }
edition = { workspace = true }
3 changes: 3 additions & 0 deletions test/fast/workspace-meta-single/fixtures/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}
10 changes: 10 additions & 0 deletions test/fast/workspace-meta/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# workspace-meta

Tests that metadata can be read from the workspace:

```toml
[package]
name = "foo"
version = { workspace = true }
edition = { workspace = true }
```
6 changes: 6 additions & 0 deletions test/fast/workspace-meta/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{ naersk, ... }:

naersk.buildPackage {
src = ./fixtures;
doCheck = true;
}
7 changes: 7 additions & 0 deletions test/fast/workspace-meta/fixtures/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions test/fast/workspace-meta/fixtures/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[workspace]

resolver = "2"

members = [
"foo",
]

[workspace.package]
version = "0.0.1"
edition = "2021"


6 changes: 6 additions & 0 deletions test/fast/workspace-meta/fixtures/foo/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[package]
name = "foo"
version = { workspace = true }
edition = { workspace = true }

[dependencies]
3 changes: 3 additions & 0 deletions test/fast/workspace-meta/fixtures/foo/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}
Loading