Skip to content

Commit

Permalink
Support codesigning on MacOS
Browse files Browse the repository at this point in the history
Fixes #224
  • Loading branch information
avdv committed May 17, 2022
1 parent c73c903 commit b2ecf48
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions toolchains/cc/cc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,23 @@ in
}:

let
postLinkSignHook =
pkgs.writeTextFile {
name = "post-link-sign-hook";
executable = true;

text = ''
CODESIGN_ALLOCATE=${pkgs.darwin.cctools}/bin/codesign_allocate \
${pkgs.sigtool}/bin/codesign -f -s - "$linkerOutput"
'';
};
darwinBinutils = pkgs.darwin.binutils.override { inherit postLinkSignHook; };
darwinCC =
# Work around https://github.com/NixOS/nixpkgs/issues/42059.
# See also https://github.com/NixOS/nixpkgs/pull/41589.
pkgs.wrapCCWith rec {
cc = pkgs.stdenv.cc;
bintools = darwinBinutils;
extraBuildCommands = with pkgs.darwin.apple_sdk.frameworks; ''
echo "-Wno-unused-command-line-argument" >> $out/nix-support/cc-cflags
echo "-isystem ${pkgs.llvmPackages.libcxx}/include/c++/v1" >> $out/nix-support/cc-cflags
Expand All @@ -36,10 +47,7 @@ let
let
paths =
if pkgs.stdenv.isDarwin then
{
cc = (pkgs.overrideCC pkgs.stdenv darwinCC).cc;
binutils = pkgs.darwin.binutils;
}
pkgs.overrideCC pkgs.stdenv darwinCC
else
{
cc = pkgs.stdenv.cc;
Expand Down

0 comments on commit b2ecf48

Please sign in to comment.