diff --git a/.github/workflows/depends.yml b/.github/workflows/depends.yml index 65cbd85..4bb9db9 100644 --- a/.github/workflows/depends.yml +++ b/.github/workflows/depends.yml @@ -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 @@ -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 }} @@ -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 " diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 8407f60..112c901 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -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: @@ -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 " diff --git a/flake.lock b/flake.lock index ec4cfca..28b0e44 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1748889542, - "narHash": "sha256-Hb4iMhIbjX45GcrgOp3b8xnyli+ysRPqAgZ/LZgyT5k=", + "lastModified": 1758791193, + "narHash": "sha256-F8WmEwFoHsnix7rt290R0rFXNJiMbClMZyIC/e+HYf0=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "10d7f8d34e5eb9c0f9a0485186c1ca691d2c5922", + "rev": "25e53aa156d47bad5082ff7618f5feb1f5e02d01", "type": "github" }, "original": { @@ -34,10 +34,27 @@ "type": "github" } }, + "nixpkgs-qt6": { + "locked": { + "lastModified": 1727460514, + "narHash": "sha256-yBEHizSvK3iomuapfOjc4Pm2pL3+dT7bqR1JfzztQoo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0c0e48b0ec1af2d7f7de70f839de1569927fe4c8", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0c0e48b0ec1af2d7f7de70f839de1569927fe4c8", + "type": "github" + } + }, "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs" + "nixpkgs": "nixpkgs", + "nixpkgs-qt6": "nixpkgs-qt6" } }, "systems": { diff --git a/flake.nix b/flake.nix index adef51a..a152196 100644 --- a/flake.nix +++ b/flake.nix @@ -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 @@ -43,7 +45,7 @@ pyzmq vulture ] - ++ platformPkgs isLinux [ + ++ lib.optionals isLinux [ bcc ]); @@ -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; });