summary refs log tree commit diff
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2021-04-13 20:54:01 +0200
committertoonn <toonn@toonn.io>2021-06-05 19:55:38 +0200
commit7da313e10a2b73b05f27a2f6bfeafa1c1d37ce8b (patch)
tree3100a72f315af1d53627e089ada9723f5afc4555
parent7e9e1b6351bb4acc71f88d3fc4defa3fa899e121 (diff)
downloadnixpkgs-7da313e10a2b73b05f27a2f6bfeafa1c1d37ce8b.tar
nixpkgs-7da313e10a2b73b05f27a2f6bfeafa1c1d37ce8b.tar.gz
nixpkgs-7da313e10a2b73b05f27a2f6bfeafa1c1d37ce8b.tar.bz2
nixpkgs-7da313e10a2b73b05f27a2f6bfeafa1c1d37ce8b.tar.lz
nixpkgs-7da313e10a2b73b05f27a2f6bfeafa1c1d37ce8b.tar.xz
nixpkgs-7da313e10a2b73b05f27a2f6bfeafa1c1d37ce8b.tar.zst
nixpkgs-7da313e10a2b73b05f27a2f6bfeafa1c1d37ce8b.zip
bootstrap-tools: Fix xnu python3 patch
This patch only affects the xnu included in the bootstrap-tools to avoid
a stdenv rebuild.
-rw-r--r--pkgs/stdenv/darwin/fixed-xnu-python3.patch41
-rw-r--r--pkgs/stdenv/darwin/make-bootstrap-tools.nix12
2 files changed, 50 insertions, 3 deletions
diff --git a/pkgs/stdenv/darwin/fixed-xnu-python3.patch b/pkgs/stdenv/darwin/fixed-xnu-python3.patch
new file mode 100644
index 00000000000..9f29376187f
--- /dev/null
+++ b/pkgs/stdenv/darwin/fixed-xnu-python3.patch
@@ -0,0 +1,41 @@
+diff --git a/bsd/kern/makekdebugevents.py b/bsd/kern/makekdebugevents.py
+index 73b2db4..d354ba0 100755
+--- a/bsd/kern/makekdebugevents.py
++++ b/bsd/kern/makekdebugevents.py
+@@ -5,7 +5,7 @@
+ # named kd_events[] or these mappings.
+ # Required to generate a header file used by DEVELOPMENT and DEBUG kernels.
+ #
+- 
++
+ import sys
+ import re
+ 
+@@ -21,18 +21,18 @@ code_table = []
+ # scan file to generate internal table
+ with open(trace_code_file, 'rt') as codes:
+     for line in codes:
+-	m = id_name_pattern.match(line)
+-	if m:
++        m = id_name_pattern.match(line)
++        if m:
+             code_table += [(int(m.group(1),base=16), m.group(2))]
+ 
+ # emit typedef:
+-print "typedef struct {"
+-print "        uint32_t   id;"
+-print "        const char *name;"
+-print "} kd_event_t;"
++print("typedef struct {")
++print("        uint32_t   id;")
++print("        const char *name;")
++print("} kd_event_t;")
+ # emit structure declaration and sorted initialization:
+-print "kd_event_t kd_events[] = {"
++print("kd_event_t kd_events[] = {")
+ for mapping in sorted(code_table, key=lambda x: x[0]):
+-        print "        {0x%x, \"%s\"}," % mapping
+-print "};"
++        print("        {0x%x, \"%s\"}," % mapping)
++print("};")
+ 
diff --git a/pkgs/stdenv/darwin/make-bootstrap-tools.nix b/pkgs/stdenv/darwin/make-bootstrap-tools.nix
index 3af444a2e52..e8a2dd640f0 100644
--- a/pkgs/stdenv/darwin/make-bootstrap-tools.nix
+++ b/pkgs/stdenv/darwin/make-bootstrap-tools.nix
@@ -26,6 +26,12 @@ in rec {
   # Avoid messing with libkrb5 and libnghttp2.
   curl_ = curlMinimal.override (args: { gssSupport = false; http2Support = false; });
 
+  # Avoid stdenv rebuild.
+  Libsystem_ = darwin.Libsystem.override (args:
+    { xnu = darwin.xnu.overrideAttrs (oldAttrs:
+      { patches = [ ./fixed-xnu-python3.patch ]; });
+    });
+
   build = stdenv.mkDerivation {
     name = "stdenv-bootstrap-tools";
 
@@ -37,12 +43,12 @@ in rec {
 
       ${lib.optionalString stdenv.targetPlatform.isx86_64 ''
         # Copy libSystem's .o files for various low-level boot stuff.
-        cp -d ${darwin.Libsystem}/lib/*.o $out/lib
+        cp -d ${Libsystem_}/lib/*.o $out/lib
 
         # Resolv is actually a link to another package, so let's copy it properly
-        cp -L ${darwin.Libsystem}/lib/libresolv.9.dylib $out/lib
+        cp -L ${Libsystem_}/lib/libresolv.9.dylib $out/lib
 
-        cp -rL ${darwin.Libsystem}/include $out
+        cp -rL ${Libsystem_}/include $out
         chmod -R u+w $out/include
         cp -rL ${darwin.ICU}/include*             $out/include
         cp -rL ${libiconv}/include/*       $out/include