Skip to content

Instantly share code, notes, and snippets.

@willcl-ark
Created April 25, 2025 10:53
Show Gist options
  • Save willcl-ark/03a3ea02b70838209eb4bccf83432d47 to your computer and use it in GitHub Desktop.
Save willcl-ark/03a3ea02b70838209eb4bccf83432d47 to your computer and use it in GitHub Desktop.
bitcoin deve flake
{
description = "Bitcoin development environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
nixpkgs-2022.url = "github:NixOS/nixpkgs?rev=028048884dc9517e548703beb24a11408cc51402"; # For boost 1.81.0, libevent 2.1.12, qrencode 4.1.1, zeromq 4.3.5
nixpkgs-lief.url = "github:NixOS/nixpkgs?rev=47c1824c261a343a6acca36d168a0a86f0e66292"; # lief 0.13.2
nixpkgs-sqlite.url = "github:NixOS/nixpkgs?rev=f597e7e9fcf37d8ed14a12835ede0a7d362314bd"; # sqlite 3.38.5
nixpkgs-fontconfig.url = "github:NixOS/nixpkgs?rev=136a26be29a9daa04e5f15ee7694e9e92e5a028c"; # fontconfig 2.12.6
nixpkgs-freetype.url = "github:NixOS/nixpkgs?rev=fadaef5aedb6b35681248f8c6096083b2efeb284"; # freetype 2.11.0
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, nixpkgs-lief, nixpkgs-2022, nixpkgs-sqlite, nixpkgs-fontconfig, nixpkgs-freetype, flake-utils, ... }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
pkgs-2022 = import nixpkgs-2022 { inherit system; };
pkgs-lief = import nixpkgs-lief { inherit system; };
pkgs-sqlite = import nixpkgs-sqlite { inherit system; };
pkgs-fontconfig = import nixpkgs-fontconfig { inherit system; };
pkgs-freetype = import nixpkgs-freetype { inherit system; };
lib = pkgs.lib;
isLinux = pkgs.stdenv.isLinux;
binDirs = [ "./build/bin" "./build/bin/qt" ];
# Common dependencies for all platforms
commonNativeBuildInputs = with pkgs; [
byacc
ccache
clang-tools_19
clang_19
cmake
gnum4
gnumake
mold-wrapped
ninja
pkg-config
];
# Linux-specific dependencies
linuxNativeBuildInputs = with pkgs; [
libsystemtap
linuxPackages.bcc
linuxPackages.bpftrace
];
# Combine dependencies based on platform
nativeBuildInputs = commonNativeBuildInputs ++ (if isLinux then linuxNativeBuildInputs else []);
# Pinned dependencies from specific nixpkgs commits
pinnedDeps = {
boost = pkgs-2022.boost;
capnproto = pkgs.capnproto;
codespell = pkgs.codespell;
db4 = pkgs.db4;
flake8 = pkgs.python311Packages.flake8;
fontconfig = pkgs-fontconfig.fontconfig;
freetype = pkgs-freetype.freetype;
gdb = pkgs.gdb;
hexdump = pkgs.util-linux;
libevent = pkgs-2022.libevent;
lief = pkgs-lief.python311Packages.lief;
mypy = pkgs.python311Packages.mypy;
pyzmq = pkgs.python311Packages.pyzmq;
qrencode = pkgs-2022.qrencode;
qtbase = pkgs.qt6.qtbase;
qttools = pkgs.qt6.qttools;
sqlite = pkgs-sqlite.sqlite;
uv = pkgs.uv;
vulture = pkgs.python311Packages.vulture;
zeromq = pkgs-2022.zeromq;
};
# Common runtime dependencies
buildInputs = with pinnedDeps; [
boost
capnproto
codespell
db4
flake8
fontconfig
freetype
gdb
hexdump
libevent
lief
mypy
pyzmq
qrencode
qtbase
qttools
sqlite
uv
vulture
zeromq
];
# Platform-specific shell hook
shellHook = ''
${if isLinux then ''
BCC_EGG=${pkgs.linuxPackages.bcc}/${pkgs.python3.sitePackages}/bcc-${pkgs.linuxPackages.bcc.version}-py3.${pkgs.python3.sourceVersion.minor}.egg
if [ -f $BCC_EGG ]; then
export PYTHONPATH="$PYTHONPATH:$BCC_EGG"
else
echo "Warning: The bcc egg $BCC_EGG does not exist. Skipping bcc PYTHONPATH setup."
fi
'' else ""}
# Add output build dir to $PATH
export PATH=${builtins.concatStringsSep ":" binDirs}:$PATH
'';
in
{
devShells.default = pkgs.mkShell {
CC = "clang";
CMAKE_GENERATOR = "Ninja";
CXX = "clang++";
LDFLAGS = "-fuse-ld=mold";
LD_LIBRARY_PATH = lib.makeLibraryPath [ pkgs.stdenv.cc.cc pkgs.capnproto ];
LOCALE_ARCHIVE = "${pkgs.glibcLocales}/lib/locale/locale-archive";
inherit nativeBuildInputs buildInputs shellHook;
};
}
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment