0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-02-10 10:52:31 -05:00

guix: Add ADDITIONAL_GUIX_{COMMON,TIMEMACHINE}_FLAGS options

This commit is contained in:
Carl Dong 2020-12-10 14:02:19 -05:00
parent 0f31e24703
commit 93b6a8544a
2 changed files with 42 additions and 8 deletions

View file

@ -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). 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]. This is skippable if you're using the [Dockerfile][fanquake/guix-docker].
If you prefer not to use any substitutes, make sure to set If you prefer not to use any substitutes, make sure to supply `--no-substitutes`
`ADDITIONAL_GUIX_ENVIRONMENT_FLAGS` like the following snippet. The first build like in the following snippet. The first build will take a while, but the
will take a while, but the resulting packages will be cached for future builds. resulting packages will be cached for future builds.
```sh ```sh
export ADDITIONAL_GUIX_ENVIRONMENT_FLAGS='--no-substitutes' export ADDITIONAL_GUIX_COMMON_FLAGS='--no-substitutes'
``` ```
Likewise, to perform a bootstrapped build (takes even longer): Likewise, to perform a bootstrapped build (takes even longer):
```sh ```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 ### 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 servers section](#speeding-up-builds-with-substitute-servers) for more
details). 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 build, set this to `--bootstrap --no-substitutes` (refer to the [security
model section](#choosing-your-security-model) for more details). Note that a 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. 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 ## Tips and Tricks
### Speeding up builds with substitute servers ### Speeding up builds with substitute servers

View file

@ -2,6 +2,30 @@
export LC_ALL=C export LC_ALL=C
set -e -o pipefail 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 # Determine the maximum number of jobs to run simultaneously (overridable by
# environment) # environment)
MAX_JOBS="${MAX_JOBS:-$(nproc)}" MAX_JOBS="${MAX_JOBS:-$(nproc)}"
@ -21,6 +45,7 @@ time-machine() {
--commit=b066c25026f21fb57677aa34692a5034338e7ee3 \ --commit=b066c25026f21fb57677aa34692a5034338e7ee3 \
--max-jobs="$MAX_JOBS" \ --max-jobs="$MAX_JOBS" \
${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"} \ ${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 \ --share="$PWD"=/bitcoin \
--expose="$(git rev-parse --git-common-dir)" \ --expose="$(git rev-parse --git-common-dir)" \
${SOURCES_PATH:+--share="$SOURCES_PATH"} \ ${SOURCES_PATH:+--share="$SOURCES_PATH"} \
${ADDITIONAL_GUIX_ENVIRONMENT_FLAGS} \
--max-jobs="$MAX_JOBS" \ --max-jobs="$MAX_JOBS" \
${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"} \ ${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"} \
${ADDITIONAL_GUIX_COMMON_FLAGS} ${ADDITIONAL_GUIX_ENVIRONMENT_FLAGS} \
-- env HOST="$host" \ -- env HOST="$host" \
MAX_JOBS="$MAX_JOBS" \ MAX_JOBS="$MAX_JOBS" \
SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:?unable to determine value}" \ SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:?unable to determine value}" \