@@ -13,6 +13,8 @@ make -C "${PWD}/depends" -j"$MAX_JOBS" download ${V:+V=1} ${SOURCES_PATH:+SOURCE
1313# Determine the reference time used for determinism (overridable by environment)
1414SOURCE_DATE_EPOCH=" ${SOURCE_DATE_EPOCH:- $(git log --format=% at -1)} "
1515
16+ # Execute "$@" in a pinned, possibly older version of Guix, for reproducibility
17+ # across time.
1618time-machine () {
1719 guix time-machine --url=https://github.com/dongcarl/guix.git \
1820 --commit=b3a7c72c8b2425f8ddb0fc6e3b1caeed40f86dee \
@@ -32,6 +34,53 @@ for host in ${HOSTS=x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv
3234
3335 # Run the build script 'contrib/guix/libexec/build.sh' in the build
3436 # container specified by 'contrib/guix/manifest.scm'.
37+ #
38+ # Explanation of `guix environment` flags:
39+ #
40+ # --container run command within an isolated container
41+ #
42+ # Running in an isolated container minimizes build-time differences
43+ # between machines and improves reproducibility
44+ #
45+ # --pure unset existing environment variables
46+ #
47+ # Same rationale as --container
48+ #
49+ # --no-cwd do not share current working directory with an
50+ # isolated container
51+ #
52+ # When --container is specified, the default behavior is to share
53+ # the current working directory with the isolated container at the
54+ # same exact path (e.g. mapping '/home/satoshi/bitcoin/' to
55+ # '/home/satoshi/bitcoin/'). This means that the $PWD inside the
56+ # container becomes a source of irreproducibility. --no-cwd disables
57+ # this behaviour.
58+ #
59+ # --share=SPEC for containers, share writable host file system
60+ # according to SPEC
61+ #
62+ # --share="$PWD"=/bitcoin
63+ #
64+ # maps our current working directory to /bitcoin
65+ # inside the isolated container, which we later cd
66+ # into.
67+ #
68+ # While we don't want to map our current working directory to the
69+ # same exact path (as this introduces irrepreducibility), we do want
70+ # it to be at a _fixed_ path _somewhere_ inside the isolated
71+ # container so that we have something to build. '/bitcoin' was
72+ # chosen arbitrarily.
73+ #
74+ # ${SOURCES_PATH:+--share="$SOURCES_PATH"}
75+ #
76+ # make the downloaded depends sources path available
77+ # inside the isolated container
78+ #
79+ # The isolated container has no network access as it's in a
80+ # different network namespace from the main machine, so we have to
81+ # make the downloaded depends sources available to it. The sources
82+ # should have been downloaded prior to this invocation.
83+ #
3584 # shellcheck disable=SC2086
3685 time-machine environment --manifest=" ${PWD} /contrib/guix/manifest.scm" \
3786 --container \
0 commit comments