Skip to content

Commit 93b6a85

Browse files
committed
guix: Add ADDITIONAL_GUIX_{COMMON,TIMEMACHINE}_FLAGS options
1 parent 0f31e24 commit 93b6a85

File tree

2 files changed

+42
-8
lines changed

2 files changed

+42
-8
lines changed

contrib/guix/README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,18 @@ servers](#speeding-up-builds-with-substitute-servers) to speed up your build if
4747
that fits your security model (say, if you're just testing that this works).
4848
This is skippable if you're using the [Dockerfile][fanquake/guix-docker].
4949

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

5454
```sh
55-
export ADDITIONAL_GUIX_ENVIRONMENT_FLAGS='--no-substitutes'
55+
export ADDITIONAL_GUIX_COMMON_FLAGS='--no-substitutes'
5656
```
5757

5858
Likewise, to perform a bootstrapped build (takes even longer):
5959

6060
```sh
61-
export ADDITIONAL_GUIX_ENVIRONMENT_FLAGS='--bootstrap --no-substitutes'
61+
export ADDITIONAL_GUIX_COMMON_FLAGS='--no-substitutes' ADDITIONAL_GUIX_ENVIRONMENT_FLAGS='--bootstrap'
6262
```
6363

6464
### Using a version of Guix with `guix time-machine` capabilities
@@ -154,13 +154,22 @@ find output/ -type f -print0 | sort -z | xargs -r0 sha256sum
154154
servers section](#speeding-up-builds-with-substitute-servers) for more
155155
details).
156156

157-
* _**ADDITIONAL_GUIX_ENVIRONMENT_FLAGS**_
157+
* _**ADDITIONAL_GUIX_COMMON_FLAGS**_
158158

159-
Additional flags to be passed to `guix environment`. For a fully-bootstrapped
159+
Additional flags to be passed to all `guix` commands. For a fully-bootstrapped
160160
build, set this to `--bootstrap --no-substitutes` (refer to the [security
161161
model section](#choosing-your-security-model) for more details). Note that a
162162
fully-bootstrapped build will take quite a long time on the first run.
163163

164+
* _**ADDITIONAL_GUIX_TIMEMACHINE_FLAGS**_
165+
166+
Additional flags to be passed to `guix time-machine`.
167+
168+
* _**ADDITIONAL_GUIX_ENVIRONMENT_FLAGS**_
169+
170+
Additional flags to be passed to the invocation of `guix environment` inside
171+
`guix time-machine`.
172+
164173
## Tips and Tricks
165174

166175
### Speeding up builds with substitute servers

contrib/guix/guix-build.sh

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,30 @@
22
export LC_ALL=C
33
set -e -o pipefail
44

5+
# GUIX_BUILD_OPTIONS is an environment variable recognized by guix commands that
6+
# can perform builds. This seems like what we want instead of
7+
# ADDITIONAL_GUIX_COMMON_FLAGS, but the value of GUIX_BUILD_OPTIONS is actually
8+
# _appended_ to normal command-line options. Meaning that they will take
9+
# precedence over the command-specific ADDITIONAL_GUIX_<CMD>_FLAGS.
10+
#
11+
# This seems like a poor user experience. Thus we check for GUIX_BUILD_OPTIONS's
12+
# existence here and direct users of this script to use our (more flexible)
13+
# custom environment variables.
14+
if [ -n "$GUIX_BUILD_OPTIONS" ]; then
15+
cat << EOF
16+
Error: Environment variable GUIX_BUILD_OPTIONS is not empty:
17+
'$GUIX_BUILD_OPTIONS'
18+
19+
Unfortunately this script is incompatible with GUIX_BUILD_OPTIONS, please unset
20+
GUIX_BUILD_OPTIONS and use ADDITIONAL_GUIX_COMMON_FLAGS to set build options
21+
across guix commands or ADDITIONAL_GUIX_<CMD>_FLAGS to set build options for a
22+
specific guix command.
23+
24+
See contrib/guix/README.md for more details.
25+
EOF
26+
exit 1
27+
fi
28+
529
# Determine the maximum number of jobs to run simultaneously (overridable by
630
# environment)
731
MAX_JOBS="${MAX_JOBS:-$(nproc)}"
@@ -21,6 +45,7 @@ time-machine() {
2145
--commit=b066c25026f21fb57677aa34692a5034338e7ee3 \
2246
--max-jobs="$MAX_JOBS" \
2347
${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"} \
48+
${ADDITIONAL_GUIX_COMMON_FLAGS} ${ADDITIONAL_GUIX_TIMEMACHINE_FLAGS} \
2449
-- "$@"
2550
}
2651

@@ -120,9 +145,9 @@ for host in ${HOSTS=x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv
120145
--share="$PWD"=/bitcoin \
121146
--expose="$(git rev-parse --git-common-dir)" \
122147
${SOURCES_PATH:+--share="$SOURCES_PATH"} \
123-
${ADDITIONAL_GUIX_ENVIRONMENT_FLAGS} \
124148
--max-jobs="$MAX_JOBS" \
125149
${SUBSTITUTE_URLS:+--substitute-urls="$SUBSTITUTE_URLS"} \
150+
${ADDITIONAL_GUIX_COMMON_FLAGS} ${ADDITIONAL_GUIX_ENVIRONMENT_FLAGS} \
126151
-- env HOST="$host" \
127152
MAX_JOBS="$MAX_JOBS" \
128153
SOURCE_DATE_EPOCH="${SOURCE_DATE_EPOCH:?unable to determine value}" \

0 commit comments

Comments
 (0)