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

flake: migrate to crane, unpin Nixpkgs, use static builds on Darwin #1380

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

emilazy
Copy link

@emilazy emilazy commented Jan 10, 2025

Description

This should fix the macOS uninstallation bug, as well as simplifying the flake and making the static builds more robust on all platforms. See the commit messages for details, justifications, and potential caveats.


Note: This work was funded by Determinate Systems.

Checklist
  • Formatted with cargo fmt
  • Built with nix build
  • Ran flake checks with nix flake check (minus hydraJobs, which looked like it’d take all year – caveat emptor)
  • Added or updated relevant tests (leave unchecked if not applicable)
  • Added or updated relevant documentation (leave unchecked if not applicable)
  • Linked to related issues (leave unchecked if not applicable)
Validating with install.determinate.systems

If a maintainer has added the upload to s3 label to this PR, it will become available for installation via install.determinate.systems:

curl --proto '=https' --tlsv1.2 -sSf -L https://install.determinate.systems/nix/pr/$PR_NUMBER | sh -s -- install

This belongs in `packages` instead (where a duplicate is already
present anyway).
Crane handles cross‐compilation a bit better and seems to be
generally more actively maintained than Naersk.

We use Nixpkgs’ stock Rust toolchains instead of bringing in fenix,
as Nixpkgs provides everything we need and tracks upstream stable
Rust well. This also simplifies the cross‐compilation story.

This doesn’t build the documentation like the Naersk build did,
which I guess might be useful to ensure that the documentation
always builds? That could be added on as a check if desired, using
`craneLib.cargoDoc`.
Crane handles setting these for us.
This would be done differently with crane using
`craneLib.cargoClippy`. That could be added as a check if desired.
I assume it was not the intent to override the configuration flags
and test behaviour of all dependencies.
This is cleaner, handles any future native dependencies correctly,
and will work more consistently across platforms (such as Darwin).
Fix a bug where the installer would link against a `libiconv` in the
Nix store.

This would silently fail to load (falling back to the system
`libiconv`, I suppose? I’m not sure) when the Nix store was not
present – as is usually the case when running the installer – but
after installation, the store path could be populated by normal use
of Nix. If that happened, then upon uninstallation, the Nix store
`libiconv` would be loaded, the installer would delete the `/nix`
partition, and then the next time a system library indirectly caused
`dyld` to check up on what’s going on with the loaded dynamic
libraries, it would try to read from an address mapped to the library
in the now‐deleted Nix store and crash.

Now that `pkgsStatic` works after Randy’s Darwin rework to provide
mostly‐static builds (system libraries and frameworks are dynamically
linked, but libraries from Nixpkgs are linked statically), we can build
a truly standalone installer that has no dependency on `/nix/store`,
fixing the crash for good.
None of this is required or does anything as of 24.11.
Copy link
Member

@cole-h cole-h left a comment

Choose a reason for hiding this comment

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

Amazing! Thanks a ton for all your hard work!

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.

2 participants