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

grafana: fix build failure on darwin #297968

Merged
merged 2 commits into from
Mar 26, 2024
Merged

Conversation

shivaraj-bh
Copy link
Member

@shivaraj-bh shivaraj-bh commented Mar 22, 2024

Description of changes

resolves #273998

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • 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/)
  • 24.05 Release Notes (or backporting 23.05 and 23.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
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@ofborg ofborg bot added the 6.topic: darwin Running or building packages on Darwin label Mar 22, 2024
@shivaraj-bh
Copy link
Member Author

shivaraj-bh commented Mar 22, 2024

Good news! the package successfully builds on aarch64-darwin.

Unfortunately, it fails on x86_64-darwin with no member named 'aligned_alloc' in the global namespace.. I fixed this by borrowing the fix from here.

Later it fails to build https://github.com/mattn/go-ieproxy, which seems to be related to #243298 (comment)

Error while trying to build go-ieproxy:

# github.com/mattn/go-ieproxy
In file included from ../go/pkg/mod/github.com/mattn/go-ieproxy@v0.0.3/ieproxy_darwin.go:7:
In file included from /nix/store/fgvsc1in07pjmp057dar58k2wms3nk6b-apple-framework-CFNetwork-11.0.0/Library/Frameworks/CFNetwork.framework/Headers/CFProxySup>
In file included from /nix/store/fgvsc1in07pjmp057dar58k2wms3nk6b-apple-framework-CFNetwork-11.0.0/Library/Frameworks/CFNetwork.framework/Headers/CFNetworkD>
In file included from /nix/store/ybqjzlwc8iazf693ffkvifj23zlsqf8p-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/CoreFoundation.framework/Headers/>
In file included from /nix/store/ybqjzlwc8iazf693ffkvifj23zlsqf8p-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/CoreFoundation.framework/Headers/>
In file included from /nix/store/ybqjzlwc8iazf693ffkvifj23zlsqf8p-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/CoreFoundation.framework/Headers/>
/nix/store/ybqjzlwc8iazf693ffkvifj23zlsqf8p-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h:1189:83: error>
    kCFURLBookmarkCreationWithSecurityScope API_AVAILABLE(macos(10.7), macCatalyst(13.0))  API_UNAVAILABLE(ios, watchos, tvos) = ( 1UL << 11 ), // Mac OS X >
                                                                                  ^
/nix/store/ybqjzlwc8iazf693ffkvifj23zlsqf8p-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h:1190:98: error>
    kCFURLBookmarkCreationSecurityScopeAllowOnlyReadAccess API_AVAILABLE(macos(10.7), macCatalyst(13.0)) API_UNAVAILABLE(ios, watchos, tvos) = ( 1UL << 12 )>
                                                                                                 ^
/nix/store/ybqjzlwc8iazf693ffkvifj23zlsqf8p-apple-framework-CoreFoundation-11.0.0/Library/Frameworks/CoreFoundation.framework/Headers/CFURL.h:1200:85: error>
    kCFURLBookmarkResolutionWithSecurityScope API_AVAILABLE(macos(10.7), macCatalyst(13.0)) API_UNAVAILABLE(ios, watchos, tvos) = ( 1UL << 10 ), // Mac OS X>
                                                                                    ^
3 errors generated.

@@ -56,14 +57,16 @@ buildGoModule rec {
dontInstall = true;
dontFixup = true;
outputHashMode = "recursive";
outputHash = "sha256-QdyXSPshzugkDTJoUrJlHNuhPAyR9gae5Cbk8Q8FSl4=";
outputHash = if stdenv.isLinux then "sha256-3CZgs732c6Z64t2sfWjPAmMFKVTzoolv2TwrbjeRCBA=" else "sha256-NKEajOe9uDZw0MF5leiKBIRH1CHUELRho7gyCa96BO8=";
Copy link
Member

Choose a reason for hiding this comment

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

The if/else here is wrong because we don't just have Linux or Darwin (see lib.platforms) even though they're less well-known.

We should either do an if/else if for stdenv.isLinux/stdenv.isDarwin and throw on else if we're sure that for each Darwin and Linux the hash is the same (please check that then).
The other option would be to specify hashes explicitly per platform:

hash = {
  x86_64-linux = "hash1";
  aarch64-darwin = "hash2";
  aarch64-linux = "hash3";
}.${system} or throw "Unsupported system";

This has the downside that we'll duplicate hashes for Linuxes though.

In any case, please make sure that we don't allow any platform in meta.platforms that's excluded / unsupported here.

Copy link
Member Author

Choose a reason for hiding this comment

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

@shivaraj-bh
Copy link
Member Author

Turns out, using xcbuild.xcbuild instead of just xcbuild avoids the headers getting mixed up between different versions of apple_sdk, solving the problem with go-ieproxy above. I am not entirely sure what makes it work, as far as I see the only difference between the outputs of both is that most of the binaries in xcbuild are just symlinks to the outputs in xcbuild.xcbuild.

@ofborg ofborg bot requested a review from Ma27 March 22, 2024 11:01
@shivaraj-bh shivaraj-bh marked this pull request as ready for review March 22, 2024 11:37
Copy link
Contributor

@risicle risicle left a comment

Choose a reason for hiding this comment

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

nixpkgs-review happy, macos 12 x86_64 & nixos x86_64

@risicle
Copy link
Contributor

risicle commented Mar 23, 2024

Could you squash the commits? Or at least, if you think they really deserve to be separate commits, prefix each of the messages with grafana: ?

@wegank wegank added the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Mar 23, 2024
@risicle risicle mentioned this pull request Mar 25, 2024
13 tasks
* use xcbuild.xcbuild, which is dep for @esfx/equatable; fix 'aligned_alloc' error

* frontend's offlineCache: don't allow platforms other than the one's mentioned in `meta.platforms`
@shivaraj-bh
Copy link
Member Author

@risicle I have squashed the commits

@wegank wegank removed the 12.approvals: 1 This PR was reviewed and approved by one reputable person label Mar 26, 2024
Copy link
Member

@Ma27 Ma27 left a comment

Choose a reason for hiding this comment

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

I think meta.platforms should be restricted to x86_64-{darwin,linux}, aarch64-{darwin,linux}.

After that this is good to go, thanks!

@ofborg ofborg bot requested a review from Ma27 March 26, 2024 13:00
@wegank wegank added the 12.approvals: 2 This PR was reviewed and approved by two reputable people label Mar 26, 2024
@Ma27 Ma27 merged commit 9d41ef1 into NixOS:master Mar 26, 2024
23 of 24 checks passed
@shivaraj-bh shivaraj-bh deleted the fix/grafana-darwin branch March 26, 2024 18:29
shivaraj-bh added a commit to juspay/services-flake that referenced this pull request Mar 29, 2024
shivaraj-bh added a commit to juspay/services-flake that referenced this pull request Apr 4, 2024
fixed here: NixOS/nixpkgs#297968

Also, hydra-checks pass on all four platforms:

```sh
shivaraj in 🌐 nixos in ~
❯ nix run github:nix-community/hydra-check -- grafana --arch aarch64-darwin
Build Status for grafana.aarch64-darwin on jobset nixpkgs/trunk
✔ grafana-10.4.1 from 2024-03-27 - https://hydra.nixos.org/build/254421303

shivaraj in 🌐 nixos in ~ took 45s
❯ nix run github:nix-community/hydra-check -- grafana --arch x86_64-darwin
Build Status for grafana.x86_64-darwin on jobset nixpkgs/trunk
✔ grafana-10.4.1 from 2024-03-27 - https://hydra.nixos.org/build/254422747

shivaraj in 🌐 nixos in ~
❯ nix run github:nix-community/hydra-check -- grafana --arch x86_64-linux
Build Status for nixpkgs.grafana.x86_64-linux on jobset nixos/trunk-combined
✔ grafana-10.4.0 from 2024-03-27 - https://hydra.nixos.org/build/254385494

shivaraj in 🌐 nixos in ~
❯ nix run github:nix-community/hydra-check -- grafana --arch aarch64-linux
Build Status for nixpkgs.grafana.aarch64-linux on jobset nixos/trunk-combined
✔ grafana-10.4.0 from 2024-03-27 - https://hydra.nixos.org/build/254392946
```
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-darwin: 1 10.rebuild-linux: 1-10 10.rebuild-linux: 1 12.approvals: 2 This PR was reviewed and approved by two reputable people
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Build failure: grafana on aarch64-darwin
4 participants