mirror of
https://github.com/itme-brain/nixos.git
synced 2026-03-23 16:29:42 -04:00
69 lines
1.5 KiB
Nix
69 lines
1.5 KiB
Nix
{ pkgs, lib, config, ... }:
|
|
|
|
with lib;
|
|
let
|
|
cfg = config.modules.system.bitcoin;
|
|
nginx = config.modules.system.nginx;
|
|
|
|
home = "/var/lib/bitcoind";
|
|
|
|
bitcoinConf = pkgs.writeTextFile {
|
|
name = "bitcoin.conf";
|
|
text = builtins.readFile ./config/bitcoin.conf;
|
|
};
|
|
|
|
in
|
|
{ options.modules.system.bitcoin = { enable = mkEnableOption "Bitcoin Server"; };
|
|
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=";
|
|
};
|
|
});
|
|
})
|
|
];
|
|
|
|
users = {
|
|
users = {
|
|
"btc" = {
|
|
inherit home;
|
|
description = "Bitcoin Core system user";
|
|
isSystemUser = true;
|
|
group = "bitcoin";
|
|
createHome = true;
|
|
};
|
|
"nginx" = {
|
|
extraGroups = mkIf nginx.enable [
|
|
"bitcoin"
|
|
];
|
|
};
|
|
};
|
|
groups = {
|
|
"bitcoin" = {
|
|
members = [
|
|
"btc"
|
|
];
|
|
};
|
|
};
|
|
};
|
|
|
|
programs.bash.shellAliases = {
|
|
btc = "bitcoind";
|
|
};
|
|
|
|
services.bitcoind = {
|
|
"btc" = {
|
|
enable = true;
|
|
user = "btc";
|
|
group = "bitcoin";
|
|
configFile = bitcoinConf;
|
|
dataDir = home;
|
|
pidFile = "${home}/bitcoind.pid";
|
|
};
|
|
};
|
|
};
|
|
}
|