Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion contrib/guix/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ Conservatively, you will need:
If you don't have Guix installed and set up, please follow the instructions in
[INSTALL.md](./INSTALL.md)

Additionally the `guix-build` script will build a docker compatible image
which require to install QEMU user static binary.

On Debian you can install `qemu-user-static` package.

# Usage

If you haven't considered your security model yet, please read [the relevant
Expand Down Expand Up @@ -224,7 +229,7 @@ details.

_(defaults to "x86\_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu
riscv64-linux-gnu powerpc64-linux-gnu powerpc64le-linux-gnu
x86\_64-w64-mingw32 x86\_64-apple-darwin arm64-apple-darwin")_
x86\_64-w64-mingw32 x86\_64-apple-darwin arm64-apple-darwin docker-x86\_64-linux docker-aarch64-linux")_

* _**SOURCES_PATH**_

Expand Down
73 changes: 73 additions & 0 deletions contrib/guix/docker/bitcoin-knots.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
(define-module (bitcoin-knots)
#:use-module ((guix licenses) #:prefix license:)
#:use-module (guix packages)
#:use-module (guix git-download)
#:use-module (guix build-system cmake)
#:use-module (guix gexp)
#:use-module (guix utils)
#:use-module (gnu packages)
#:use-module (gnu packages bash)
#:use-module (gnu packages base)
#:use-module (gnu packages boost)
#:use-module (gnu packages libevent)
#:use-module (gnu packages networking)
#:use-module (gnu packages pkg-config)
#:use-module (gnu packages python)
#:use-module (gnu packages python-xyz)
#:use-module (gnu packages sqlite))

(define-public bitcoin-knots
(package
(name "bitcoin-knots")
(version (getenv "VERSION"))
; the source section is overrided by the guix-build script
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/bitcoinknots/bitcoin")
(commit (string-append "v" version))))
; We use a fake hash because this scheme isn't supposed
; to be builded outside the guix-build scipt
(sha256 #f)))
(build-system cmake-build-system)
(arguments
(list #:configure-flags
#~(list
"-DBUILD_GUI=OFF"
"-DBUILD_TESTS=ON"
"-DWITH_ZMQ=ON")
#:phases
#~(modify-phases %standard-phases
(add-before 'build 'set-no-git-flag
(lambda _
;; Make it clear we are not building from within a git repository
;; (and thus no information regarding this build is available
;; from git).
(setenv "BITCOIN_GENBUILD_NO_GIT" "1")))
(add-before 'check 'set-home
(lambda _
;; Tests write to $HOME.
(setenv "HOME" (getenv "TMPDIR")))))))
(native-inputs
(list bash ; provides the sh command for system_tests
coreutils ; provides the cat, echo and false commands for system_tests
pkg-config
python ; for the tests
python-pyzmq ; for the tests
))
(inputs
(list boost
libevent
sqlite
zeromq))
(home-page "https://bitcoinknots.org/")
(synopsis "Bitcoin peer-to-peer client")
(description
"Bitcoin is a digital currency that enables instant payments to anyone
anywhere in the world. It uses peer-to-peer technology to operate without
central authority: managing transactions and issuing money are carried out
collectively by the network. This package provides the Bitcoin Knots command
line client.")
(license license:expat)))

bitcoin-knots
14 changes: 14 additions & 0 deletions contrib/guix/docker/channels.scm
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
(define-module (channels))
(use-modules (guix channels))

(list (channel
(name 'guix)
(url "https://git.savannah.gnu.org/git/guix.git")
(branch "master")
(commit
"8eed773a70afa696b3b67ca49ee67257b8a44b03")
(introduction
(make-channel-introduction
"9edb3f66fd807b096b48283debdcddccfea34bad"
(openpgp-fingerprint
"BBB0 2DDF 2CEA F6A8 0D1D E643 A2A0 6DF2 A33A 54FA")))))
39 changes: 37 additions & 2 deletions contrib/guix/guix-build
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ check_source_date_epoch
# Default to building for all supported HOSTs (overridable by environment)
export HOSTS="${HOSTS:-x86_64-linux-gnu arm-linux-gnueabihf aarch64-linux-gnu riscv64-linux-gnu powerpc64-linux-gnu powerpc64le-linux-gnu
x86_64-w64-mingw32
x86_64-apple-darwin arm64-apple-darwin}"
x86_64-apple-darwin arm64-apple-darwin
docker-x86_64-linux docker-aarch64-linux}"

# Usage: distsrc_for_host HOST
#
Expand Down Expand Up @@ -301,6 +302,12 @@ mkdir -p "$OUTDIR_BASE"
# Download the depends sources now as we won't have internet access in the build
# container
for host in $HOSTS; do
case "$host" in
docker*)
# No need to download depends sources for docker builds
continue
;;
esac
make -C "${PWD}/depends" -j"$JOBS" download-"$(host_to_commonname "$host")" ${V:+V=1} ${SOURCES_PATH:+SOURCES_PATH="$SOURCES_PATH"}
done

Expand Down Expand Up @@ -352,6 +359,33 @@ for host in $HOSTS; do
# Display proper warning when the user interrupts the build
trap 'int_trap ${host}' INT

if [[ "$host" == docker* ]]; then
mkdir -p "$OUTDIR_BASE/docker"
fi

case "$host" in
docker*)
echo "Building docker image for ${host#docker-}"
dockerpath=$(VERSION="${VERSION}" \
guix time-machine -C ${PWD}/contrib/guix/docker/channels.scm -- \
pack -L "${PWD}"/contrib/guix/docker \
-f docker \
--system=${host#docker-} \
--entry-point=bin/bitcoind \
--with-git-url=bitcoin-knots=file://"${PWD}" \
bitcoin-knots \
| tee /dev/tty | tail -n1)
if [ ! -z "$dockerpath" ]; then
cp "$dockerpath" "$OUTDIR_BASE/docker/${DISTNAME}-${host}.tar.gz"
chmod 644 "$OUTDIR_BASE/docker/${DISTNAME}-${host}.tar.gz"
sha256sum "$OUTDIR_BASE/docker/${DISTNAME}-${host}.tar.gz" >> "$OUTDIR_BASE/docker/SHA256SUMS.part"
else
echo "Failed to build docker image for ${host#docker-}, exiting..."
exit 1
fi
continue
;;
*)
(
# Required for 'contrib/guix/manifest.scm' to output the right manifest
# for the particular $HOST we're building for
Expand Down Expand Up @@ -471,5 +505,6 @@ EOF
DIST_ARCHIVE_BASE=/outdir-base/dist-archive \
bash -c "cd /bitcoin && bash contrib/guix/libexec/build.sh"
)

;;
esac
done
Loading