Skip to content

Commit 3acf90c

Browse files
committed
guix: build docker images in the guix process
1 parent 7b009f5 commit 3acf90c

File tree

3 files changed

+117
-2
lines changed

3 files changed

+117
-2
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
(define-module (bitcoin-knots)
2+
#:use-module ((guix licenses) #:prefix license:)
3+
#:use-module (guix packages)
4+
#:use-module (guix git-download)
5+
#:use-module (guix build-system cmake)
6+
#:use-module (guix gexp)
7+
#:use-module (guix utils)
8+
#:use-module (gnu packages)
9+
#:use-module (gnu packages bash)
10+
#:use-module (gnu packages base)
11+
#:use-module (gnu packages boost)
12+
#:use-module (gnu packages libevent)
13+
#:use-module (gnu packages networking)
14+
#:use-module (gnu packages pkg-config)
15+
#:use-module (gnu packages python)
16+
#:use-module (gnu packages python-xyz)
17+
#:use-module (gnu packages sqlite))
18+
19+
(define-public bitcoin-knots
20+
(package
21+
(name "bitcoin-knots")
22+
(version "29.2.knots20251110")
23+
(source (origin
24+
(method git-fetch)
25+
(uri (git-reference
26+
(url "https://github.com/bitcoinknots/bitcoin")
27+
(commit (string-append "v" version))))
28+
(sha256
29+
(base32
30+
"1ljfdqcqyn6hq6bhibvrc7wvayvy01x503qcnnzd5hcnxc7g3cjw"))))
31+
(build-system cmake-build-system)
32+
(arguments
33+
(list #:configure-flags
34+
#~(list
35+
"-DBUILD_GUI=OFF"
36+
"-DBUILD_BENCH=ON"
37+
"-DWITH_ZMQ=ON"
38+
;; TODO: Enable IPC once capnproto is built with -fPIC.
39+
"-DENABLE_IPC=OFF")
40+
#:phases
41+
#~(modify-phases %standard-phases
42+
(add-before 'build 'set-no-git-flag
43+
(lambda _
44+
;; Make it clear we are not building from within a git repository
45+
;; (and thus no information regarding this build is available
46+
;; from git).
47+
(setenv "BITCOIN_GENBUILD_NO_GIT" "1")))
48+
(add-before 'check 'set-home
49+
(lambda _
50+
;; Tests write to $HOME.
51+
(setenv "HOME" (getenv "TMPDIR"))))
52+
(add-after 'check 'check-functional
53+
(lambda _
54+
(invoke
55+
"python3" "./test/functional/test_runner.py"
56+
(string-append "--jobs=" (number->string (parallel-job-count)))))))))
57+
(native-inputs
58+
(list bash ; provides the sh command for system_tests
59+
coreutils ; provides the cat, echo and false commands for system_tests
60+
pkg-config
61+
python ; for the tests
62+
python-pyzmq ; for the tests
63+
))
64+
(inputs
65+
(list boost
66+
libevent
67+
sqlite
68+
zeromq))
69+
(home-page "https://bitcoinknots.org/")
70+
(synopsis "Bitcoin peer-to-peer client")
71+
(description
72+
"Bitcoin is a digital currency that enables instant payments to anyone
73+
anywhere in the world. It uses peer-to-peer technology to operate without
74+
central authority: managing transactions and issuing money are carried out
75+
collectively by the network. This package provides the Bitcoin Knots command
76+
line client.")
77+
(license license:expat)))
78+
79+
bitcoin-knots

contrib/guix/docker/channels.scm

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
(define-module (channels))
2+
(use-modules (guix channels))
3+
4+
(list (channel
5+
(name 'guix)
6+
(url "https://git.savannah.gnu.org/git/guix.git")
7+
(branch "master")
8+
(commit
9+
"8eed773a70afa696b3b67ca49ee67257b8a44b03")
10+
(introduction
11+
(make-channel-introduction
12+
"9edb3f66fd807b096b48283debdcddccfea34bad"
13+
(openpgp-fingerprint
14+
"BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA")))))

contrib/guix/guix-build

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ check_source_date_epoch
8282
# Default to building for all supported HOSTs (overridable by environment)
8383
export HOSTS="${HOSTS:-x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv64-linux-gnu powerpc64-linux-gnu powerpc64le-linux-gnu
8484
x86_64-w64-mingw32
85-
x86_64-apple-darwin arm64-apple-darwin}"
85+
x86_64-apple-darwin arm64-apple-darwin
86+
docker-x86_64-linux docker-aarch64-linux}"
8687

8788
# Usage: distsrc_for_host HOST
8889
#
@@ -301,6 +302,12 @@ mkdir -p "$OUTDIR_BASE"
301302
# Download the depends sources now as we won't have internet access in the build
302303
# container
303304
for host in $HOSTS; do
305+
case "$host" in
306+
docker*)
307+
# No need to download depends sources for docker builds
308+
continue
309+
;;
310+
esac
304311
make -C "${PWD}/depends" -j"$JOBS" download-"$(host_to_commonname "$host")" ${V:+V=1} ${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"}
305312
done
306313

@@ -352,6 +359,20 @@ for host in $HOSTS; do
352359
# Display proper warning when the user interrupts the build
353360
trap 'int_trap ${host}' INT
354361

362+
if [[ "$host" == docker* ]]; then
363+
mkdir -p "$OUTDIR_BASE/docker"
364+
fi
365+
366+
case "$host" in
367+
docker*)
368+
echo "Building docker image for ${host#docker-}"
369+
dockerpath=$(guix time-machine -C ${PWD}/contrib/guix/docker/channels.scm -- \
370+
pack -L ${PWD}/contrib/guix/docker -f docker --system=${host#docker-} bitcoin-knots \
371+
| tee /dev/tty | tail -n1)
372+
cp "$dockerpath" "$OUTDIR_BASE/docker/${host}.tar.gz"
373+
continue
374+
;;
375+
*)
355376
(
356377
# Required for 'contrib/guix/manifest.scm' to output the right manifest
357378
# for the particular $HOST we're building for
@@ -471,5 +492,6 @@ EOF
471492
DIST_ARCHIVE_BASE=/outdir-base/dist-archive \
472493
bash -c "cd /bitcoin && bash contrib/guix/libexec/build.sh"
473494
)
474-
495+
;;
496+
esac
475497
done

0 commit comments

Comments
 (0)