Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add devenv or nix shell #81

Open
matthiasdebernardini opened this issue Jul 16, 2024 · 0 comments
Open

add devenv or nix shell #81

matthiasdebernardini opened this issue Jul 16, 2024 · 0 comments

Comments

@matthiasdebernardini
Copy link

Kinda hard to guess which versions this crate works with, would be great to provide a devenv.nix or nix shell that builds the specific versions that its expecting and use that rather than installing and downloading things separately (I couldn't get it to work on macos).

Once I get this to work, I'm happy to submit that

{ pkgs, lib, config, inputs, ... }:

let
  customBitcoind = pkgs.callPackage ./bitcoind.nix {};
in
{
  env.DATABASE_URL="postgres";

 packages = [
    pkgs.git
    pkgs.just
    pkgs.openssl
    pkgs.cargo-nextest
    pkgs.hurl
    pkgs.sqlx-cli
    pkgs.tailwindcss
    pkgs.cargo-watch
    pkgs.electrs
    customBitcoind
  ] ++ lib.optionals pkgs.stdenv.isDarwin (with pkgs.darwin.apple_sdk; [
    frameworks.CoreFoundation
    frameworks.Security
    frameworks.SystemConfiguration
  ]);

  enterShell = ''
    git --version
    cargo --version
    alias c="cargo"
    bitcoind --version  # Check Bitcoin Core version
    export BITCOIND_EXE=$(which bitcoind)
    echo $BITCOIND_EXE
    export ELECTRS_EXEC=$(which electrs)
    echo $ELECTRS_EXEC
  '';

  # https://devenv.sh/pre-commit-hooks/
  pre-commit.hooks = {
    clippy.enable = true;
    cargo-check.enable = true;
    rustfmt.enable = true;
  };

  # https://devenv.sh/languages/
  languages.nix.enable = true;
  languages.rust = {
    enable = true;
    channel = "stable";
  };

  services.postgres = {
    enable = true;
    # initialDatabases = [{ name = "keel"; }];
  };
}
{ lib
, stdenv
, fetchurl
, pkg-config
, autoreconfHook
, boost
, libevent
, miniupnpc
, zeromq
, zlib
, db48
, sqlite
, qrencode
, python3
, util-linux
, darwin
}:

stdenv.mkDerivation rec {
  pname = "bitcoind";
  version = "25.0";

  src = fetchurl {
    url = "https://bitcoincore.org/bin/bitcoin-core-${version}/bitcoin-${version}.tar.gz";
    sha256 = "sha256-XfZ89CyjuaDDjNr+xbu1F9pbWNJR8yyNKkdRH5vh68I=";
  };

  nativeBuildInputs = [ pkg-config autoreconfHook ];
  buildInputs = [
    boost
    libevent
    miniupnpc
    zeromq
    zlib
    db48
    sqlite
    qrencode
    python3
    util-linux
  ] ++ lib.optionals stdenv.isDarwin [ darwin.apple_sdk.frameworks.Foundation ];

  configureFlags = [
    "--with-boost-libdir=${boost.out}/lib"
    "--disable-bench"
    "--disable-tests"
    "--disable-gui-tests"
    "--disable-fuzz-binary"
  ];

  enableParallelBuilding = true;

  meta = with lib; {
    description = "Bitcoin Core daemon";
    longDescription = ''
      Bitcoin is a free open source peer-to-peer electronic cash system that is
      completely decentralized, without the need for a central server or trusted
      parties. Users hold the crypto keys to their own money and transact directly
      with each other, with the help of a P2P network to check for double-spending.
    '';
    homepage = "https://bitcoincore.org/";
    maintainers = with maintainers; [ roconnor ];
    license = licenses.mit;
    platforms = platforms.unix;
  };
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant