@@ -90,6 +90,8 @@ let
9090
9191 targetIconv = targetPackages.libiconv or libiconv;
9292
93+ targetNumactl = targetPackages.numactl or numactl;
94+
9395 # TODO(@Ericson2314) Make unconditional
9496 targetPrefix = lib.optionalString
9597 (targetPlatform != hostPlatform)
@@ -259,7 +261,18 @@ stdenv.mkDerivation (rec {
259261 ++ lib.optional stdenv.targetPlatform.isAarch32 "pic"
260262 ++ lib.optional stdenv.targetPlatform.isMusl "pie";
261263
262− postInstall = ''
264+ postInstall = lib.optionalString (enableNUMA && targetPlatform.isLinux) ''
265+ # Patch rts.conf to ensure libnuma can be found
266+
267+ for file in $(find "$out/lib" -name "rts*.conf"); do
268+ if grep -q numa $file; then
269+ substituteInPlace $file \
270+ --replace "library-dirs:" "library-dirs: ${targetNumactl}/lib" \
271+ --replace "include-dirs:" "include-dirs: ${targetNumactl}/include"
272+ "$out/bin/${targetPrefix}ghc-pkg" recache
273+ fi
274+ done
275+ '' + ''
263276 # Install the bash completion file.
264277 install -D -m 444 utils/completion/ghc.bash $out/share/bash-completion/completions/${targetPrefix}ghc
265278