wip: bitcoin module update

This commit is contained in:
Bryan Ramos 2024-11-05 11:38:27 -05:00
parent 294dfd9d2d
commit 5296467dd2
Signed by: bryan
GPG key ID: 6ABDCD144D6643C8
8 changed files with 163 additions and 16 deletions

View file

@ -9,6 +9,10 @@
bitcoin = {
enable = true;
electrum.enable = true;
clightning = {
enable = true;
rest.enable = true;
};
};
};
};

View file

@ -15,16 +15,22 @@ in
{ options.modules.system.bitcoin = { enable = mkEnableOption "Bitcoin Server"; };
imports = [ ./modules ];
config = mkIf cfg.enable {
nixpkgs.overlays = [
(final: prev: {
bitcoind = prev.bitcoind.overrideAttrs (old: rec {
version = "27.0";
src = fetchTarball {
url = "https://github.com/bitcoin/bitcoin/archive/refs/tags/v${version}.tar.gz";
sha256 = "sha256-U2tR3WySD3EssA3a14wUtA3e0t/5go0isqNZSSma7m4=";
};
});
})
#nixpkgs.overlays = [
# (final: prev: {
# bitcoind = prev.bitcoind.overrideAttrs (old: rec {
# version = "v28.0";
# src = pkgs.fetchFromGitHub {
# owner = "bitcoin";
# repo = "bitcoin";
# rev = "${version}";
# sha256 = "sha256-LLtw6pMyqIJ3IWHiK4P3XoifLojB9yMNMo+MGNFGuRY=";
# };
# });
# })
#];
environment.systemPackages = with pkgs; [
bitcoind
];
users = {

View file

@ -0,0 +1 @@
test

View file

@ -0,0 +1,92 @@
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.modules.system.bitcoin.clightning;
btc = config.modules.system.bitcoin;
clnConfig = pkgs.writeTextFile {
name = "lightning.conf";
text = builtins.readFile ./config/lightning.conf;
};
in
{ options.modules.system.bitcoin.clightning = { enable = mkEnableOption "Core Lightning Server"; };
imports = [ ./plugins ];
config = mkIf (cfg.enable && btc.enable) {
#nixpkgs.overlays = [
# (final: prev: {
# clightning = prev.electrs.overrideAttrs (old: rec {
# version = "24.08";
# src = pkgs.fetchFromGitHub {
# owner = "ElementsProject";
# repo = "lightning";
# rev = "82f4ad68e34a2428c556e63fc2632d48a914968c";
# hash = "sha256-MWU75e55Zt/P4aaIuMte7iRcrFGMw0P81b8VNHQBe2g";
# };
# cargoDeps = old.cargoDeps.overrideAttrs (lib.const {
# name = "lightning-vendor.tar.gz";
# inherit src;
# outputHash = "sha256-MWU75e55Zt/P4aaIuMte7iRcrFGMw0P81b8VNHQBe2g=";
# });
# });
# })
#];
environment.systemPackages = with pkgs; [
clightning
];
users = {
users = {
"clightning" = {
home = "/var/lib/clightning";
description = "Core Lightning system user";
isSystemUser = true;
group = "bitcoin";
createHome = true;
};
};
groups = {
"bitcoin" = {
members = mkAfter [
"clightning"
];
};
};
};
programs.bash.shellAliases = {
cln = "lightningd";
};
systemd.services.lightningd = {
description = "Core Lightning Daemon";
script = "${pkgs.clightning}/bin/lightningd";
scriptArgs = ''
--conf=${clnConfig}
'';
after = [
"bitcoind-btc.service"
];
serviceConfig = {
User = "clightning";
Group = "bitcoin";
Type = "simple";
KillMode = "process";
TimeoutSec = 60;
Restart = "always";
RestartSec = 60;
};
requisite = [
"bitcoind-btc.service"
"network.target"
];
};
};
}

View file

@ -0,0 +1,35 @@
{ lib, pkgs, config, ... }:
with lib;
let
cfg = config.modules.system.bitcoin.clightning.rest;
cln = config.modules.system.bitcoin.clightning;
in
{ options.modules.system.bitcoin.clightning.rest = { enable = mkEnableOption "C-Lightning REST API Server"; };
config = mkIf (cfg.enable && cln.enable) {
nixpkgs.overlays = [
(final: prev: {
clightning-REST = prev.buildNpmPackage rec {
pname = "c-lightning-rest";
version = "0.10.7";
src = prev.fetchFromGitHub {
owner = "Ride-The-Lightning";
repo = "c-lightning-REST";
rev = "v${version}";
hash = "sha256-Z3bLH/nqhO2IPE1N4TxYhEDh2wHR0nT801kztfYoj+s=";
};
npmDepsHash = "sha256-svt5hjhTriGhehxC36yGwrqcjax/9UqqVzxEhHnoM0M=";
dontNpmBuild = true;
meta = with lib; {
description = "REST APIs for Core Lightning written with node.js ";
homepage = "https://github.com/Ride-The-Lightning/c-lightning-REST";
license = licenses.mit;
};
};
})
];
};
}

View file

@ -0,0 +1,5 @@
{
imports = [
./c-lightning-REST
];
}

View file

@ -1,5 +1,6 @@
{
imports = [
./electrum
./clightning
];
}

View file

@ -3,8 +3,6 @@
with lib;
let
cfg = config.modules.system.bitcoin.electrum;
home = "/var/lib/electrs";
btc = config.modules.system.bitcoin;
electrsConfig = pkgs.writeTextFile {
@ -18,13 +16,18 @@ in
nixpkgs.overlays = [
(final: prev: {
electrs = prev.electrs.overrideAttrs (old: rec {
version = "0.10.4";
version = "0.10.6";
src = pkgs.fetchFromGitHub {
owner = "romanz";
repo = "electrs";
rev = "${version}";
hash = "sha256-4c+FGYM34LSfazzshfRPjA+0BvDL2tvkSr2rasUognc=";
rev = "v${version}";
hash = "sha256-yp9fKD7zH9Ne2+WQUupaxvUx39RWE8RdY4U6lHuDGSc=";
};
cargoDeps = old.cargoDeps.overrideAttrs (lib.const {
name = "electrs-vendor.tar.gz";
inherit src;
outputHash = "sha256-qQKAQHOAeYWQ5YVtx12hIAjNA7Aj1MW1m+WimlBWPv0=";
});
});
})
];
@ -36,7 +39,7 @@ in
users = {
users = {
"electrs" = {
inherit home;
home = "/var/lib/electrs";
description = "Electrs system user";
isSystemUser = true;
group = "bitcoin";