Jonas Nick 739fa36785
Merge fort-nix/nix-bitcoin#508: More NixOS 22.05 fixes
7261813051c0ea92c603570c21ddd8a680facace examples/configuration.nix: use `system.stateVersion` comment from NixOS 22.05 (Erik Arvstedt)
2ae2eea54e127310612bf0f9fadf269b584eec98 run-tests: fix command `debug` on NixOS 22.05 (Erik Arvstedt)
a8255d61d711af06d019e1859fe3cb103a3a16ed lib/make-container: update required extra-container version (Erik Arvstedt)
f02f27cbcacfa23d9d3c8ab3125078248a8d202e lib/make-test: fix `system.stateVersion` warning (Erik Arvstedt)

Pull request description:

ACKs for top commit:
  jonasnick:
    ACK 7261813051c0ea92c603570c21ddd8a680facace

Tree-SHA512: ae6d15092666187dfb9eca6a307ee2533446e49265390315b74d00b848b072339e522308ed88751d09631cc064c0f7fd34084add38ca52c130153a4ebc527549
2022-07-05 10:13:10 +00:00
..
2022-06-01 22:12:47 +02:00
2022-06-28 00:09:26 +02:00
2022-06-28 00:09:26 +02:00
2022-06-28 00:09:26 +02:00
2022-06-02 14:06:54 +02:00

Examples

The easiest way to try out nix-bitcoin is to use one of the provided examples.

Flakes-based quick start

If you use a Flakes-enabled version of Nix, run the following command to start a minimal nix-bitcoin QEMU VM:

nix run github:fort-nix/nix-bitcoin/release

The VM (defined in flake.nix) runs in the terminal and has bitcoind and clightning installed.
It leaves no traces (outside of /nix/store) on the host system.

More examples

Clone this repo and enter the examples shell:

git clone https://github.com/fort-nix/nix-bitcoin
cd nix-bitcoin/examples/
nix-shell

The following example scripts set up a nix-bitcoin node according to configuration.nix and then shut down immediately. They leave no traces (outside of /nix/store) on the host system.
By default, configuration.nix enables bitcoind and clightning.

Run the examples with option --interactive or -i to start a shell for interacting with the node:

./deploy-qemu-vm.sh -i

Tests

The internal test suite is also useful for exploring features.
The following run-tests.sh commands leave no traces (outside of /nix/store) on the host system.

git clone https://github.com/fort-nix/nix-bitcoin
cd nix-bitcoin/test

# Run a node in a VM. No tests are executed.
./run-tests.sh vm
systemctl status bitcoind

# Run a Python test shell inside a VM node
./run-tests.sh debug
print(succeed("systemctl status bitcoind"))
run_test("bitcoind")

# Run a node in a container. Requires systemd and root privileges.
./run-tests.sh container
c systemctl status bitcoind

# Explore a single feature
./run-tests.sh --scenario electrs container

# Run a command in a container
./run-tests.sh --scenario '{
  services.clightning.enable = true;
  nix-bitcoin.nodeinfo.enable = true;
}' container --run c nodeinfo

See run-tests.sh for a complete documentation.

Real-world example

Check the server repo for https://nixbitcoin.org to see the configuration of a nix-bitcoin node that's used in production.

The commands in shell.nix allow you to locally run the node in a VM or container.

Flakes

Flakes make it easy to include nix-bitcoin in an existing NixOS config. The flakes example shows how to use nix-bitcoin as an input to a system flake.