From 6c0e44397ba766e2f5587dc030552adcaedad0b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ha=CC=88cker?= Date: Wed, 4 Dec 2024 10:38:57 +0100 Subject: [PATCH] Add documentation on how to enable compilation of binary dependencies. --- docs/common-patterns.md | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/docs/common-patterns.md b/docs/common-patterns.md index b01a55486..a35349301 100644 --- a/docs/common-patterns.md +++ b/docs/common-patterns.md @@ -141,3 +141,36 @@ in { ]; } ``` + +### Compile x86 dependencies on ARM Macs via Rosetta + +If you want to also compile dependencies for x86, you can add dependencies to `packages`: + +```nix +packages = with rosettaPkgs; [ + # these are the packages required for pymssql + freetds + krb5 + openssl +]; +``` + +And switch the compiler to x86: + +```nix +stdenv = rosettaPkgs.stdenv; +``` + +Then, in the generated shell, you can compile software for x86, like `pymssql` or `ibm_db`. However some creative DYLD_FALLBACK_LIBRARY_PATH may be required to make some dependency libraries available to the x86 binaries: + +```sh +export DYLD_FALLBACK_LIBRARY_PATH="${rosettaPkgs.lib.makeLibraryPath [ rosettaPkgs.gcc14.cc] }:$DYLD_FALLBACK_LIBRARY_PATH" +git clone git@github.com:pymssql/pymssql.git +${rosettaPkgs.python312Full}/bin/python3 -m venv venv +source venv/bin/activate +( + cd pymssql + pip install -e . +) +pip install ibm_db +```