summary refs log tree commit diff
path: root/pkgs/os-specific/bsd/netbsd/default.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-11-03 16:50:59 +0000
committerAlyssa Ross <hi@alyssa.is>2022-01-06 14:20:18 +0000
commit7be5fbf70fdc995034b2658bd814cfa45dfddc9a (patch)
treec4072adf5a594abf14a0c6e09600561eeb82b80d /pkgs/os-specific/bsd/netbsd/default.nix
parentc253b04a2f3435f9535a9c024e5ace6912ffb990 (diff)
downloadnixpkgs-7be5fbf70fdc995034b2658bd814cfa45dfddc9a.tar
nixpkgs-7be5fbf70fdc995034b2658bd814cfa45dfddc9a.tar.gz
nixpkgs-7be5fbf70fdc995034b2658bd814cfa45dfddc9a.tar.bz2
nixpkgs-7be5fbf70fdc995034b2658bd814cfa45dfddc9a.tar.lz
nixpkgs-7be5fbf70fdc995034b2658bd814cfa45dfddc9a.tar.xz
nixpkgs-7be5fbf70fdc995034b2658bd814cfa45dfddc9a.tar.zst
nixpkgs-7be5fbf70fdc995034b2658bd814cfa45dfddc9a.zip
pkgsStatic.netbsd: fix nbtool_config.h conflicts
In pkgsStatic, /all/ build inputs are propagated.  This means that
netbsd.compat was propagated, along with its setup hook, which broke
static glib builds because glib defines a function with the same name
as one in nbtool_config.h, and nbtool_config.h was being automatically
included in every C file processed by the compiler, in any transitive
dependent of netbsd.compat's setup hook.

To fix this, rather than forcing nbtool_config.h to be included for
_every_ C file in a derivation that depends on netbsd.compat, modify
the NetBSD-specific mkDerivation to detect files that need the header,
and patch it in there where appropriate.  That way, only files that
are part of NetBSD will be affected, not all transitive dependents.
Diffstat (limited to 'pkgs/os-specific/bsd/netbsd/default.nix')
-rw-r--r--pkgs/os-specific/bsd/netbsd/default.nix12
1 files changed, 11 insertions, 1 deletions
diff --git a/pkgs/os-specific/bsd/netbsd/default.nix b/pkgs/os-specific/bsd/netbsd/default.nix
index beaa176dae1..7a6604afe64 100644
--- a/pkgs/os-specific/bsd/netbsd/default.nix
+++ b/pkgs/os-specific/bsd/netbsd/default.nix
@@ -120,7 +120,17 @@ in lib.makeScopeWithSplicing
   } // lib.optionalAttrs (attrs.headersOnly or false) {
     installPhase = "includesPhase";
     dontBuild = true;
-  } // attrs));
+  } // attrs // {
+    postPatch = lib.optionalString (!stdenv'.hostPlatform.isNetBSD) ''
+      # Files that use NetBSD-specific macros need to have nbtool_config.h
+      # included ahead of them on non-NetBSD platforms.
+      set +e
+      grep -Zlr "^__RCSID
+      ^__BEGIN_DECLS" | xargs -0r grep -FLZ nbtool_config.h |
+          xargs -0tr sed -i '0,/^#/s//#include <nbtool_config.h>\n\0/'
+      set -e
+    '' + attrs.postPatch or "";
+  }));
 
   ##
   ## START BOOTSTRAPPING