Skip to content

Instantly share code, notes, and snippets.

@eriknylund
Last active February 1, 2022 01:48
Show Gist options
  • Save eriknylund/a58d7587f785881eee0aea10bba60546 to your computer and use it in GitHub Desktop.
Save eriknylund/a58d7587f785881eee0aea10bba60546 to your computer and use it in GitHub Desktop.
Bitcoin Core v22.0 reproducible build with Guix

Overview for creating Guix signatures

Setup

Bitcoin Core v22.0 Guix build on a Digital Ocean $160/mo VPS

  • Debian 9 x64 Memory-Optimized
  • 4 CPUs / 32 GB Memory / 100 GB Disk / FRA1
  • More than 50 GB disk space is required or you'll get a Performing a Bitcoin Core Guix build for the selected HOSTS requires 44 GiB, however, only 41 GiB is available. Please free up some disk space before performing the build.
  • Estimated cost to perform a build: ~$2

Install base packages required for consecutive steps

apt update && apt upgrade -y
apt update && apt install -y xz-utils git make curl screen

Setup user account

adduser erik sudo
mkdir -p /home/erik/.ssh
cp .ssh/authorized_keys /home/erik/.ssh
chown erik:erik /home/erik/.ssh/authorized_keys
su erik

Install guix

wget https://git.savannah.gnu.org/cgit/guix.git/plain/etc/guix-install.sh
chmod +x guix-install.sh
sudo ./guix-install.sh
guix install glibc-utf8-locales
export GUIX_LOCPATH="$HOME/.guix-profile/lib/locale"
# Apply fix for exception 
# guix environment: error: cannot create container: unprivileged user cannot create user namespaces
# guix environment: error: please set /proc/sys/kernel/unprivileged_userns_clone to "1"
sudo su -
echo 1 > /proc/sys/kernel/unprivileged_userns_clone
exit

Clone repos

git clone https://github.com/bitcoin-core/guix.sigs.git
git clone https://github.com/bitcoin-core/bitcoin-detached-sigs.git
git clone https://github.com/bitcoin/bitcoin.git

Set build variables and download macOS SDK

export VERSION=22.0
export GUIX_SIGS_REPO="$PWD/guix.sigs"
export DETACHED_SIGS_REPO="$PWD/bitcoin-detached-sigs"
export ADDITIONAL_GUIX_COMMON_FLAGS='--max-jobs=4'
export HOSTS='x86_64-apple-darwin18'

wget https://bitcoincore.org/depends-sources/sdks/Xcode-12.1-12A7403-extracted-SDK-with-libcxx-headers.tar.gz
mkdir SDKs
tar -C $PWD/SDKs -xaf Xcode-12.1-12A7403-extracted-SDK-with-libcxx-headers.tar.gz 
export SDK_PATH=$PWD/SDKs

Build!

# Run in screen so we can detach and come back in two hours 
# and don't have to worry about losing connectivity
screen
pushd bitcoin
git fetch 
git checkout "v${VERSION}"
# Expect the first time Guix setup to last for 1-2 hours to compile all dependencies 
# and then build the bitcoin binaries
./contrib/guix/guix-build
# Sign binary
./contrib/guix/guix-codesign

# Exit screen with CTRL + a + d
# Come back at any time and resume with screen -D -r

popd

Verify binaries

# Downloading binary to compare hash against
curl -O https://bitcoincore.org/bin/bitcoin-core-22.0/bitcoin-22.0-osx-signed.dmg

shasum -a 256 bitcoin-22.0-osx-signed.dmg bitcoin/guix-build-22.0/output/x86_64-apple-darwin18-codesigned/bitcoin-22.0-osx-signed.dmg

Video

https://youtu.be/329vghcGP9w
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment