diff options
author | Carl Dong <contact@carldong.me> | 2020-12-10 14:02:19 -0500 |
---|---|---|
committer | Carl Dong <contact@carldong.me> | 2021-01-08 11:40:01 -0500 |
commit | 93b6a8544a03d13733ca2ef769f76df587ad86c8 (patch) | |
tree | 4b884b3b2a7c690f3d3d50d6649cbccd3ea7345b /contrib | |
parent | 0f31e24703e25698d2d41fb54e30ec75a4a80943 (diff) |
guix: Add ADDITIONAL_GUIX_{COMMON,TIMEMACHINE}_FLAGS options
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/guix/README.md | 23 | ||||
-rwxr-xr-x | contrib/guix/guix-build.sh | 27 |
2 files changed, 42 insertions, 8 deletions
diff --git a/contrib/guix/README.md b/contrib/guix/README.md index cf1429f6cf..4e633729fe 100644 --- a/contrib/guix/README.md +++ b/contrib/guix/README.md @@ -47,18 +47,18 @@ servers](#speeding-up-builds-with-substitute-servers) to speed up your build if that fits your security model (say, if you're just testing that this works). This is skippable if you're using the [Dockerfile][fanquake/guix-docker]. -If you prefer not to use any substitutes, make sure to set -`ADDITIONAL_GUIX_ENVIRONMENT_FLAGS` like the following snippet. The first build -will take a while, but the resulting packages will be cached for future builds. +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. ```sh -export ADDITIONAL_GUIX_ENVIRONMENT_FLAGS='--no-substitutes' +export ADDITIONAL_GUIX_COMMON_FLAGS='--no-substitutes' ``` Likewise, to perform a bootstrapped build (takes even longer): ```sh -export ADDITIONAL_GUIX_ENVIRONMENT_FLAGS='--bootstrap --no-substitutes' +export ADDITIONAL_GUIX_COMMON_FLAGS='--no-substitutes' ADDITIONAL_GUIX_ENVIRONMENT_FLAGS='--bootstrap' ``` ### Using a version of Guix with `guix time-machine` capabilities @@ -154,13 +154,22 @@ find output/ -type f -print0 | sort -z | xargs -r0 sha256sum servers section](#speeding-up-builds-with-substitute-servers) for more details). -* _**ADDITIONAL_GUIX_ENVIRONMENT_FLAGS**_ +* _**ADDITIONAL_GUIX_COMMON_FLAGS**_ - Additional flags to be passed to `guix environment`. For a fully-bootstrapped + Additional flags to be passed to all `guix` commands. For a fully-bootstrapped build, set this to `--bootstrap --no-substitutes` (refer to the [security model section](#choosing-your-security-model) for more details). Note that a fully-bootstrapped build will take quite a long time on the first run. +* _**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`. + ## Tips and Tricks ### Speeding up builds with substitute servers diff --git a/contrib/guix/guix-build.sh b/contrib/guix/guix-build.sh index 91fa273175..e268a8b996 100755 --- a/contrib/guix/guix-build.sh +++ b/contrib/guix/guix-build.sh @@ -2,6 +2,30 @@ export LC_ALL=C set -e -o pipefail +# GUIX_BUILD_OPTIONS is an environment variable recognized by guix commands that +# can perform builds. This seems like what we want instead of +# ADDITIONAL_GUIX_COMMON_FLAGS, but the value of GUIX_BUILD_OPTIONS is actually +# _appended_ to normal command-line options. Meaning that they will take +# precedence over the command-specific ADDITIONAL_GUIX_<CMD>_FLAGS. +# +# This seems like a poor user experience. Thus we check for GUIX_BUILD_OPTIONS's +# existence here and direct users of this script to use our (more flexible) +# custom environment variables. +if [ -n "$GUIX_BUILD_OPTIONS" ]; then +cat << EOF +Error: Environment variable GUIX_BUILD_OPTIONS is not empty: + '$GUIX_BUILD_OPTIONS' + +Unfortunately this script is incompatible with GUIX_BUILD_OPTIONS, please unset +GUIX_BUILD_OPTIONS and use ADDITIONAL_GUIX_COMMON_FLAGS to set build options +across guix commands or ADDITIONAL_GUIX_<CMD>_FLAGS to set build options for a +specific guix command. + +See contrib/guix/README.md for more details. +EOF +exit 1 +fi + # Determine the maximum number of jobs to run simultaneously (overridable by # environment) MAX_JOBS="${MAX_JOBS:-$(nproc)}" @@ -21,6 +45,7 @@ time-machine() { --commit=b066c25026f21fb57677aa34692a5034338e7ee3 \ --max-jobs="$MAX_JOBS" \ ${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"} \ + ${ADDITIONAL_GUIX_COMMON_FLAGS} ${ADDITIONAL_GUIX_TIMEMACHINE_FLAGS} \ -- "$@" } @@ -120,9 +145,9 @@ for host in ${HOSTS=x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv --share="$PWD"=/bitcoin \ --expose="$(git rev-parse --git-common-dir)" \ ${SOURCES_PATH:+--share="$SOURCES_PATH"} \ - ${ADDITIONAL_GUIX_ENVIRONMENT_FLAGS} \ --max-jobs="$MAX_JOBS" \ ${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"} \ + ${ADDITIONAL_GUIX_COMMON_FLAGS} ${ADDITIONAL_GUIX_ENVIRONMENT_FLAGS} \ -- env HOST="$host" \ MAX_JOBS="$MAX_JOBS" \ SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:?unable to determine value}" \ |