From 04b1b84ace82d4ef8acfcb68233076b7c6643744 Mon Sep 17 00:00:00 2001 From: will Date: Fri, 15 Aug 2025 12:21:58 +0100 Subject: [PATCH 01/10] Generally overhaul flake - Tidy up LLVM-based stdenv, include LLVM bintools - Add separate depends devShell for building from depends - Update nixpkgs to unstable - Pin Qt6 to specific version for depends compatibility - Modernize CI: update GitHub Actions runners and add per-platform core counts - Fix depends workflow to use new devShell and remove custom cmake config - Set CMAKE_EXPORT_COMPILE_COMMANDS for native LSP support - Use mold linker on Linux for faster builds - Add include-what-you-use and other tools - Format nix files with nixfmt-tree The depends devShell sets build_CC/build_CXX to clang to avoid issues with depends packages that hardcode CXX=g++. --- .github/workflows/depends.yml | 11 +- .github/workflows/fmt.yml | 4 +- .github/workflows/nix.yml | 17 +++- flake.lock | 27 ++++- flake.nix | 183 +++++++++++++++++++--------------- 5 files changed, 146 insertions(+), 96 deletions(-) diff --git a/.github/workflows/depends.yml b/.github/workflows/depends.yml index 65cbd85..c8e5760 100644 --- a/.github/workflows/depends.yml +++ b/.github/workflows/depends.yml @@ -19,6 +19,7 @@ jobs: CCACHE_DIR: ${{ github.workspace }}/.ccache SOURCES_PATH: ${{ github.workspace }}/depends-sources BASE_CACHE: ${{ github.workspace }}/depends-base + NIX_SHOW_LOG: "1" steps: - name: Checkout Repo @@ -27,8 +28,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 +81,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 }} @@ -90,8 +91,8 @@ jobs: cd bitcoin 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\" + make -C depends -j\$(nproc) NO_QT=1 build_CC="$CC" build_CXX="$CXX" + cmake -B build --toolchain \"depends/\$HOST_TRIPLET/toolchain.cmake\" cmake --build build -j\$(nproc) ccache --show-stats " diff --git a/.github/workflows/fmt.yml b/.github/workflows/fmt.yml index c25d368..511a70c 100644 --- a/.github/workflows/fmt.yml +++ b/.github/workflows/fmt.yml @@ -33,8 +33,8 @@ jobs: - name: Check formatting run: | - if ! nix run nixpkgs#alejandra -- --check .; then - nix run nixpkgs#alejandra -- . + if ! nix run nixpkgs#nixfmt-tree .; then + nix run nixpkgs#nixfmt-tree . git diff exit 1 fi diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml index 8407f60..61120cb 100644 --- a/.github/workflows/nix.yml +++ b/.github/workflows/nix.yml @@ -21,19 +21,24 @@ 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: CCACHE_DIR: ${{ github.workspace }}/.ccache + NIX_SHOW_LOG: "1" steps: - name: Checkout Repo @@ -85,7 +90,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..22ad5ce 100644 --- a/flake.lock +++ b/flake.lock @@ -20,24 +20,41 @@ }, "nixpkgs": { "locked": { - "lastModified": 1748889542, - "narHash": "sha256-Hb4iMhIbjX45GcrgOp3b8xnyli+ysRPqAgZ/LZgyT5k=", + "lastModified": 1763283776, + "narHash": "sha256-Y7TDFPK4GlqrKrivOcsHG8xSGqQx3A6c+i7novT85Uk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "10d7f8d34e5eb9c0f9a0485186c1ca691d2c5922", + "rev": "50a96edd8d0db6cc8db57dab6bb6d6ee1f3dc49a", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-25.05", + "ref": "nixos-unstable", "repo": "nixpkgs", "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..be89948 100644 --- a/flake.nix +++ b/flake.nix @@ -2,40 +2,56 @@ description = "Bitcoin development environment with tools for building, testing, and debugging"; inputs = { - nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + nixpkgs-qt6.url = "github:NixOS/nixpkgs/0c0e48b0ec1af2d7f7de70f839de1569927fe4c8"; flake-utils.url = "github:numtide/flake-utils"; }; - outputs = { - nixpkgs, - flake-utils, - ... - }: - flake-utils.lib.eachDefaultSystem (system: let - pkgs = import nixpkgs {inherit system;}; - isLinux = pkgs.stdenv.isLinux; - isDarwin = pkgs.stdenv.isDarwin; - lib = pkgs.lib; + outputs = + { + nixpkgs, + nixpkgs-qt6, + flake-utils, + ... + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + # 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; - # Configure LLVM and python version for the environment - llvmVersion = "20"; - pythonVersion = "13"; + python = pkgs.python313; + llvmPackages = pkgs.llvmPackages_latest; - llvmPackages = pkgs."llvmPackages_${llvmVersion}"; - llvmTools = { - inherit (llvmPackages) bintools clang clang-tools; - lldb = pkgs."lldb_${llvmVersion}"; - }; + # Use a full llvm toolchain including bintools + stdEnv = + let + llvmStdenv = llvmPackages.stdenv.override { + cc = llvmPackages.stdenv.cc.override { + bintools = llvmPackages.bintools; + }; + }; + in + if isLinux then + # Mold linker is much faster on Linux + pkgs.stdenvAdapters.useMoldLinker (pkgs.ccacheStdenv.override { stdenv = llvmStdenv; }) + else + pkgs.ccacheStdenv.override { stdenv = llvmStdenv; }; - # Helper for platform-specific packages - platformPkgs = cond: pkgs: - if cond - then pkgs - else []; - - # Use a single pythonEnv throughout and specifically in the devShell to make sure bcc is available. - pythonEnv = pkgs."python3${pythonVersion}".withPackages (ps: - with ps; + pythonEnv = python.withPackages ( + ps: + with ps; [ flake8 lief @@ -43,69 +59,76 @@ pyzmq vulture ] - ++ platformPkgs isLinux [ + ++ lib.optionals isLinux [ bcc - ]); + ] + ); + + # Will only exist in the build environment + nativeBuildInputs = + with pkgs; + [ + bison + ccache + clang-tools + cmakeCurses + curlMinimal + ninja + pkg-config + xz + ] + ++ lib.optionals isLinux [ + libsystemtap + linuxPackages.bcc + linuxPackages.bpftrace + ]; - # Will only exist in the build environment - nativeBuildInputs = with pkgs; - [ - bison - ccache - 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 [ - 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; - [ + # 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 ]; - env = { - CMAKE_GENERATOR = "Ninja"; - 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; - }; + mkDevShell = + nativeInputs: buildInputs: + (pkgs.mkShell.override { stdenv = stdEnv; }) { + inherit nativeBuildInputs buildInputs; + packages = [ + pkgs.include-what-you-use + 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"; + }; - formatter = pkgs.alejandra; - }); + in + { + devShells.default = mkDevShell (nativeBuildInputs ++ [ pkgs.qt6.wrapQtAppsHook ]) ( + buildInputs ++ qtBuildInputs + ); + devShells.depends = (mkDevShell nativeBuildInputs qtBuildInputs).overrideAttrs (oldAttrs: { + # Set these to force depends capnp to also use clang, otherwise it + # fails when looking for the default (gcc/g++) + build_CC = "clang"; + build_CXX = "clang++"; + }); + formatter = pkgs.nixfmt-tree; + } + ); } From fd1c4f9d19bf783eaa6e8eaa863f8b1f4349cb6c Mon Sep 17 00:00:00 2001 From: will Date: Thu, 22 Jan 2026 13:43:15 +0000 Subject: [PATCH 02/10] add unstable src, use pkgs.* --- flake.lock | 19 ++++++++++++++++- flake.nix | 62 ++++++++++++++++++++++++++++-------------------------- 2 files changed, 50 insertions(+), 31 deletions(-) diff --git a/flake.lock b/flake.lock index 22ad5ce..ce3206d 100644 --- a/flake.lock +++ b/flake.lock @@ -50,11 +50,28 @@ "type": "github" } }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1768305791, + "narHash": "sha256-AIdl6WAn9aymeaH/NvBj0H9qM+XuAuYbGMZaP0zcXAQ=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "1412caf7bf9e660f2f962917c14b1ea1c3bc695e", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, "root": { "inputs": { "flake-utils": "flake-utils", "nixpkgs": "nixpkgs", - "nixpkgs-qt6": "nixpkgs-qt6" + "nixpkgs-qt6": "nixpkgs-qt6", + "nixpkgs-unstable": "nixpkgs-unstable" } }, "systems": { diff --git a/flake.nix b/flake.nix index be89948..9329e18 100644 --- a/flake.nix +++ b/flake.nix @@ -4,6 +4,7 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nixpkgs-qt6.url = "github:NixOS/nixpkgs/0c0e48b0ec1af2d7f7de70f839de1569927fe4c8"; + nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; }; @@ -11,6 +12,7 @@ { nixpkgs, nixpkgs-qt6, + nixpkgs-unstable, flake-utils, ... }: @@ -20,6 +22,7 @@ # 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; }; + unstablePkgs = import nixpkgs-unstable { inherit system; }; pkgs = import nixpkgs { inherit system; overlays = [ @@ -65,37 +68,35 @@ ); # Will only exist in the build environment - nativeBuildInputs = - with pkgs; - [ - bison - ccache - clang-tools - cmakeCurses - curlMinimal - ninja - pkg-config - xz - ] - ++ lib.optionals isLinux [ - libsystemtap - linuxPackages.bcc - linuxPackages.bpftrace - ]; + nativeBuildInputs = [ + pkgs.bison + pkgs.ccache + pkgs.clang-tools + pkgs.cmakeCurses + pkgs.curlMinimal + pkgs.ninja + pkgs.pkg-config + pkgs.xz + ] + ++ lib.optionals isLinux [ + pkgs.libsystemtap + pkgs.linuxPackages.bcc + pkgs.linuxPackages.bpftrace + ]; - qtBuildInputs = with pkgs; [ - qt6.qtbase # https://nixos.org/manual/nixpkgs/stable/#sec-language-qt - qt6.qttools + qtBuildInputs = [ + pkgs.qt6.qtbase # https://nixos.org/manual/nixpkgs/stable/#sec-language-qt + pkgs.qt6.qttools ]; # Will exist in the runtime environment - buildInputs = with pkgs; [ - boost - capnproto - libevent - qrencode - sqlite.dev - zeromq + buildInputs = [ + pkgs.boost + pkgs.capnproto + pkgs.libevent + pkgs.qrencode + pkgs.sqlite.dev + pkgs.zeromq ]; mkDevShell = @@ -103,10 +104,12 @@ (pkgs.mkShell.override { stdenv = stdEnv; }) { inherit nativeBuildInputs buildInputs; packages = [ - pkgs.include-what-you-use - pythonEnv pkgs.codespell pkgs.hexdump + pkgs.include-what-you-use + pkgs.ruff + unstablePkgs.ty + pythonEnv ] ++ lib.optionals isLinux [ pkgs.gdb ] ++ lib.optionals isDarwin [ llvmPackages.lldb ]; @@ -116,7 +119,6 @@ LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.capnproto ]; LOCALE_ARCHIVE = lib.optionalString isLinux "${pkgs.glibcLocales}/lib/locale/locale-archive"; }; - in { devShells.default = mkDevShell (nativeBuildInputs ++ [ pkgs.qt6.wrapQtAppsHook ]) ( From 62a50c65b9ab953e41d385e0f92d9390a1a6ea5d Mon Sep 17 00:00:00 2001 From: will Date: Thu, 22 Jan 2026 13:43:24 +0000 Subject: [PATCH 03/10] add pycapnp and requests --- flake.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/flake.nix b/flake.nix index 9329e18..f7a17da 100644 --- a/flake.nix +++ b/flake.nix @@ -60,6 +60,8 @@ lief mypy pyzmq + pycapnp + requests vulture ] ++ lib.optionals isLinux [ From aa460277e07c4180c1b7f4ef6cc6597f2fcab70a Mon Sep 17 00:00:00 2001 From: will Date: Thu, 22 Jan 2026 14:03:14 +0000 Subject: [PATCH 04/10] use latest qt from unstable --- flake.lock | 12 ++++++------ flake.nix | 14 +------------- 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/flake.lock b/flake.lock index ce3206d..2ba4817 100644 --- a/flake.lock +++ b/flake.lock @@ -20,11 +20,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1763283776, - "narHash": "sha256-Y7TDFPK4GlqrKrivOcsHG8xSGqQx3A6c+i7novT85Uk=", + "lastModified": 1768886240, + "narHash": "sha256-C2TjvwYZ2VDxYWeqvvJ5XPPp6U7H66zeJlRaErJKoEM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "50a96edd8d0db6cc8db57dab6bb6d6ee1f3dc49a", + "rev": "80e4adbcf8992d3fd27ad4964fbb84907f9478b0", "type": "github" }, "original": { @@ -52,11 +52,11 @@ }, "nixpkgs-unstable": { "locked": { - "lastModified": 1768305791, - "narHash": "sha256-AIdl6WAn9aymeaH/NvBj0H9qM+XuAuYbGMZaP0zcXAQ=", + "lastModified": 1768886240, + "narHash": "sha256-C2TjvwYZ2VDxYWeqvvJ5XPPp6U7H66zeJlRaErJKoEM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1412caf7bf9e660f2f962917c14b1ea1c3bc695e", + "rev": "80e4adbcf8992d3fd27ad4964fbb84907f9478b0", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index f7a17da..0e4522e 100644 --- a/flake.nix +++ b/flake.nix @@ -3,7 +3,6 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - nixpkgs-qt6.url = "github:NixOS/nixpkgs/0c0e48b0ec1af2d7f7de70f839de1569927fe4c8"; nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; }; @@ -11,7 +10,6 @@ outputs = { nixpkgs, - nixpkgs-qt6, nixpkgs-unstable, flake-utils, ... @@ -19,18 +17,8 @@ flake-utils.lib.eachDefaultSystem ( system: let - # 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; }; unstablePkgs = import nixpkgs-unstable { inherit system; }; - pkgs = import nixpkgs { - inherit system; - overlays = [ - (final: prev: { - qt6 = qtPkgs.qt6; - }) - ]; - }; + pkgs = import nixpkgs { inherit system; }; inherit (pkgs) lib; inherit (pkgs.stdenv) isLinux isDarwin; From 6c3cc78f331b48639d08924fa9282ebe6829c801 Mon Sep 17 00:00:00 2001 From: will Date: Thu, 22 Jan 2026 14:04:01 +0000 Subject: [PATCH 05/10] consolidate nixpkgs urls --- flake.lock | 36 +----------------------------------- flake.nix | 5 +---- 2 files changed, 2 insertions(+), 39 deletions(-) diff --git a/flake.lock b/flake.lock index 2ba4817..6714924 100644 --- a/flake.lock +++ b/flake.lock @@ -34,44 +34,10 @@ "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" - } - }, - "nixpkgs-unstable": { - "locked": { - "lastModified": 1768886240, - "narHash": "sha256-C2TjvwYZ2VDxYWeqvvJ5XPPp6U7H66zeJlRaErJKoEM=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "80e4adbcf8992d3fd27ad4964fbb84907f9478b0", - "type": "github" - }, - "original": { - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" - } - }, "root": { "inputs": { "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs", - "nixpkgs-qt6": "nixpkgs-qt6", - "nixpkgs-unstable": "nixpkgs-unstable" + "nixpkgs": "nixpkgs" } }, "systems": { diff --git a/flake.nix b/flake.nix index 0e4522e..99e54e9 100644 --- a/flake.nix +++ b/flake.nix @@ -3,21 +3,18 @@ inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; - nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { nixpkgs, - nixpkgs-unstable, flake-utils, ... }: flake-utils.lib.eachDefaultSystem ( system: let - unstablePkgs = import nixpkgs-unstable { inherit system; }; pkgs = import nixpkgs { inherit system; }; inherit (pkgs) lib; inherit (pkgs.stdenv) isLinux isDarwin; @@ -98,7 +95,7 @@ pkgs.hexdump pkgs.include-what-you-use pkgs.ruff - unstablePkgs.ty + pkgs.ty pythonEnv ] ++ lib.optionals isLinux [ pkgs.gdb ] From ee8a19db4d3697d2e10af6552a137beed939e0ab Mon Sep 17 00:00:00 2001 From: will Date: Thu, 22 Jan 2026 14:11:21 +0000 Subject: [PATCH 06/10] use native bintools on MacOS The flake previously used llvmPackages.bintools on macOS, which brings in LLVM's lld linker. Apple's toolchain expects its native linker (ld64) with flags like -arch, -platform_version, -syslibroot, etc., which lld doesn't support. --- flake.nix | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/flake.nix b/flake.nix index 99e54e9..0d64500 100644 --- a/flake.nix +++ b/flake.nix @@ -22,17 +22,19 @@ python = pkgs.python313; llvmPackages = pkgs.llvmPackages_latest; - # Use a full llvm toolchain including bintools stdEnv = let - llvmStdenv = llvmPackages.stdenv.override { - cc = llvmPackages.stdenv.cc.override { - bintools = llvmPackages.bintools; - }; - }; + llvmStdenv = + if isLinux then + llvmPackages.stdenv.override { + cc = llvmPackages.stdenv.cc.override { + bintools = llvmPackages.bintools; + }; + } + else + llvmPackages.stdenv; in if isLinux then - # Mold linker is much faster on Linux pkgs.stdenvAdapters.useMoldLinker (pkgs.ccacheStdenv.override { stdenv = llvmStdenv; }) else pkgs.ccacheStdenv.override { stdenv = llvmStdenv; }; From 397c29d320bf1cd205ce07b3eacffbb2b13198c9 Mon Sep 17 00:00:00 2001 From: will Date: Thu, 22 Jan 2026 14:22:03 +0000 Subject: [PATCH 07/10] disable hardening on Darwin --- flake.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/flake.nix b/flake.nix index 0d64500..e1f37e4 100644 --- a/flake.nix +++ b/flake.nix @@ -92,6 +92,7 @@ nativeInputs: buildInputs: (pkgs.mkShell.override { stdenv = stdEnv; }) { inherit nativeBuildInputs buildInputs; + hardeningDisable = lib.optionals isDarwin [ "stackclashprotection" ]; packages = [ pkgs.codespell pkgs.hexdump From a0cd1e1443fefafc453e7665b8d151a75a35fa2a Mon Sep 17 00:00:00 2001 From: will Date: Thu, 29 Jan 2026 10:46:14 +0000 Subject: [PATCH 08/10] overlay capnproto 1.3.0 while waiting on nixpkgs --- flake.nix | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index e1f37e4..0fd7bb2 100644 --- a/flake.nix +++ b/flake.nix @@ -15,7 +15,23 @@ flake-utils.lib.eachDefaultSystem ( system: let - pkgs = import nixpkgs { inherit system; }; + pkgs = import nixpkgs { + inherit system; + overlays = [ + (final: prev: { + capnproto = prev.capnproto.overrideAttrs (oldAttrs: rec { + version = "1.3.0"; + src = prev.fetchFromGitHub { + owner = "capnproto"; + repo = "capnproto"; + rev = "v${version}"; + hash = "sha256-fvZzNDBZr73U+xbj1LhVj1qWZyNmblKluh7lhacV+6I="; + }; + patches = [ ]; + }); + }) + ]; + }; inherit (pkgs) lib; inherit (pkgs.stdenv) isLinux isDarwin; From 4e5211d72c176b22a0261581f675fc9070c0ae78 Mon Sep 17 00:00:00 2001 From: will Date: Mon, 2 Feb 2026 21:19:55 +0000 Subject: [PATCH 09/10] add clang-tidy-diff --- flake.nix | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/flake.nix b/flake.nix index 0fd7bb2..f0e2ebc 100644 --- a/flake.nix +++ b/flake.nix @@ -38,6 +38,25 @@ python = pkgs.python313; llvmPackages = pkgs.llvmPackages_latest; + clang-tidy-diff = + pkgs.runCommand "clang-tidy-diff" + { + nativeBuildInputs = [ pkgs.makeWrapper ]; + } + '' + mkdir -p $out/bin + cp ${llvmPackages.clang-unwrapped.src}/clang-tools-extra/clang-tidy/tool/clang-tidy-diff.py \ + $out/bin/clang-tidy-diff + chmod +x $out/bin/clang-tidy-diff + wrapProgram $out/bin/clang-tidy-diff \ + --prefix PATH : ${ + lib.makeBinPath [ + pkgs.clang-tools + pythonEnv + ] + } + ''; + stdEnv = let llvmStdenv = @@ -110,6 +129,7 @@ inherit nativeBuildInputs buildInputs; hardeningDisable = lib.optionals isDarwin [ "stackclashprotection" ]; packages = [ + clang-tidy-diff pkgs.codespell pkgs.hexdump pkgs.include-what-you-use From 69c4767cf340686fae3e17f2b94cfacfcb59046a Mon Sep 17 00:00:00 2001 From: will Date: Thu, 12 Feb 2026 15:16:16 +0000 Subject: [PATCH 10/10] add valgrind and use nativeInputs correctly in devshell --- flake.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/flake.nix b/flake.nix index f0e2ebc..fcf531c 100644 --- a/flake.nix +++ b/flake.nix @@ -126,7 +126,8 @@ mkDevShell = nativeInputs: buildInputs: (pkgs.mkShell.override { stdenv = stdEnv; }) { - inherit nativeBuildInputs buildInputs; + nativeBuildInputs = nativeInputs; + inherit buildInputs; hardeningDisable = lib.optionals isDarwin [ "stackclashprotection" ]; packages = [ clang-tidy-diff @@ -137,7 +138,10 @@ pkgs.ty pythonEnv ] - ++ lib.optionals isLinux [ pkgs.gdb ] + ++ lib.optionals isLinux [ + pkgs.gdb + pkgs.valgrind + ] ++ lib.optionals isDarwin [ llvmPackages.lldb ]; CMAKE_GENERATOR = "Ninja"; @@ -147,8 +151,8 @@ }; in { - devShells.default = mkDevShell (nativeBuildInputs ++ [ pkgs.qt6.wrapQtAppsHook ]) ( - buildInputs ++ qtBuildInputs + devShells.default = mkDevShell nativeBuildInputs ( + buildInputs ++ qtBuildInputs ++ [ pkgs.qt6.wrapQtAppsHook ] ); devShells.depends = (mkDevShell nativeBuildInputs qtBuildInputs).overrideAttrs (oldAttrs: { # Set these to force depends capnp to also use clang, otherwise it