summary refs log tree commit diff
path: root/pkgs/os-specific/darwin/apple-source-releases/libsecurity_generic/default.nix
blob: a94b9b455ef92f709e879c2676f6e1f0f86e0c6c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{ appleDerivation_, applePackage, pkgs, stdenv }:
name: version: sha256: args: let
  n = stdenv.lib.removePrefix "lib" name;
  makeFile = ../. + builtins.toPath "/${name}/GNUmakefile";
  appleDerivation = appleDerivation_ name version sha256;
  in applePackage name version sha256 (args // {
    appleDerivation = a:
    appleDerivation (stdenv.lib.mergeAttrsConcatenateValues {
      __impureHostDeps = import ./impure_deps.nix;

      patchPhase = ''
        # allows including <Security/some-private-header.h>
        ln -s ${pkgs.darwin.osx_private_sdk}/System/Library/Frameworks/Security.framework/Versions/A/PrivateHeaders Security

        grep -Rl MacErrors.h . | while read file; do
          substituteInPlace "''$file" --replace \
            '<CoreServices/../Frameworks/CarbonCore.framework/Headers/MacErrors.h>' \
            '"${pkgs.darwin.apple_sdk.sdk}/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/CarbonCore.framework/Versions/A/Headers/MacErrors.h"'
        done || true # grep returns 1 if it can't find the string
        
        grep -Rl MacTypes.h . | while read file; do
          substituteInPlace "''$file" --replace \
            '<CoreServices/../Frameworks/CarbonCore.framework/Headers/MacTypes.h>' \
            '"${pkgs.darwin.apple_sdk.sdk}/include/MacTypes.h"'
        done || true # grep returns 1 if it can't find the string
      '';
      preBuild = ''
        ln -s lib ${n}
        makeFlagsArray=(-j''$NIX_BUILD_CORES)
      '';
      buildInputs = [
        pkgs.gnustep-make
      ];
      makeFlags = [
        "-f${makeFile}"
        "MAKEFILE_NAME=${makeFile}"
        "GNUSTEP_ABSOLUTE_INSTALL_PATHS=yes"
        "LIB_LINK_INSTALL_DIR=\$(out)/lib"
      ];
      installFlags = [
        "${n}_INSTALL_DIR=\$(out)/lib"
        "${n}_HEADER_FILES_INSTALL_DIR=\$(out)/include/${n}"
        "GNUSTEP_HEADERS="
      ];
      NIX_CFLAGS_COMPILE = [
        "-isystem lib"
        "-iframework ${pkgs.darwin.Security}/Library/Frameworks"
        "-I."
        "-Wno-deprecated-declarations"
      ];
      NIX_LDFLAGS = with pkgs.darwin; with apple_sdk.frameworks; [
        "-L${libobjc}/lib"
        "-F${Foundation}/Library/Frameworks"
        "-F${AppKit}/Library/Frameworks"
        "-no_dtrace_dof"
      ];
    } a);
  })