index

Guide for Guix Builds on NixOS

These are adapted and updated steps from bitcoin-resource.

One-time steps

This blog may be out of date and is subject to change

Installations

Add the following to environment.systemPackages:

  guix
  xar
  pbzx
  cpio
  rcodesign

You will also need python if it is not present on the system already.

Then, add the daemon as a system service:

services.guix.enable = true;

Now you may rebuild your system:

sudo nixos-rebuild switch

While not required, using a separate git tree for Guix builds can keep your working directory available and organized for usual development. Here is the recommended directory structure:

guix-builds/
├─ bitcoin/
├─ Xcode_*/
run_build.sh

Apple Developer Account

Unfortunately, to use the Xcode SDK, Apple expects you to register a developer account. It is not required to pay for the full license to download the SDK.

Per-release steps

The Xcode SDK may, and likely will, change per release. For each version of the Xcode SDK, create an Xcode folder in the guix-builds directory, for example Xcode_26.1.1. The universal platform SDK is downloadable as an xip, which may be found by searching here after signing in.

If required, copy the downloaded xip to your server:

rsync -azP ~/Downloads/Xcode_26.1.1_Universal.xip user@server:/home/user/guix-builds/Xcode_26.1.1/

Afterwards, extract the xip:

# inside `guix-builds/Xcode_26.1.1`
xar -xf Xcode_26.1.1_Universal.xip

pbzx -n Content | cpio -i
rm Content Metadata

rcodesign verify Xcode.app/Contents/MacOS/Xcode

You should see no problems detected!. Optionally, you may clean up the xip folder. Next, we will unpack the SDK, move into the bitcoin directory and run:

# inside `guix-builds/bitcoin`
python ./contrib/macdeploy/gen-sdk.py ../guix-builds/Xcode_26.1.1/Xcode.app

The output will be .tar archive. You can attest to it by taking the sha256sum hash and comparing it to the one found here:

sha256sum Xcode-26.1.1-17B100-extracted-SDK-with-libcxx-headers.tar

Assuming the hashes match, move that tar archive to the Xcode_26.1.1 folder:

mv Xcode-26.1.1-17B100-extracted-SDK-with-libcxx-headers.tar ../Xcode_26.1.1/

Almost ready to do the first guix build! Lastly, we need to extract the tarball in the Xcode_26.1.1 folder:

tar -C ./ -xaf Xcode-26.1.1-17B100-extracted-SDK-with-libcxx-headers.tar

Build Steps

I use the following script for my builds, which requires a lot of CPU and memory. To reduce the system usage, you may remove the ADDITION_GUIX_COMMON_FLAGS:

# in guix-builds
unset SOURCE_DATE_EPOCH
export SDK_PATH=$1
export ADDITIONAL_GUIX_COMMON_FLAGS='--max-jobs=8'
cd bitcoin
./contrib/guix/guix-build

An example run, with the SDK we just unpacked:

./run-build.sh /home/you/guix-builds/Xcode_26.1.1

This will take a while, so it is recommended to run in a detached tmux or zellij session.

Cleaning up

You may gather the shasums of the builds by running:

# in guix-builds/bitcoin
source contrib/shell/git-utils.bash && uname -m && find guix-build-$(git_head_version)/output/ -type f -print0 | env LC_ALL=C sort -z | xargs -r0 sha256sum

If you would like to remove the build artifacts:

# in guix-builds/bitcoin
./contrib/guix/guix-clean