mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-03-13 11:36:15 +01:00
Merge f034408a7c
into 40b1ac351f
This commit is contained in:
commit
5b9c109d87
3 changed files with 308 additions and 0 deletions
56
README_NIX.adoc
Normal file
56
README_NIX.adoc
Normal file
|
@ -0,0 +1,56 @@
|
|||
= bitcoinj Nix ReadMe
|
||||
|
||||
These instructions are for a work-in-progress `flake.nix` file. They assume you have `experimental-features = nix-command flakes` enabled. For information about **Nix** see the https://nixos.org[Nix & NixOS] website.
|
||||
|
||||
Known issues:
|
||||
|
||||
1. The builds are currently using the "escape hatch" method and should be using something like `gradle2nix`.
|
||||
2. There should be a separate target to install `bitcoinj-core` and possibly for some of the other module and dependency JARs.
|
||||
3. As a result of the above two issues there is a conflict if you install both applications. It can be resolved with the `--priority` option see the note below.
|
||||
|
||||
== To start and use a development shell
|
||||
|
||||
From the project root directory type:
|
||||
|
||||
* `nix develop`
|
||||
|
||||
From within the launched shell, you can use commands like:
|
||||
|
||||
* `gradle build`
|
||||
* `gradle bitcoinj-wallettool:run --args="--help"`
|
||||
* `gradle bitcoinj-wallettemplate:run`
|
||||
|
||||
|
||||
== To run applications directly
|
||||
|
||||
From the project root directory type:
|
||||
|
||||
* `nix run .#wallettool -- --help`
|
||||
* `nix run .#wallettemplate`
|
||||
|
||||
== To install and run applications
|
||||
|
||||
From the project root directory type:
|
||||
|
||||
. `nix profile install .#wallettool`
|
||||
. `wallet-tool --help`
|
||||
|
||||
and/or
|
||||
|
||||
. `nix profile install .#wallettemplate --priority 4`
|
||||
. `bitcoinj-wallettemplate`
|
||||
|
||||
NOTE:: The `--priority 4` option above is to avoid the following known issue:
|
||||
+
|
||||
```
|
||||
error: An existing package already provides the following file:
|
||||
|
||||
/nix/store/kgchs2a7g0ik2ybwc2v0k9iq4i04sarh-wallettool-0.0.1/share/vanilla/lib/slf4j-jdk14-2.0.9.jar
|
||||
|
||||
This is the conflicting file from the new package:
|
||||
|
||||
/nix/store/9b4517xgawvig9fxyf8vxay2nzbmmvq2-wallettemplate-0.0.1/share/vanilla/lib/slf4j-jdk14-2.0.9.jar
|
||||
```
|
||||
|
||||
|
||||
|
90
flake.lock
generated
Normal file
90
flake.lock
generated
Normal file
|
@ -0,0 +1,90 @@
|
|||
{
|
||||
"nodes": {
|
||||
"devshell": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1735644329,
|
||||
"narHash": "sha256-tO3HrHriyLvipc4xr+Ewtdlo7wM1OjXNjlWRgmM7peY=",
|
||||
"owner": "numtide",
|
||||
"repo": "devshell",
|
||||
"rev": "f7795ede5b02664b57035b3b757876703e2c3eac",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "devshell",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-parts": {
|
||||
"inputs": {
|
||||
"nixpkgs-lib": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1736143030,
|
||||
"narHash": "sha256-+hu54pAoLDEZT9pjHlqL9DNzWz0NbUn8NEAHP7PQPzU=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"rev": "b905f6fc23a9051a6e1b741e1438dbfc0634c6de",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "flake-parts",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"gitignore": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1709087332,
|
||||
"narHash": "sha256-HG2cCnktfHsKV0s4XW83gU3F57gaTljL9KNSuG6bnQs=",
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"rev": "637db329424fd7e46cf4185293b9cc8c88c95394",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "hercules-ci",
|
||||
"repo": "gitignore.nix",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1738142207,
|
||||
"narHash": "sha256-NGqpVVxNAHwIicXpgaVqJEJWeyqzoQJ9oc8lnK9+WC4=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "9d3ae807ebd2981d593cddd0080856873139aa40",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"devshell": "devshell",
|
||||
"flake-parts": "flake-parts",
|
||||
"gitignore": "gitignore",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
162
flake.nix
Normal file
162
flake.nix
Normal file
|
@ -0,0 +1,162 @@
|
|||
{
|
||||
description = "bitcoinj";
|
||||
|
||||
# this allows derivations with `__noChroot = true` and allows us to work around limitations with gradle
|
||||
# see https://zimbatm.com/notes/nix-packaging-the-heretic-way
|
||||
nixConfig.sandbox = "relaxed";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
|
||||
flake-parts = {
|
||||
url = "github:hercules-ci/flake-parts";
|
||||
inputs.nixpkgs-lib.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
gitignore = {
|
||||
url = "github:hercules-ci/gitignore.nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
devshell = {
|
||||
url = "github:numtide/devshell";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = inputs @ {
|
||||
flake-parts,
|
||||
devshell,
|
||||
gitignore,
|
||||
...
|
||||
}:
|
||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||
systems = [
|
||||
"x86_64-linux"
|
||||
"x86_64-darwin"
|
||||
"aarch64-linux"
|
||||
"aarch64-darwin"
|
||||
];
|
||||
|
||||
perSystem = {
|
||||
config,
|
||||
inputs',
|
||||
pkgs,
|
||||
lib,
|
||||
system,
|
||||
...
|
||||
}: let
|
||||
inherit (pkgs) stdenv;
|
||||
|
||||
# pick our jdk and gradle versions
|
||||
jdk = pkgs.jdk21.override {
|
||||
# enabling JavaFX in the JDK allows `nix run .#wallettemplate` to work correctly.
|
||||
# This is because the `bitcoinj-wallettemplate:installDist` Gradle task does
|
||||
# not set up the Module Path correctly for JavaFX to be loaded from a Maven JAR.
|
||||
enableJavaFX = true;
|
||||
};
|
||||
gradle = pkgs.gradle;
|
||||
|
||||
in {
|
||||
# define a devshell
|
||||
devShells.default = inputs'.devshell.legacyPackages.mkShell {
|
||||
# setup some environment variables
|
||||
env = with lib;
|
||||
mkMerge [
|
||||
[
|
||||
# Configure nix to use nixpgks
|
||||
{
|
||||
name = "NIX_PATH";
|
||||
value = "nixpkgs=${toString pkgs.path}";
|
||||
}
|
||||
]
|
||||
(mkIf stdenv.isLinux [
|
||||
{
|
||||
name = "JAVA_HOME";
|
||||
eval = "$DEVSHELL_DIR/lib/openjdk";
|
||||
}
|
||||
])
|
||||
(mkIf stdenv.isDarwin [
|
||||
{
|
||||
name = "JAVA_HOME";
|
||||
# TODO: Fix this so it isn't hardcoded to "zulu".
|
||||
# I think it should be computed from `jdk` somehow.
|
||||
eval = "$DEVSHELL_DIR/zulu-17.jdk/Contents/Home";
|
||||
}
|
||||
])
|
||||
];
|
||||
|
||||
# add package dependencies
|
||||
packages = with lib;
|
||||
mkMerge [
|
||||
[
|
||||
jdk
|
||||
gradle
|
||||
]
|
||||
];
|
||||
};
|
||||
|
||||
# define flake output packages
|
||||
packages = let
|
||||
# useful for filtering src trees based on gitignore
|
||||
inherit (gitignore.lib) gitignoreSource;
|
||||
|
||||
# common properties across the derivations
|
||||
version = "0.0.1";
|
||||
src = gitignoreSource ./.;
|
||||
in {
|
||||
# This package is an example of an escape hatch
|
||||
wallettool = stdenv.mkDerivation {
|
||||
pname = "wallettool";
|
||||
inherit version src;
|
||||
|
||||
# Disable the Nix build sandbox for this specific build.
|
||||
# This means the build can freely talk to the Internet.
|
||||
__noChroot = true;
|
||||
|
||||
nativeBuildInputs = [gradle pkgs.makeWrapper];
|
||||
|
||||
buildPhase = ''
|
||||
export GRADLE_USER_HOME=$(mktemp -d)
|
||||
gradle --no-daemon bitcoinj-wallettool:installDist
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/share/vanilla
|
||||
cp -r wallettool/build/install/wallet-tool/* $out/share/vanilla
|
||||
makeWrapper $out/share/vanilla/bin/wallet-tool $out/bin/wallet-tool \
|
||||
--set JAVA_HOME ${jdk}
|
||||
'';
|
||||
|
||||
meta.mainProgram = "wallet-tool";
|
||||
};
|
||||
|
||||
# This package is an example of an escape hatch
|
||||
wallettemplate = stdenv.mkDerivation {
|
||||
pname = "wallettemplate";
|
||||
inherit version src;
|
||||
|
||||
# Disable the Nix build sandbox for this specific build.
|
||||
# This means the build can freely talk to the Internet.
|
||||
__noChroot = true;
|
||||
|
||||
nativeBuildInputs = [gradle pkgs.makeWrapper];
|
||||
|
||||
buildPhase = ''
|
||||
export GRADLE_USER_HOME=$(mktemp -d)
|
||||
gradle --no-daemon bitcoinj-wallettemplate:installDist
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/share/vanilla
|
||||
cp -r wallettemplate/build/install/bitcoinj-wallettemplate/* $out/share/vanilla
|
||||
makeWrapper $out/share/vanilla/bin/bitcoinj-wallettemplate $out/bin/bitcoinj-wallettemplate \
|
||||
--set JAVA_HOME ${jdk}
|
||||
'';
|
||||
|
||||
meta.mainProgram = "bitcoinj-wallettemplate";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Add table
Reference in a new issue