nix-bitcoin/examples/container/usage.sh
Erik Arvstedt b8f6343ee4
fix test persistentContainerExample
This test requires `electrs` to be enabled.

Also, by using `electrs` instead of `clightning` we avoid the bug
where clightning hangs at startup when internet access is unavailable.
Due to technical limititations, internet access is available in NixOS
containers only after the container has started.
2025-01-22 20:41:52 +01:00

47 lines
2.1 KiB
Bash

# Requirements:
# - A systemd-based Linux distro
# - extra-container (https://github.com/erikarvstedt/extra-container/#install)
# - Nix
# - Root privileges
#―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Create container
# Create and start container defined by ./flake.nix
nix run . -- create --start
# You can use the same command to update the (running) container,
# after changing the container configuration.
# In the default configuration, the container is automatically started on
# system boot (option `autoStart`).
#―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Use container
# Run command in container
extra-container run mynode -- hostname
extra-container run mynode -- systemctl status bitcoind
extra-container run mynode -- bitcoin-cli -getinfo
extra-container run mynode -- bash -c 'bitcoin-cli -getinfo && systemctl status electrs'
# Start shell in container
extra-container root-login mynode
# Show the container filesystem
sudo ls -al /var/lib/nixos-containers/mynode
#―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Stop container
extra-container stop mynode
# Resume the container
extra-container start mynode
# You can also use the `create --start` command above
# Destroy container
extra-container destroy mynode
#―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――
# Inspect container config
nix eval .#default.outPath
nix eval . --apply 'sys: sys.containers.mynode.config.networking.hostName'