2021-08-16 01:42:07 -07:00
|
|
|
{
|
|
|
|
description = ''
|
|
|
|
A collection of Nix packages and NixOS modules for easily
|
|
|
|
installing full-featured Bitcoin nodes with an emphasis on security.
|
|
|
|
'';
|
|
|
|
|
|
|
|
inputs = {
|
2022-12-18 04:13:42 -08:00
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.11";
|
2022-10-22 10:37:53 -07:00
|
|
|
nixpkgs-unstable.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
2021-08-16 01:42:07 -07:00
|
|
|
flake-utils.url = "github:numtide/flake-utils";
|
2022-10-22 10:37:58 -07:00
|
|
|
extra-container = {
|
|
|
|
url = "github:erikarvstedt/extra-container";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
inputs.flake-utils.follows = "flake-utils";
|
|
|
|
};
|
2021-08-16 01:42:07 -07:00
|
|
|
};
|
|
|
|
|
2022-10-22 10:37:58 -07:00
|
|
|
outputs = { self, nixpkgs, nixpkgs-unstable, flake-utils, ... }:
|
2021-08-16 01:42:07 -07:00
|
|
|
let
|
2022-07-17 01:33:22 -07:00
|
|
|
supportedSystems = [
|
|
|
|
"x86_64-linux"
|
|
|
|
"aarch64-linux"
|
2022-12-18 04:13:43 -08:00
|
|
|
# On these 32-bit platforms, Python pkg `pymemcache` 4.0.0 (required by
|
|
|
|
# `joinmarket`) is broken:
|
|
|
|
# "i686-linux"
|
|
|
|
# "armv7l-linux"
|
2022-07-17 01:33:22 -07:00
|
|
|
];
|
2022-10-22 10:37:58 -07:00
|
|
|
|
|
|
|
test = import ./test/tests.nix nixpkgs.lib;
|
2022-07-15 02:42:02 -07:00
|
|
|
in {
|
2021-12-27 07:58:14 -08:00
|
|
|
lib = {
|
|
|
|
mkNbPkgs = {
|
|
|
|
system
|
2022-02-03 11:46:25 -08:00
|
|
|
, pkgs ? nixpkgs.legacyPackages.${system}
|
2022-10-22 10:37:53 -07:00
|
|
|
, pkgsUnstable ? nixpkgs-unstable.legacyPackages.${system}
|
2021-12-27 07:58:14 -08:00
|
|
|
}:
|
|
|
|
import ./pkgs { inherit pkgs pkgsUnstable; };
|
2022-10-22 10:37:55 -07:00
|
|
|
|
2022-10-22 10:37:58 -07:00
|
|
|
test = {
|
|
|
|
inherit (test) scenarios;
|
|
|
|
};
|
|
|
|
|
2022-10-22 10:37:55 -07:00
|
|
|
inherit supportedSystems;
|
2021-12-27 07:58:14 -08:00
|
|
|
};
|
2021-08-16 01:42:07 -07:00
|
|
|
|
2022-06-01 10:59:32 -07:00
|
|
|
overlays.default = final: prev: let
|
2022-07-15 02:42:02 -07:00
|
|
|
nbPkgs = self.lib.mkNbPkgs { inherit (final) system; pkgs = final; };
|
2021-08-16 01:42:07 -07:00
|
|
|
in removeAttrs nbPkgs [ "pinned" "nixops19_09" "krops" ];
|
|
|
|
|
2022-06-01 10:59:32 -07:00
|
|
|
nixosModules.default = { config, pkgs, lib, ... }: {
|
2021-12-27 07:58:15 -08:00
|
|
|
imports = [ ./modules/modules.nix ];
|
|
|
|
|
|
|
|
options = with lib; {
|
|
|
|
nix-bitcoin.useVersionLockedPkgs = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Use the nixpkgs version locked by this flake for `nix-bitcoin.pkgs`.
|
|
|
|
Only relevant if you are using a nixpkgs version for evaluating your system
|
|
|
|
that differs from the one that is locked by this flake (via input `nixpkgs`).
|
|
|
|
If this is the case, enabling this option may result in a more stable system
|
|
|
|
because the nix-bitcoin services use the exact pkgs versions that are tested
|
|
|
|
by nix-bitcoin.
|
|
|
|
The downsides are increased evaluation times and increased system
|
|
|
|
closure size.
|
|
|
|
|
|
|
|
If `false`, the default system pkgs are used.
|
|
|
|
'';
|
|
|
|
};
|
2021-08-16 01:42:07 -07:00
|
|
|
};
|
|
|
|
|
2021-12-27 07:58:15 -08:00
|
|
|
config = {
|
|
|
|
nix-bitcoin.pkgs =
|
|
|
|
if config.nix-bitcoin.useVersionLockedPkgs
|
|
|
|
then (self.lib.mkNbPkgs { inherit (config.nixpkgs) system; }).modulesPkgs
|
|
|
|
else (self.lib.mkNbPkgs { inherit (pkgs) system; inherit pkgs; }).modulesPkgs;
|
2021-08-16 01:42:07 -07:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-06-01 10:59:32 -07:00
|
|
|
templates.default = {
|
2021-08-16 01:42:07 -07:00
|
|
|
description = "Basic node template";
|
|
|
|
path = ./examples/flakes;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // (flake-utils.lib.eachSystem supportedSystems (system:
|
|
|
|
let
|
2022-02-03 11:46:25 -08:00
|
|
|
pkgs = nixpkgs.legacyPackages.${system};
|
2021-12-27 07:58:14 -08:00
|
|
|
nbPkgs = self.lib.mkNbPkgs { inherit system pkgs; };
|
2021-08-16 01:42:07 -07:00
|
|
|
in rec {
|
|
|
|
packages = flake-utils.lib.flattenTree (removeAttrs nbPkgs [
|
2022-08-21 05:41:36 -07:00
|
|
|
"fetchNodeModules"
|
|
|
|
"krops"
|
|
|
|
"modulesPkgs"
|
|
|
|
"netns-exec"
|
|
|
|
"nixops19_09"
|
|
|
|
"pinned"
|
|
|
|
"generate-secrets"
|
2021-08-16 01:42:07 -07:00
|
|
|
]) // {
|
2022-06-01 12:31:33 -07:00
|
|
|
inherit (import ./examples/qemu-vm/minimal-vm.nix self pkgs system)
|
|
|
|
# A simple demo VM.
|
|
|
|
# See ./examples/flakes/flake.nix on how to use nix-bitcoin with flakes.
|
|
|
|
runVM
|
|
|
|
vm;
|
2021-08-16 01:42:07 -07:00
|
|
|
};
|
|
|
|
|
2021-12-27 07:58:14 -08:00
|
|
|
# Allow accessing the whole nested `nbPkgs` attrset (including `modulesPkgs`)
|
|
|
|
# via this flake.
|
|
|
|
# `packages` is not allowed to contain nested pkgs attrsets.
|
2022-10-22 10:37:58 -07:00
|
|
|
legacyPackages =
|
|
|
|
nbPkgs //
|
|
|
|
(test.pkgs self pkgs) //
|
|
|
|
{
|
|
|
|
extra-container = self.inputs.extra-container.packages.${system}.default;
|
|
|
|
};
|
2021-12-27 07:58:14 -08:00
|
|
|
|
2022-06-01 10:59:32 -07:00
|
|
|
apps = rec {
|
|
|
|
default = vm;
|
2021-08-16 01:42:07 -07:00
|
|
|
|
|
|
|
# Run a basic nix-bitcoin node in a VM
|
|
|
|
vm = {
|
|
|
|
type = "app";
|
|
|
|
program = toString packages.runVM;
|
|
|
|
};
|
|
|
|
};
|
2023-01-15 11:27:51 -08:00
|
|
|
|
|
|
|
devShells.default = import ./dev/dev-env/dev-shell.nix pkgs;
|
2021-08-16 01:42:07 -07:00
|
|
|
}
|
|
|
|
));
|
|
|
|
}
|