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

x509-system: use /usr/bin/security on macOS. #974

Merged
merged 1 commit into from
Dec 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions overlays/darwin.nix
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
final: prev: {

}
final: prev:
{
haskell-nix = prev.haskell-nix // ({
defaultModules = prev.haskell-nix.defaultModules ++ [
({ pkgs, buildModules, config, lib, ... }:
{
packages = { } // pkgs.lib.optionalAttrs (pkgs.stdenv.hostPlatform.isDarwin && !pkgs.stdenv.cc.nativeLibc)
{
# Workaround for broken nixpkgs darwin.security_tool in
# Mojave. This mirrors the workaround in nixpkgs
# haskellPackages.
#
# ref:
# https://github.com/NixOS/nixpkgs/pull/47676
# https://github.com/NixOS/nixpkgs/issues/45042
x509-system.components.library.preBuild = "substituteInPlace System/X509/MacOS.hs --replace security /usr/bin/security";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Does this work if x509-system isn't in the package set?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm using this in a temporary fork to build all kinds of packages, including some non-Stack projects. (It's Stack that pulls in x509-system 100%.)

My expectation was that this expression wouldn't be evaluated unless the package set includes x509-system.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Cool. I actually just don't know what the module system will do with this. e.g. I could imagine it complaining that x509-system wasn't defined or something.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For me, the real question about this PR is whether the conditional that guards the override is correct. In nixpkgs, my understanding is that you just need to use stdenv.isDarwin and that does the right thing for native builds and cross. But I get the impression (having not tried it myself) that cross-compiles are more complicated in haskell.nix, so it would be good to have someone who knows that stuff take a look at this PR.

There is also the complication that in nixpkgs, the equivalent code checks for !pkgs.stdenv.cc.nativeLibc, which I have mimicked here, but I confess that I don't understand why that's necessary:

https://github.com/NixOS/nixpkgs/blob/50863eb06c8f2f3397fa4cf0129a62047fbb765c/pkgs/development/haskell-modules/configuration-nix.nix#L160

Copy link
Collaborator

Choose a reason for hiding this comment

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

We use stdenv.isDarwin all over the place, so I'm fairly confident that this is going to be okay. I have no idea about the nativeLibc thing, but I'm happy if we're copying it from nixpkgs.

I was about to ask if we should make a note to await the "proper fix" mentioned in the issue, and then I saw it was from 2018 😅

};
})
];
});
}
2 changes: 2 additions & 0 deletions overlays/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ let
bootstrap = import ./bootstrap.nix;
ghc = import ./ghc.nix;
ghc-packages = import ./ghc-packages.nix;
darwin = import ./darwin.nix;
windows = import ./windows.nix;
armv6l-linux = import ./armv6l-linux.nix;
musl = import ./musl.nix;
Expand Down Expand Up @@ -42,6 +43,7 @@ let
bootstrap
ghc
ghc-packages
darwin
windows
armv6l-linux
musl
Expand Down