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

Use TOML serializer from nixpkgs #300

Merged
merged 5 commits into from
Aug 16, 2023
Merged

Use TOML serializer from nixpkgs #300

merged 5 commits into from
Aug 16, 2023

Conversation

Patryk27
Copy link
Contributor

Requires #288.
Closes #263.

nmattia
nmattia previously approved these changes Jul 25, 2023
Copy link
Collaborator

@nmattia nmattia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Didn't know this existed.

@Patryk27
Copy link
Contributor Author

Patryk27 commented Jul 26, 2023

I've rebased just now.

Thanks! Didn't know this existed.

Yeah, the older version in nixpkgs was kinda bad (e.g. didn't support stuff like [[targets."cfg(...)"]]), but the current one looks pretty complete 😄

@Patryk27
Copy link
Contributor Author

Ouch, something's failing on the CI - I'll take a look later 🤨

@Patryk27
Copy link
Contributor Author

Alright, the issue is that older nixpkgs' (< 23) lib.formats.toml doesn't properly handle cases like [target."cfg(\"something\")"], which means that we can't rely on it there.

I've adjusted the logic to use our custom serializer (as it was) for older nixpkgs and rely on the nixpkgs' serializer only when nixpkgs are recent enough, with the intention of getting rid of our custom serializer when nixpkgs v23+ get more widely adopted.

@Patryk27
Copy link
Contributor Author

Huh, it's still failing, but the tests succeed on my Linux machine 🤨 -- lemme check on another one

@Patryk27
Copy link
Contributor Author

Alrighty, done!

nix/sources.json Outdated Show resolved Hide resolved
nmattia
nmattia previously approved these changes Aug 3, 2023
Copy link
Collaborator

@nmattia nmattia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks a lot!

@Patryk27
Copy link
Contributor Author

hmm, analyzing failing tests 🔍

@Patryk27
Copy link
Contributor Author

Alright, got it!

I think #299 caused us to (randomly) bump into rust-lang/cargo#11188 where tl;dr it looks like when both crates.io & Git dependencies are packed together, as we do now:

source = {

... Cargo (sometimes, randomly) decides that Git-based dependencies must have checksums specified, which we don't do for them, since we don't know that checksum:

echo '{"package":null,"files":{}}' > $dest/.cargo-checksum.json

Creating two separate sources (one for crates.io and one for Git dependencies), as I've done in the recent commit just now, seems to avoid the issue (I've checked on aarch64-darwin, x86_64-linux NixOS + x86_64-linux Ubuntu, and everything passed on the first time now).

Copy link
Collaborator

@nmattia nmattia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for all the work!

@Patryk27 Patryk27 merged commit 9bbe32c into master Aug 16, 2023
10 checks passed
@Patryk27 Patryk27 deleted the fix-263/to-toml branch August 16, 2023 09:32
Patryk27 added a commit that referenced this pull request Aug 17, 2023
Before #300, our
`builtinz.toTOML` used to return a string representing the serialized
document which was later redirected into a file:

https://github.com/nix-community/naersk/pull/300/files#diff-b6b537316f2d29c8faf178a110366796811d1bc72f694262c7d2efad79aa984bL238

Over that merge request, this was changed to return a path, to make it
consistent with how nixpkgs' formatters works, but I haven't noticed one
place that still _read_ the file instead of returning a path (which was
fine before, since the code did `echo ... > ...`, but currently the code
does `cp`).

Closes #305.
Patryk27 added a commit that referenced this pull request Aug 17, 2023
Before #300, our
`builtinz.toTOML` used to return a string representing the serialized
document which was later redirected into a file:

https://github.com/nix-community/naersk/pull/300/files#diff-b6b537316f2d29c8faf178a110366796811d1bc72f694262c7d2efad79aa984bL238

Over that merge request, this was changed to return a path, to make it
consistent with how nixpkgs' formatters work - but I haven't noticed one
place that still _read_ the file instead of returning a path (which was
fine before, since the code did `echo ... > ...`, but is not a correct
thing to do for `cp`).

Closes #305.
Patryk27 added a commit that referenced this pull request Aug 17, 2023
Before #300, our
`builtinz.toTOML` used to return a string representing the serialized
document which was later redirected into a file:

https://github.com/nix-community/naersk/pull/300/files#diff-b6b537316f2d29c8faf178a110366796811d1bc72f694262c7d2efad79aa984bL238

Over that merge request, this was changed to return a path, to make it
consistent with how nixpkgs' formatters work - but I haven't noticed one
place that still _read_ the file instead of returning a path (which was
fine before, since the code did `echo ... > ...`, but is not a correct
thing to do for `cp`).

Closes #305.
Patryk27 added a commit that referenced this pull request Aug 17, 2023
Before #300, our
`builtinz.toTOML` used to return a string representing the serialized
document which was later redirected into a file:

https://github.com/nix-community/naersk/pull/300/files#diff-b6b537316f2d29c8faf178a110366796811d1bc72f694262c7d2efad79aa984bL238

Over that merge request, this was changed to return a path, to make it
consistent with how nixpkgs' formatters work - but I haven't noticed one
place that still _read_ the file instead of returning a path (which was
fine before, since the code did `echo ... > ...`, but is not a correct
thing to do for `cp`).

Closes #305.
Patryk27 added a commit that referenced this pull request Aug 18, 2023
Before #300, our
`builtinz.toTOML` used to return a string representing the serialized
document which was later redirected into a file:

https://github.com/nix-community/naersk/pull/300/files#diff-b6b537316f2d29c8faf178a110366796811d1bc72f694262c7d2efad79aa984bL238

Over that merge request, this was changed to return a path, to make it
consistent with how nixpkgs' formatters work - but I haven't noticed one
place that still _read_ the file instead of returning a path (which was
fine before, since the code did `echo ... > ...`, but is not a correct
thing to do for `cp`).

Closes #305.
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

Successfully merging this pull request may close these issues.

naersk rewrites Cargo.toml to something unparseable
2 participants