-
Notifications
You must be signed in to change notification settings - Fork 107
/
flake.nix
70 lines (55 loc) · 2.42 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# See how this flake is used in ./usage.sh
# See also:
# https://github.com/erikarvstedt/extra-container
# https://github.com/erikarvstedt/extra-container/blob/master/examples/flake
# Container-related NixOS options
# https://search.nixos.org/options?channel=unstable&query=containers.%3Cname%3E
{
description = "A basic nix-bitcoin container node";
inputs = {
nix-bitcoin.url = "github:fort-nix/nix-bitcoin/release";
# You can also use a version branch to track a specific NixOS release
# nix-bitcoin.url = "github:fort-nix/nix-bitcoin/nixos-23.05";
nixpkgs.follows = "nix-bitcoin/nixpkgs";
nixpkgs-unstable.follows = "nix-bitcoin/nixpkgs-unstable";
extra-container.follows = "nix-bitcoin/extra-container";
};
outputs = { nixpkgs, nix-bitcoin, extra-container, ... }:
extra-container.lib.eachSupportedSystem (system: {
packages.default = extra-container.lib.buildContainers {
inherit system;
# The container uses the nixpkgs from `nix-bitcoin.inputs.nixpkgs` by default
# Only set this if the `system.stateVersion` of your container
# host is < 22.05
# legacyInstallDirs = true;
config = {
containers.mynode = {
# Always start container along with the container host
autoStart = true;
# This assigns the following addresses:
# Host IP: 10.250.0.1
# Container IP: 10.250.0.2
extra.addressPrefix = "10.250.0";
# Enable internet access for the container
extra.enableWAN = true;
# Map `/my/host/dir` to `/my/mount` in the container
# bindMounts."/my/mount" = { hostPath = "/my/host/dir"; isReadOnly = false; };
# Setup port forwarding
# forwardPorts = [ { containerPort = 80; hostPort = 8080; protocol = "tcp";} ];
config = { config, pkgs, ... }: {
imports = [
nix-bitcoin.nixosModules.default
];
# Automatically generate all secrets required by services.
# The secrets are stored in /etc/nix-bitcoin-secrets in the container
nix-bitcoin.generateSecrets = true;
# Enable some services.
# See ../configuration.nix for all available features.
services.bitcoind.enable = true;
services.electrs.enable = true;
};
};
};
};
});
}