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

cargo-watch: fix darwin build #213072

Merged
merged 1 commit into from
Feb 2, 2023
Merged

cargo-watch: fix darwin build #213072

merged 1 commit into from
Feb 2, 2023

Conversation

tjni
Copy link
Contributor

@tjni tjni commented Jan 28, 2023

Since version 8.2.0, cargo-watch pulls in mac-notification-sys version (through notify-rust) that requires Cocoa.

I also made two minor changes:

  1. The repository owner is now named watchexec.
  2. Since r-ryantm now updates this, there won't be as many opportunities to change sha256 to hash manually, so I went ahead and did that here even though the hash hasn't changed.

Regressed in #208410. Fixes #212987.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 23.05 Release Notes (or backporting 22.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

Since version 8.2.0, cargo-watch pulls in mac-notification-sys version
(through notify-rust) that requires Cocoa.
@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label Jan 28, 2023
@ofborg ofborg bot requested a review from ivan January 28, 2023 05:09
@ofborg ofborg bot added 10.rebuild-darwin: 1-10 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Jan 28, 2023
@NickCao
Copy link
Member

NickCao commented Jan 28, 2023

This is also a nice chance to remove the toplevel inherit, see: #204303

@tjni
Copy link
Contributor Author

tjni commented Jan 28, 2023

I don't really understand what the correct fix is for that. There seems to be several proposals in that thread.

@NickCao
Copy link
Member

NickCao commented Jan 28, 2023

The easy way is to completely remove the inherit, then use darwin.apple_sdk.frameworks.SomeFramework directly in default.nix, see pkgs/applications/editors/amp/default.nix for an example. But there's currently little benefit in doing this, leaving it as-is is also fine.

@winterqt
Copy link
Member

winterqt commented Jan 28, 2023

This is also a nice chance to remove the toplevel inherit, see: #204303

I don't think we're actually doing that for Darwin frameworks as of right now, see #204924 (comment).

Copy link
Member

@winterqt winterqt left a comment

Choose a reason for hiding this comment

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

Looks like we're going to have to mark this as broken on x86_64-darwin until the 11.0 bootstrap SDK lands.

With the following diff, Rust still brings in 10.13 SDK references:

diff --git a/pkgs/development/tools/rust/cargo-watch/default.nix b/pkgs/development/tools/rust/cargo-watch/default.nix
index c06420d2530..1c82c703c19 100644
--- a/pkgs/development/tools/rust/cargo-watch/default.nix
+++ b/pkgs/development/tools/rust/cargo-watch/default.nix
@@ -15,6 +15,10 @@ rustPlatform.buildRustPackage rec {
 
   buildInputs = lib.optionals stdenv.isDarwin [ Cocoa CoreServices Foundation libiconv ];
 
+  preBuild = ''
+    export HOME="$TMPDIR"
+  '';
+
   # `test with_cargo` tries to call cargo-watch as a cargo subcommand
   # (calling cargo-watch with command `cargo watch`)
   preCheck = ''
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 8bbf92d6c26..ac702044b9a 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -15724,8 +15724,8 @@ with pkgs;
   cargo-wasi = callPackage ../development/tools/rust/cargo-wasi {
     inherit (darwin.apple_sdk.frameworks) Security;
   };
-  cargo-watch = callPackage ../development/tools/rust/cargo-watch {
-    inherit (darwin.apple_sdk.frameworks) Cocoa CoreServices Foundation;
+  cargo-watch = darwin.apple_sdk_11_0.callPackage ../development/tools/rust/cargo-watch {
+    inherit (darwin.apple_sdk_11_0.frameworks) Cocoa CoreServices Foundation;
   };
   cargo-wipe = callPackage ../development/tools/rust/cargo-wipe { };
   cargo-workspaces = callPackage ../development/tools/rust/cargo-workspaces {

@wegank
Copy link
Member

wegank commented Jan 28, 2023

Then we can apply #209065 (or the well-aged #180931) to get this build on x86_64-darwin.

$ nix-build -A cargo-watch --argstr system x86_64-darwin
/nix/store/amkzm5iqgdybgygn4isvsf49hkxcq1h8-cargo-watch-8.3.0

@mweinelt mweinelt added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Feb 1, 2023
@wegank wegank merged commit 79b6e4c into NixOS:master Feb 2, 2023
@tjni tjni deleted the cargo-watch branch February 27, 2023 17:45
@tjni tjni mentioned this pull request Jun 11, 2023
12 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: darwin Running or building packages on Darwin 10.rebuild-darwin: 1-10 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux 12.approvals: 1 This PR was reviewed and approved by one reputable person
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cargo-watch fails to build on aarch64-darwin
6 participants