Skip to content

Commit

Permalink
cargoTomlContents: ignore context of Cargo.toml file (#762)
Browse files Browse the repository at this point in the history
  • Loading branch information
ipetkov authored Dec 16, 2024
1 parent 6046371 commit a984d90
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Fixed
* `mkDummySrc` will deduplicate discovered and declared binary targets when
dummifying sources
* `crateNameFromCargoToml` will ignore store contexts when parsing a Cargo.toml
file (avoiding errors like `the string ... is not allowed to refer to a store
path`).

### Meta
* Dropped support for publishing releases to https://flakestry.dev/
Expand Down
9 changes: 9 additions & 0 deletions checks/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,15 @@ in
};
};

customDummyWithMkDummySrcNoPname = myLib.buildDepsOnly {
dummySrc = myLib.mkDummySrc {
src = myLib.cleanCargoSource ./simple;
postInstall = ''
touch $out/blah.txt
'';
};
};

# https://github.com/ipetkov/crane/pull/234
nonJsonCargoBuildLog =
let
Expand Down
7 changes: 6 additions & 1 deletion lib/crateNameFromCargoToml.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,12 @@ let
else throwMsg
);

toml = builtins.fromTOML cargoTomlContents;
# NB: if `src` is derived via `mkDummySrc` the Cargo.toml will contain store paths
# (e.g. build script stubs), which the fromTOML does not like since the context isn't
# threaded through (error is `the string ... is not allowed to refer to a store path`).
# We can work around this by discarding the context before parsing the TOML since we don't
# actually care about any dependency derivations, we just want to parse the name and version
toml = builtins.fromTOML (builtins.unsafeDiscardStringContext cargoTomlContents);

debugPath =
if args ? cargoTomlContents
Expand Down

0 comments on commit a984d90

Please sign in to comment.