-
Notifications
You must be signed in to change notification settings - Fork 10
Refactor bitcoind.nix to fetch pre-built binaries based on platform d… #38
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,34 +1,54 @@ | ||
| { | ||
| pkgs, | ||
| lib, | ||
| stdenv, | ||
| ... | ||
| }: let | ||
| src = pkgs.fetchFromGitHub { | ||
| owner = "Sjors"; | ||
| repo = "bitcoin"; | ||
| rev = "b4eb739e5d76e2b62fd37bae5da8acfa75484879"; | ||
| hash = "sha256-vRPVOjGt1bYQUWZycweaYI6y22O1K1QAaCh5u3rfP6Q="; | ||
| # Detect platform and OS | ||
| platform = if stdenv.isDarwin then | ||
| if stdenv.isAarch64 then "arm64-apple-darwin-unsigned" else "x86_64-apple-darwin-unsigned" | ||
| else if stdenv.isLinux then | ||
| if stdenv.isx86_64 then "x86_64-linux-gnu" else "aarch64-linux-gnu" | ||
| else throw "Unsupported platform"; | ||
|
|
||
| # Construct the appropriate binary URL | ||
| binaryUrl = "https://github.com/Sjors/bitcoin/releases/download/sv2-tp-0.1.17/bitcoin-sv2-tp-0.1.17-${platform}.tar.gz"; | ||
|
|
||
| # Fetch the pre-built binary | ||
| binary = pkgs.fetchurl { | ||
| url = binaryUrl; | ||
| hash = "sha256-fq38pBiLmq14+tqlYBlIT/L1Zo+HyhGYMu1wh9KiDkc="; | ||
| }; | ||
| in | ||
| pkgs.bitcoind.overrideAttrs (oldAttrs: { | ||
| pkgs.stdenv.mkDerivation { | ||
| name = "bitcoind-sv2"; | ||
| src = src; | ||
| version = "0.1.17"; | ||
| src = binary; | ||
|
|
||
| nativeBuildInputs = [ pkgs.gnutar pkgs.gzip ]; | ||
|
|
||
| sourceRoot = "bitcoin-sv2-tp-0.1.17"; | ||
|
|
||
| dontBuild = true; | ||
| dontConfigure = true; | ||
|
|
||
| installPhase = '' | ||
| mkdir -p $out | ||
| cp -r bin share $out/ | ||
| '' + lib.optionalString stdenv.isDarwin '' | ||
| # Code sign the binaries on macOS | ||
| /usr/bin/codesign -s - $out/bin/bitcoind | ||
| /usr/bin/codesign -s - $out/bin/bitcoin-cli | ||
| ''; | ||
|
|
||
| installCheckPhase = '' | ||
| OUTPUT=$(${pkgs.bitcoind}/bin/bitcoin-cli --version || true) | ||
| echo "Bitcoin CLI Version Output: $OUTPUT" | ||
| echo "Skipping strict version check..." | ||
| $out/bin/bitcoin-cli --version | ||
| ''; | ||
|
|
||
| # Modify build settings | ||
| nativeBuildInputs = lib.lists.drop 1 oldAttrs.nativeBuildInputs ++ [pkgs.cmake]; | ||
| postInstall = ""; | ||
| cmakeFlags = [ | ||
| (lib.cmakeBool "WITH_SV2" true) | ||
| (lib.cmakeBool "BUILD_BENCH" true) | ||
| (lib.cmakeBool "BUILD_TESTS" true) | ||
| (lib.cmakeBool "ENABLE_WALLET" false) | ||
| (lib.cmakeBool "BUILD_GUI" false) | ||
| (lib.cmakeBool "BUILD_GUI_TESTS" false) | ||
| ]; | ||
| }) | ||
| meta = { | ||
| description = "Bitcoin SV2 Template Provider"; | ||
| homepage = "https://github.com/Sjors/bitcoin"; | ||
| license = lib.licenses.mit; | ||
| platforms = lib.platforms.darwin ++ lib.platforms.linux; | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why use bash to update bitcoin.conf? You can edit it directly at
/bitcoind.conf.