Skip to content
Closed
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
8 changes: 4 additions & 4 deletions .github/workflows/depends.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ jobs:
- name: Checkout Bitcoin Repo
uses: actions/checkout@v4
with:
repository: willcl-ark/bitcoin
ref: cmake-dependency-provider
repository: bitcoin/bitcoin
ref: master
path: bitcoin
fetch-depth: 1

Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:

- name: Build bitcoin from depends
run: |
nix develop --command bash -c "
nix develop .#depends --command bash -c "
set -eux

export CCACHE_DIR=${{ env.CCACHE_DIR }}
Expand All @@ -91,7 +91,7 @@ jobs:
HOST_TRIPLET=\$(./depends/config.guess)
export HOST_TRIPLET
make -C depends -j\$(nproc) NO_QT=1
cmake -B build --toolchain \"depends/\$HOST_TRIPLET/toolchain.cmake\" -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES=\"depends/\$HOST_TRIPLET/dependency_provider.cmake\"
cmake -B build --toolchain \"depends/\$HOST_TRIPLET/toolchain.cmake\"
cmake --build build -j\$(nproc)
ccache --show-stats
"
16 changes: 12 additions & 4 deletions .github/workflows/nix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,19 @@ jobs:
include:
- system: x86_64-linux
runner_label: ubuntu-latest
cores: 4
cmake_flags:
- system: aarch64-linux
runner_label: ubuntu-24.04-arm
cores: 4
cmake_flags:
- system: x86_64-darwin
runner_label: macos-13
runner_label: macos-15-intel
cores: 4
cmake_flags: -DWITH_USDT=OFF
- system: aarch64-darwin
runner_label: macos-14
runner_label: macos-latest
cores: 3
cmake_flags: -DWITH_USDT=OFF

env:
Expand Down Expand Up @@ -85,7 +89,11 @@ jobs:
set -eux
export CCACHE_DIR=${{ env.CCACHE_DIR }}
cd bitcoin
cmake -B build -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache --preset dev-mode ${{ matrix.cmake_flags }}
cmake --build build -j$(nproc)
cmake -B build \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
--preset dev-mode \
${{ matrix.cmake_flags }}
cmake --build build -j${{ matrix.cores }}
ccache --show-stats
"
25 changes: 21 additions & 4 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

117 changes: 57 additions & 60 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,40 @@

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
nixpkgs-qt6.url = "github:NixOS/nixpkgs/0c0e48b0ec1af2d7f7de70f839de1569927fe4c8";
flake-utils.url = "github:numtide/flake-utils";
};

outputs = {
nixpkgs,
nixpkgs-qt6,
flake-utils,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {inherit system;};
isLinux = pkgs.stdenv.isLinux;
isDarwin = pkgs.stdenv.isDarwin;
lib = pkgs.lib;

# Configure LLVM and python version for the environment
llvmVersion = "20";
pythonVersion = "13";

llvmPackages = pkgs."llvmPackages_${llvmVersion}";
llvmTools = {
inherit (llvmPackages) bintools clang clang-tools;
lldb = pkgs."lldb_${llvmVersion}";
# Overlay depends-matching version of qt6: https://github.com/bitcoin/bitcoin/blob/master/depends/packages/qt_details.mk#L1
qtPkgs = import nixpkgs-qt6 {inherit system;};
pkgs = import nixpkgs {
inherit system;
overlays = [
(final: prev: {
qt6 = qtPkgs.qt6;
})
];
};
inherit (pkgs) lib;
inherit (pkgs.stdenv) isLinux isDarwin;

python = pkgs.python313;
llvmPackages = pkgs.llvmPackages_20;

# Helper for platform-specific packages
platformPkgs = cond: pkgs:
if cond
then pkgs
else [];
# On Darwin use clang-20 otherwise use a gcc15 (and mold)-based standard env.
stdEnv =
if isDarwin
then llvmPackages.stdenv
else pkgs.stdenvAdapters.useMoldLinker pkgs.gcc15Stdenv;

# Use a single pythonEnv throughout and specifically in the devShell to make sure bcc is available.
pythonEnv = pkgs."python3${pythonVersion}".withPackages (ps:
pythonEnv = python.withPackages (ps:
with ps;
[
flake8
Expand All @@ -43,7 +45,7 @@
pyzmq
vulture
]
++ platformPkgs isLinux [
++ lib.optionals isLinux [
bcc
]);

Expand All @@ -52,59 +54,54 @@
[
bison
ccache
clang-tools
cmake
curlMinimal
llvmTools.bintools
llvmTools.clang
llvmTools.clang-tools
ninja
pkg-config
qt6.wrapQtAppsHook # https://nixos.org/manual/nixpkgs/stable/#sec-language-qt
xz
]
++ platformPkgs isLinux [
++ lib.optionals isLinux [
libsystemtap
linuxPackages.bcc
linuxPackages.bpftrace
];

qtBuildInputs = with pkgs; [
qt6.qtbase # https://nixos.org/manual/nixpkgs/stable/#sec-language-qt
qt6.qttools
];

# Will exist in the runtime environment
buildInputs = with pkgs;
[
boost
capnproto
libevent
qrencode
qt6.qtbase # https://nixos.org/manual/nixpkgs/stable/#sec-language-qt
qt6.qttools
sqlite.dev
zeromq
]
++ platformPkgs isLinux [
libsystemtap
linuxPackages.bcc
linuxPackages.bpftrace
];
buildInputs = with pkgs; [
boost
capnproto
libevent
qrencode
sqlite.dev
zeromq
];

env = {
CMAKE_GENERATOR = "Ninja";
LD_LIBRARY_PATH = lib.makeLibraryPath [pkgs.capnproto];
LOCALE_ARCHIVE = lib.optionalString isLinux "${pkgs.glibcLocales}/lib/locale/locale-archive";
};
mkDevShell = nativeInputs: buildInputs:
(pkgs.mkShell.override {stdenv = stdEnv;}) {
inherit nativeBuildInputs buildInputs;
packages =
[
pythonEnv
pkgs.codespell
pkgs.hexdump
]
++ lib.optionals isLinux [pkgs.gdb]
++ lib.optionals isDarwin [llvmPackages.lldb];

CMAKE_GENERATOR = "Ninja";
CMAKE_EXPORT_COMPILE_COMMANDS = 1;
LD_LIBRARY_PATH = lib.makeLibraryPath [pkgs.capnproto];
LOCALE_ARCHIVE = lib.optionalString isLinux "${pkgs.glibcLocales}/lib/locale/locale-archive";
};
in {
# We use mkShelNoCC to avoid having Nix set up a gcc-based build environment
devShells.default = pkgs.mkShellNoCC {
inherit nativeBuildInputs buildInputs;
packages =
[
pythonEnv
pkgs.codespell
pkgs.hexdump
]
++ platformPkgs isLinux [pkgs.gdb]
++ platformPkgs isDarwin [llvmTools.lldb];
inherit (env) CMAKE_GENERATOR LD_LIBRARY_PATH LOCALE_ARCHIVE;
};
devShells.default = mkDevShell (nativeBuildInputs ++ [pkgs.qt6.wrapQtAppsHook]) (buildInputs ++ qtBuildInputs);
devShells.depends = mkDevShell nativeBuildInputs qtBuildInputs;

formatter = pkgs.alejandra;
});
Expand Down
Loading