dash/contrib/guix
fanquake e4a6ea6032 Merge bitcoin/bitcoin#25861: guix: use --build={arch}-guix-linux-gnu in cross toolchain
56e79fe683d36c1944e52326fae3bcc4cb7deec7 guix: use --build={arch}-guix-linux-gnu in cross toolchain (fanquake)

Pull request description:

  Technically we are always cross-compiling when Guix building, so make that explicit. `{arch}-guix-linux-gnu` is not a triplet that should be used in any other capacity, but here it serves the purpose of ensuring, that by setting `--build` to something other than `--host/--target`, we are always cross-compiling (in the eyes of autoconf etc) when building our cross toolchains. It looks like `x86_64-linux-gnu` on `x86_64-linux-gnu` currently works because of the triplet canonicalisation, i.e `x86_64-linux-gnu` becomes `x86_64-pc-linux-gnu`, and GCCs configure thinking it's cross-compiling, whereas the same canonicalisation doesn't happen for `aarch64-linux-gnu` so we don't get a cross-compile when building on aarch64.

  Fixes: #22458.

  Guix Build (x86_64):
  ```bash
  e590e67d2b151e7d079f50393c61cacf9e65f5e3fdddc10bffd5dbb59cd9f5e3  guix-build-56e79fe683d3/output/aarch64-linux-gnu/SHA256SUMS.part
  9222a733209dc73168722ee0f290831d1723f7ed55abc1e243dd3892ef9733f1  guix-build-56e79fe683d3/output/aarch64-linux-gnu/bitcoin-56e79fe683d3-aarch64-linux-gnu-debug.tar.gz
  a4ec01411195412e9a483397554d98b2db161a6be8aceee2dac78f0015f2a8e5  guix-build-56e79fe683d3/output/aarch64-linux-gnu/bitcoin-56e79fe683d3-aarch64-linux-gnu.tar.gz
  a4ff8f2538c1b3a63a3e7c92699c18164b2c4954ebd72c4a854bf7844e6131b6  guix-build-56e79fe683d3/output/arm-linux-gnueabihf/SHA256SUMS.part
  ac6e4dffcf6f49dac73d3677f3fe5edb08ee1127648bc7ec24b217f48a3a4d21  guix-build-56e79fe683d3/output/arm-linux-gnueabihf/bitcoin-56e79fe683d3-arm-linux-gnueabihf-debug.tar.gz
  ab26467fce9732596b1713179618eee20c2bd44875dc1c39f9afd68f135e8ce4  guix-build-56e79fe683d3/output/arm-linux-gnueabihf/bitcoin-56e79fe683d3-arm-linux-gnueabihf.tar.gz
  f44108d818d53ee7e70b44361cb3cc6841b7aecbe4fade1fa289263718620824  guix-build-56e79fe683d3/output/arm64-apple-darwin/SHA256SUMS.part
  29adfb2d575be8b5a7092b2aff888af2084ad5783bdc74ae3de4b2dd84da7a26  guix-build-56e79fe683d3/output/arm64-apple-darwin/bitcoin-56e79fe683d3-arm64-apple-darwin-unsigned.dmg
  3d7640f604bd27cb1ae47853d70378a7631aa436b5c027eae31fa06d4dd20d4a  guix-build-56e79fe683d3/output/arm64-apple-darwin/bitcoin-56e79fe683d3-arm64-apple-darwin-unsigned.tar.gz
  3f8d8fc49cf722a7a13640872762d045c14efd610fba908f0acc99a99032b903  guix-build-56e79fe683d3/output/arm64-apple-darwin/bitcoin-56e79fe683d3-arm64-apple-darwin.tar.gz
  b8df097e10e7acded8556a5681da2b0132c0d509b200792f5584c186b8dcaf24  guix-build-56e79fe683d3/output/dist-archive/bitcoin-56e79fe683d3.tar.gz
  1a605c563038107b88e8d859fa045ca3087241340264eb7125e97b3af36874db  guix-build-56e79fe683d3/output/powerpc64-linux-gnu/SHA256SUMS.part
  d10be89a816ee2f47bf778ef4aaa8a7b548403c123a4b4b3aa0470ee7b9472d2  guix-build-56e79fe683d3/output/powerpc64-linux-gnu/bitcoin-56e79fe683d3-powerpc64-linux-gnu-debug.tar.gz
  839dd079d677c87a91ccc28f6c423657d98212350d3693ae2facb92082d10c88  guix-build-56e79fe683d3/output/powerpc64-linux-gnu/bitcoin-56e79fe683d3-powerpc64-linux-gnu.tar.gz
  200d7a72a7901b6788e70aa1c6fbbe16144e9dac29beb06242a9dcfe1e88acbe  guix-build-56e79fe683d3/output/powerpc64le-linux-gnu/SHA256SUMS.part
  3d207bb57dc45f234d804a9ee615001aa28ac4b59b530a1e7d16d0a72c2ea514  guix-build-56e79fe683d3/output/powerpc64le-linux-gnu/bitcoin-56e79fe683d3-powerpc64le-linux-gnu-debug.tar.gz
  16a789c98409d36bd6b69a5ca38cd8886979f50f845265dc0b005c92286a3e4f  guix-build-56e79fe683d3/output/powerpc64le-linux-gnu/bitcoin-56e79fe683d3-powerpc64le-linux-gnu.tar.gz
  e48f6fae9c2ffeb2bf02ffc073ac69648b2ce4ba87e0ad7a3a5059abf33b8ce2  guix-build-56e79fe683d3/output/riscv64-linux-gnu/SHA256SUMS.part
  fa8d66af5f202e0c8968114af4dcd6d88099eb91d197dfaaa0144f8ae6b12f4a  guix-build-56e79fe683d3/output/riscv64-linux-gnu/bitcoin-56e79fe683d3-riscv64-linux-gnu-debug.tar.gz
  86cffa62687f4272c899897ff6c1a86e1a7bdbbb7ab09a085b7b1122d3a1f1b2  guix-build-56e79fe683d3/output/riscv64-linux-gnu/bitcoin-56e79fe683d3-riscv64-linux-gnu.tar.gz
  e42a7c33da6ea4be5d0826df097bdc7e919c9fd6642e7d59fe3d45a97d9009fa  guix-build-56e79fe683d3/output/x86_64-apple-darwin/SHA256SUMS.part
  2f9faa88fa0025b9bfade83177b1f50833dc6c3be1ef26c4d5881aa165bcc537  guix-build-56e79fe683d3/output/x86_64-apple-darwin/bitcoin-56e79fe683d3-x86_64-apple-darwin-unsigned.dmg
  fdfe560968c85500dc886d4e12b851cd27a76de860b8cbf1fb6aac95ccd0582e  guix-build-56e79fe683d3/output/x86_64-apple-darwin/bitcoin-56e79fe683d3-x86_64-apple-darwin-unsigned.tar.gz
  c3c75560befd72a9f13f5626ddf39c63ad25fb9753a4d941e48830b7e06f143e  guix-build-56e79fe683d3/output/x86_64-apple-darwin/bitcoin-56e79fe683d3-x86_64-apple-darwin.tar.gz
  38100946ec1469fdd31aa8ea9e471b317dc278c298c106289c119016c2c0caa0  guix-build-56e79fe683d3/output/x86_64-linux-gnu/SHA256SUMS.part
  67890771aad89dc0d20b8dcdc6b29bd838ace310e8bcbbc0d16d7afc87d3a474  guix-build-56e79fe683d3/output/x86_64-linux-gnu/bitcoin-56e79fe683d3-x86_64-linux-gnu-debug.tar.gz
  a9772b40c8b9d3c1a0bf9c9db2a60050415bf6a9bd4a19cfd8a038f4a1e712e3  guix-build-56e79fe683d3/output/x86_64-linux-gnu/bitcoin-56e79fe683d3-x86_64-linux-gnu.tar.gz
  01da0561f2c3a268c28615b1573dfdecb6346bf3f8eba7a052488191234ac1d6  guix-build-56e79fe683d3/output/x86_64-w64-mingw32/SHA256SUMS.part
  71324ac0f6fc8163e41031b2fd2d38d2e15bfd5ef4efe4cb45d7974fad474394  guix-build-56e79fe683d3/output/x86_64-w64-mingw32/bitcoin-56e79fe683d3-win64-debug.zip
  219b58281d3c79b2ed7e9085b1e15d7e021fd3899ef07a6ad747058b43d64443  guix-build-56e79fe683d3/output/x86_64-w64-mingw32/bitcoin-56e79fe683d3-win64-setup-unsigned.exe
  fe838d32587c2f942fcd9f9a0b3735611b686a867e2d2040cf3a8aa6a43d09fe  guix-build-56e79fe683d3/output/x86_64-w64-mingw32/bitcoin-56e79fe683d3-win64-unsigned.tar.gz
  13b537217a13293b93afd7c588b3733955c3188f79a3249b363fb4e885b74b32  guix-build-56e79fe683d3/output/x86_64-w64-mingw32/bitcoin-56e79fe683d3-win64.zip
  ```

  Guix Build (arm64):
  ```bash
  e590e67d2b151e7d079f50393c61cacf9e65f5e3fdddc10bffd5dbb59cd9f5e3  guix-build-56e79fe683d3/output/aarch64-linux-gnu/SHA256SUMS.part
  9222a733209dc73168722ee0f290831d1723f7ed55abc1e243dd3892ef9733f1  guix-build-56e79fe683d3/output/aarch64-linux-gnu/bitcoin-56e79fe683d3-aarch64-linux-gnu-debug.tar.gz
  a4ec01411195412e9a483397554d98b2db161a6be8aceee2dac78f0015f2a8e5  guix-build-56e79fe683d3/output/aarch64-linux-gnu/bitcoin-56e79fe683d3-aarch64-linux-gnu.tar.gz
  a4ff8f2538c1b3a63a3e7c92699c18164b2c4954ebd72c4a854bf7844e6131b6  guix-build-56e79fe683d3/output/arm-linux-gnueabihf/SHA256SUMS.part
  ac6e4dffcf6f49dac73d3677f3fe5edb08ee1127648bc7ec24b217f48a3a4d21  guix-build-56e79fe683d3/output/arm-linux-gnueabihf/bitcoin-56e79fe683d3-arm-linux-gnueabihf-debug.tar.gz
  ab26467fce9732596b1713179618eee20c2bd44875dc1c39f9afd68f135e8ce4  guix-build-56e79fe683d3/output/arm-linux-gnueabihf/bitcoin-56e79fe683d3-arm-linux-gnueabihf.tar.gz
  f44108d818d53ee7e70b44361cb3cc6841b7aecbe4fade1fa289263718620824  guix-build-56e79fe683d3/output/arm64-apple-darwin/SHA256SUMS.part
  29adfb2d575be8b5a7092b2aff888af2084ad5783bdc74ae3de4b2dd84da7a26  guix-build-56e79fe683d3/output/arm64-apple-darwin/bitcoin-56e79fe683d3-arm64-apple-darwin-unsigned.dmg
  3d7640f604bd27cb1ae47853d70378a7631aa436b5c027eae31fa06d4dd20d4a  guix-build-56e79fe683d3/output/arm64-apple-darwin/bitcoin-56e79fe683d3-arm64-apple-darwin-unsigned.tar.gz
  3f8d8fc49cf722a7a13640872762d045c14efd610fba908f0acc99a99032b903  guix-build-56e79fe683d3/output/arm64-apple-darwin/bitcoin-56e79fe683d3-arm64-apple-darwin.tar.gz
  b8df097e10e7acded8556a5681da2b0132c0d509b200792f5584c186b8dcaf24  guix-build-56e79fe683d3/output/dist-archive/bitcoin-56e79fe683d3.tar.gz
  1a605c563038107b88e8d859fa045ca3087241340264eb7125e97b3af36874db  guix-build-56e79fe683d3/output/powerpc64-linux-gnu/SHA256SUMS.part
  d10be89a816ee2f47bf778ef4aaa8a7b548403c123a4b4b3aa0470ee7b9472d2  guix-build-56e79fe683d3/output/powerpc64-linux-gnu/bitcoin-56e79fe683d3-powerpc64-linux-gnu-debug.tar.gz
  839dd079d677c87a91ccc28f6c423657d98212350d3693ae2facb92082d10c88  guix-build-56e79fe683d3/output/powerpc64-linux-gnu/bitcoin-56e79fe683d3-powerpc64-linux-gnu.tar.gz
  200d7a72a7901b6788e70aa1c6fbbe16144e9dac29beb06242a9dcfe1e88acbe  guix-build-56e79fe683d3/output/powerpc64le-linux-gnu/SHA256SUMS.part
  3d207bb57dc45f234d804a9ee615001aa28ac4b59b530a1e7d16d0a72c2ea514  guix-build-56e79fe683d3/output/powerpc64le-linux-gnu/bitcoin-56e79fe683d3-powerpc64le-linux-gnu-debug.tar.gz
  16a789c98409d36bd6b69a5ca38cd8886979f50f845265dc0b005c92286a3e4f  guix-build-56e79fe683d3/output/powerpc64le-linux-gnu/bitcoin-56e79fe683d3-powerpc64le-linux-gnu.tar.gz
  e48f6fae9c2ffeb2bf02ffc073ac69648b2ce4ba87e0ad7a3a5059abf33b8ce2  guix-build-56e79fe683d3/output/riscv64-linux-gnu/SHA256SUMS.part
  fa8d66af5f202e0c8968114af4dcd6d88099eb91d197dfaaa0144f8ae6b12f4a  guix-build-56e79fe683d3/output/riscv64-linux-gnu/bitcoin-56e79fe683d3-riscv64-linux-gnu-debug.tar.gz
  86cffa62687f4272c899897ff6c1a86e1a7bdbbb7ab09a085b7b1122d3a1f1b2  guix-build-56e79fe683d3/output/riscv64-linux-gnu/bitcoin-56e79fe683d3-riscv64-linux-gnu.tar.gz
  e42a7c33da6ea4be5d0826df097bdc7e919c9fd6642e7d59fe3d45a97d9009fa  guix-build-56e79fe683d3/output/x86_64-apple-darwin/SHA256SUMS.part
  2f9faa88fa0025b9bfade83177b1f50833dc6c3be1ef26c4d5881aa165bcc537  guix-build-56e79fe683d3/output/x86_64-apple-darwin/bitcoin-56e79fe683d3-x86_64-apple-darwin-unsigned.dmg
  fdfe560968c85500dc886d4e12b851cd27a76de860b8cbf1fb6aac95ccd0582e  guix-build-56e79fe683d3/output/x86_64-apple-darwin/bitcoin-56e79fe683d3-x86_64-apple-darwin-unsigned.tar.gz
  c3c75560befd72a9f13f5626ddf39c63ad25fb9753a4d941e48830b7e06f143e  guix-build-56e79fe683d3/output/x86_64-apple-darwin/bitcoin-56e79fe683d3-x86_64-apple-darwin.tar.gz
  38100946ec1469fdd31aa8ea9e471b317dc278c298c106289c119016c2c0caa0  guix-build-56e79fe683d3/output/x86_64-linux-gnu/SHA256SUMS.part
  67890771aad89dc0d20b8dcdc6b29bd838ace310e8bcbbc0d16d7afc87d3a474  guix-build-56e79fe683d3/output/x86_64-linux-gnu/bitcoin-56e79fe683d3-x86_64-linux-gnu-debug.tar.gz
  a9772b40c8b9d3c1a0bf9c9db2a60050415bf6a9bd4a19cfd8a038f4a1e712e3  guix-build-56e79fe683d3/output/x86_64-linux-gnu/bitcoin-56e79fe683d3-x86_64-linux-gnu.tar.gz
  01da0561f2c3a268c28615b1573dfdecb6346bf3f8eba7a052488191234ac1d6  guix-build-56e79fe683d3/output/x86_64-w64-mingw32/SHA256SUMS.part
  71324ac0f6fc8163e41031b2fd2d38d2e15bfd5ef4efe4cb45d7974fad474394  guix-build-56e79fe683d3/output/x86_64-w64-mingw32/bitcoin-56e79fe683d3-win64-debug.zip
  219b58281d3c79b2ed7e9085b1e15d7e021fd3899ef07a6ad747058b43d64443  guix-build-56e79fe683d3/output/x86_64-w64-mingw32/bitcoin-56e79fe683d3-win64-setup-unsigned.exe
  fe838d32587c2f942fcd9f9a0b3735611b686a867e2d2040cf3a8aa6a43d09fe  guix-build-56e79fe683d3/output/x86_64-w64-mingw32/bitcoin-56e79fe683d3-win64-unsigned.tar.gz
  13b537217a13293b93afd7c588b3733955c3188f79a3249b363fb4e885b74b32  guix-build-56e79fe683d3/output/x86_64-w64-mingw32/bitcoin-56e79fe683d3-win64.zip
  ```

ACKs for top commit:
  hebasto:
    ACK 56e79fe683d36c1944e52326fae3bcc4cb7deec7

Tree-SHA512: 628ab6cda80069ad277107639bef21b44a8417198862e9ec89b45a2c41741d29aeb79aa58c5a90283fb96cf707494ae948ac790abde809bb18c86b14af999200
2023-04-16 12:07:09 -05:00
..
libexec docs: dashification of guix 2023-04-15 12:13:27 -05:00
patches docs: dashification of guix 2023-04-15 12:13:27 -05:00
Dockerfile docs: dashification guix/INSTALL.md and added Dockerfile for guix 2023-04-15 12:13:27 -05:00
guix-attest Merge bitcoin/bitcoin#22654: guix: Don't include directory name in SHA256SUMS 2023-04-15 12:13:27 -05:00
guix-build Merge bitcoin/bitcoin#22511: guix: Silence getent(1) invocation, doc fixups 2023-04-15 12:13:27 -05:00
guix-clean docs: dashification of guix 2023-04-15 12:13:27 -05:00
guix-codesign docs: dashification of guix 2023-04-15 12:13:27 -05:00
guix-verify docs: dashification of guix 2023-04-15 12:13:27 -05:00
INSTALL.md Merge bitcoin/bitcoin#22511: guix: Silence getent(1) invocation, doc fixups 2023-04-15 12:13:27 -05:00
manifest.scm Merge bitcoin/bitcoin#25861: guix: use --build={arch}-guix-linux-gnu in cross toolchain 2023-04-16 12:07:09 -05:00
README.md fix: extra edits of guix's README.md 2023-04-15 12:13:27 -05:00

Bootstrappable Dash Core Builds

This directory contains the files necessary to perform bootstrappable Dash Core builds.

Bootstrappability furthers our binary security guarantees by allowing us to audit and reproduce our toolchain instead of blindly trusting binary downloads.

We achieve bootstrappability by using Guix as a functional package manager.

Requirements

Conservatively, a x86_64 machine with:

  • 16GB of free disk space on the partition that /gnu/store will reside in
  • 8GB of free disk space per platform triple you're planning on building (see the HOSTS environment variable description)

Installation and Setup

If you don't have Guix installed and set up, please follow the instructions in INSTALL.md

Usage

If you haven't considered your security model yet, please read the relevant section before proceeding to perform a build.

Making the Xcode SDK available for macOS cross-compilation

In order to perform a build for macOS (which is included in the default set of platform triples to build), you'll need to extract the macOS SDK tarball using tools found in the macdeploy directory.

You can then either point to the SDK using the SDK_PATH environment variable:

# Extract the SDK tarball to /path/to/parent/dir/of/extracted/SDK/Xcode-<foo>-<bar>-extracted-SDK-with-libcxx-headers
tar -C /path/to/parent/dir/of/extracted/SDK -xaf /path/to/Xcode-<foo>-<bar>-extracted-SDK-with-libcxx-headers.tar.gz

# Indicate where to locate the SDK tarball
export SDK_PATH=/path/to/parent/dir/of/extracted/SDK

or extract it into depends/SDKs:

mkdir -p depends/SDKs
tar -C depends/SDKs -xaf /path/to/SDK/tarball

Building

The author highly recommends at least reading over the common usage patterns and examples section below before starting a build. For a full list of customization options, see the recognized environment variables section.

To build Dash Core reproducibly with all default options, invoke the following from the top of a clean repository:

./contrib/guix/guix-build

Codesigning build outputs

The guix-codesign command attaches codesignatures (produced by codesigners) to existing non-codesigned outputs. Please see the release process documentation for more context.

It respects many of the same environment variable flags as guix-build, with 2 crucial differences:

  1. Since only Windows and macOS build outputs require codesigning, the HOSTS environment variable will have a sane default value of x86_64-w64-mingw32 x86_64-apple-darwin18 instead of all the platforms.
  2. The guix-codesign command requires a DETACHED_SIGS_REPO flag.
    • DETACHED_SIGS_REPO

      Set the directory where detached codesignatures can be found for the current Dash Core version being built.

      REQUIRED environment variable

An invocation with all default options would look like:

env DETACHED_SIGS_REPO=<path/to/dash-detached-sigs> ./contrib/guix/guix-codesign

Cleaning intermediate work directories

By default, guix-build leaves all intermediate files or "work directories" (e.g. depends/work, guix-build-*/distsrc-*) intact at the end of a build so that they are available to the user (to aid in debugging, etc.). However, these directories usually take up a large amount of disk space. Therefore, a guix-clean convenience script is provided which cleans the current git worktree to save disk space:

./contrib/guix/guix-clean

Attesting to build outputs

Much like how Gitian build outputs are attested to in a gitian.sigs repository, Guix build outputs are attested to in the guix.sigs repository.

After you've cloned the guix.sigs repository, to attest to the current worktree's commit/tag:

env GUIX_SIGS_REPO=<path/to/guix.sigs> SIGNER=<gpg-key-name> ./contrib/guix/guix-attest

See ./contrib/guix/guix-attest --help for more information on the various ways guix-attest can be invoked.

Verifying build output attestations

After at least one other signer has uploaded their signatures to the guix.sigs repository:

git -C <path/to/guix.sigs> pull
env GUIX_SIGS_REPO=<path/to/guix.sigs> ./contrib/guix/guix-verify

Common guix-build invocation patterns and examples

Keeping caches and SDKs outside of the worktree

If you perform a lot of builds and have a bunch of worktrees, you may find it more efficient to keep the depends tree's download cache, build cache, and SDKs outside of the worktrees to avoid duplicate downloads and unnecessary builds. To help with this situation, the guix-build script honours the SOURCES_PATH, BASE_CACHE, and SDK_PATH environment variables and will pass them on to the depends tree so that you can do something like:

env SOURCES_PATH="$HOME/depends-SOURCES_PATH" BASE_CACHE="$HOME/depends-BASE_CACHE" SDK_PATH="$HOME/macOS-SDKs" ./contrib/guix/guix-build

Note that the paths that these environment variables point to must be directories, and NOT symlinks to directories.

See the recognized environment variables section for more details.

Building a subset of platform triples

Sometimes you only want to build a subset of the supported platform triples, in which case you can override the default list by setting the space-separated HOSTS environment variable:

env HOSTS='x86_64-w64-mingw32 x86_64-apple-darwin18' ./contrib/guix/guix-build

See the recognized environment variables section for more details.

Controlling the number of threads used by guix build commands

Depending on your system's RAM capacity, you may want to decrease the number of threads used to decrease RAM usage or vice versa.

By default, the scripts under ./contrib/guix will invoke all guix build commands with --cores="$JOBS". Note that $JOBS defaults to $(nproc) if not specified. However, astute manual readers will also notice that guix build commands also accept a --max-jobs= flag (which defaults to 1 if unspecified).

Here is the difference between --cores= and --max-jobs=:

Note: When I say "derivation," think "package"

--cores=

  • controls the number of CPU cores to build each derivation. This is the value passed to make's --jobs= flag.

--max-jobs=

  • controls how many derivations can be built in parallel
  • defaults to 1

Therefore, the default is for guix build commands to build one derivation at a time, utilizing $JOBS threads.

Specifying the $JOBS environment variable will only modify --cores=, but you can also modify the value for --max-jobs= by specifying $ADDITIONAL_GUIX_COMMON_FLAGS. For example, if you have a LOT of memory, you may want to set:

export ADDITIONAL_GUIX_COMMON_FLAGS='--max-jobs=8'

Which allows for a maximum of 8 derivations to be built at the same time, each utilizing $JOBS threads.

Or, if you'd like to avoid spurious build failures caused by issues with parallelism within a single package, but would still like to build multiple packages when the dependency graph allows for it, you may want to try:

export JOBS=1 ADDITIONAL_GUIX_COMMON_FLAGS='--max-jobs=8'

See the recognized environment variables section for more details.

Recognized environment variables

  • HOSTS

    Override the space-separated list of platform triples for which to perform a bootstrappable build.

    (defaults to "x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu powerpc64-linux-gnu powerpc64le-linux-gnu x86_64-w64-mingw32 x86_64-apple-darwin18")

  • SOURCES_PATH

    Set the depends tree download cache for sources. This is passed through to the depends tree. Setting this to the same directory across multiple builds of the depends tree can eliminate unnecessary redownloading of package sources.

    The path that this environment variable points to must be a directory, and NOT a symlink to a directory.

  • BASE_CACHE

    Set the depends tree cache for built packages. This is passed through to the depends tree. Setting this to the same directory across multiple builds of the depends tree can eliminate unnecessary building of packages.

    The path that this environment variable points to must be a directory, and NOT a symlink to a directory.

  • SDK_PATH

    Set the path where extracted SDKs can be found. This is passed through to the depends tree. Note that this is should be set to the parent directory of the actual SDK (e.g. SDK_PATH=$HOME/Downloads/macOS-SDKs instead of $HOME/Downloads/macOS-SDKs/Xcode-12.1-12A7403-extracted-SDK-with-libcxx-headers).

    The path that this environment variable points to must be a directory, and NOT a symlink to a directory.

  • JOBS

    Override the number of jobs to run simultaneously, you might want to do so on a memory-limited machine. This may be passed to:

    • guix build commands as in guix environment --cores="$JOBS"
    • make as in make --jobs="$JOBS"
    • xargs as in xargs -P"$JOBS"

    See here for more details.

    (defaults to the value of nproc outside the container)

  • SOURCE_DATE_EPOCH

    Override the reference UNIX timestamp used for bit-for-bit reproducibility, the variable name conforms to standard.

    (defaults to the output of $(git log --format=%at -1))

  • V

    If non-empty, will pass V=1 to all make invocations, making make output verbose.

    Note that any given value is ignored. The variable is only checked for emptiness. More concretely, this means that V= (setting V to the empty string) is interpreted the same way as not setting V at all, and that V=0 has the same effect as V=1.

  • SUBSTITUTE_URLS

    A whitespace-delimited list of URLs from which to download pre-built packages. A URL is only used if its signing key is authorized (refer to the substitute servers section for more details).

  • ADDITIONAL_GUIX_COMMON_FLAGS

    Additional flags to be passed to all guix commands.

  • ADDITIONAL_GUIX_TIMEMACHINE_FLAGS

    Additional flags to be passed to guix time-machine.

  • ADDITIONAL_GUIX_ENVIRONMENT_FLAGS

    Additional flags to be passed to the invocation of guix environment inside guix time-machine.

Choosing your security model

No matter how you installed Guix, you need to decide on your security model for building packages with Guix.

Guix allows us to achieve better binary security by using our CPU time to build everything from scratch. However, it doesn't sacrifice user choice in pursuit of this: users can decide whether or not to use substitutes (pre-built packages).

Option 1: Building with substitutes

Step 1: Authorize the signing keys

Depending on the installation procedure you followed, you may have already authorized the Guix build farm key. In particular, the official shell installer script asks you if you want the key installed, and the debian distribution package authorized the key during installation.

You can check the current list of authorized keys at /etc/guix/acl.

At the time of writing, a /etc/guix/acl with just the Guix build farm key authorized looks something like:

(acl
 (entry
  (public-key
   (ecc
    (curve Ed25519)
    (q #8D156F295D24B0D9A86FA5741A840FF2D24F60F7B6C4134814AD55625971B394#)
    )
   )
  (tag
   (guix import)
   )
  )
 )

If you've determined that the official Guix build farm key hasn't been authorized, and you would like to authorize it, run the following as root:

guix archive --authorize < /var/guix/profiles/per-user/root/current-guix/share/guix/ci.guix.gnu.org.pub

If /var/guix/profiles/per-user/root/current-guix/share/guix/ci.guix.gnu.org.pub doesn't exist, try:

guix archive --authorize < <PREFIX>/share/guix/ci.guix.gnu.org.pub

Where <PREFIX> is likely:

  • /usr if you installed from a distribution package
  • /usr/local if you installed Guix from source and didn't supply any prefix-modifying flags to Guix's ./configure

For dongcarl's substitute server at https://guix.carldong.io, run as root:

wget -qO- 'https://guix.carldong.io/signing-key.pub' | guix archive --authorize

Removing authorized keys

To remove previously authorized keys, simply edit /etc/guix/acl and remove the (entry (public-key ...)) entry.

Step 2: Specify the substitute servers

Once its key is authorized, the official Guix build farm at https://ci.guix.gnu.org is automatically used unless the --no-substitutes flag is supplied. This default list of substitute servers is overridable both on a guix-daemon level and when you invoke guix commands. See examples below for the various ways of adding dongcarl's substitute server after having authorized his signing key.

Change the default list of substitute servers by starting guix-daemon with the --substitute-urls option (you will likely need to edit your init script):

guix-daemon <cmd> --substitute-urls='https://guix.carldong.io https://ci.guix.gnu.org'

Override the default list of substitute servers by passing the --substitute-urls option for invocations of guix commands:

guix <cmd> --substitute-urls='https://guix.carldong.io https://ci.guix.gnu.org'

For scripts under ./contrib/guix, set the SUBSTITUTE_URLS environment variable:

export SUBSTITUTE_URLS='https://guix.carldong.io https://ci.guix.gnu.org'

Option 2: Disabling substitutes on an ad-hoc basis

If you prefer not to use any substitutes, make sure to supply --no-substitutes like in the following snippet. The first build will take a while, but the resulting packages will be cached for future builds.

For direct invocations of guix:

guix <cmd> --no-substitutes

For the scripts under ./contrib/guix/:

export ADDITIONAL_GUIX_COMMON_FLAGS='--no-substitutes'

Option 3: Disabling substitutes by default

guix-daemon accepts a --no-substitutes flag, which will make sure that, unless otherwise overridden by a command line invocation, no substitutes will be used.

If you start guix-daemon using an init script, you can edit said script to supply this flag.

Purging/Uninstalling Guix

In the extraordinarily rare case where you messed up your Guix installation in an irreversible way, you may want to completely purge Guix from your system and start over.

  1. Uninstall Guix itself according to the way you installed it. (e.g. sudo apt purge guix for Ubuntu packaging, sudo make uninstall for built-from-source).

  2. Remove all build users and groups

    You may check for relevant users and groups using:

    getent passwd | grep guix
    getent group | grep guix
    

    Then, you may remove users and groups using:

    sudo userdel <user>
    sudo groupdel <group>
    
  3. Remove all possible Guix-related directories

    • /var/guix/
    • /var/log/guix/
    • /gnu/
    • /etc/guix/
    • /home/*/.config/guix/
    • /home/*/.cache/guix/
    • /home/*/.guix-profile/
    • /root/.config/guix/
    • /root/.cache/guix/
    • /root/.guix-profile/