2018-12-01 20:26:29 +03:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.services.nanopos;
|
2019-11-27 16:04:23 +03:00
|
|
|
inherit (config) nix-bitcoin-services;
|
2018-12-01 20:26:29 +03:00
|
|
|
defaultItemsFile = pkgs.writeText "items.yaml" ''
|
|
|
|
tea:
|
|
|
|
price: 0.02 # denominated in the currency specified by --currency
|
|
|
|
title: Green Tea # title is optional, defaults to the key
|
|
|
|
|
|
|
|
coffee:
|
|
|
|
price: 1
|
|
|
|
|
|
|
|
bamba:
|
|
|
|
price: 3
|
|
|
|
|
|
|
|
beer:
|
|
|
|
price: 7
|
|
|
|
|
|
|
|
hat:
|
|
|
|
price: 15
|
|
|
|
|
|
|
|
tshirt:
|
|
|
|
price: 25
|
|
|
|
'';
|
|
|
|
|
|
|
|
in {
|
|
|
|
options.services.nanopos = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
If enabled, the nanopos service will be installed.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
port = mkOption {
|
2019-01-01 22:16:24 +03:00
|
|
|
type = types.ints.u16;
|
2018-12-01 20:26:29 +03:00
|
|
|
default = 9116;
|
|
|
|
description = ''
|
|
|
|
"The port on which to listen for connections.";
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
itemsFile = mkOption {
|
|
|
|
type = types.path;
|
|
|
|
default = defaultItemsFile;
|
|
|
|
description = ''
|
|
|
|
"The items file (see nanopos README).";
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2019-01-02 18:17:57 +03:00
|
|
|
systemd.services.nanopos = {
|
|
|
|
description = "Run nanopos";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
requires = [ "lightning-charge.service" ];
|
|
|
|
after = [ "lightning-charge.service" ];
|
|
|
|
serviceConfig = {
|
2020-01-12 22:52:39 +03:00
|
|
|
EnvironmentFile = "${config.nix-bitcoin.secretsDir}/nanopos-env";
|
2019-11-27 16:04:21 +03:00
|
|
|
ExecStart = "${pkgs.nix-bitcoin.nanopos}/bin/nanopos -y ${cfg.itemsFile} -p ${toString cfg.port} --show-bolt11";
|
2018-12-01 20:26:29 +03:00
|
|
|
|
2019-01-02 18:17:57 +03:00
|
|
|
User = "nanopos";
|
|
|
|
Restart = "on-failure";
|
|
|
|
RestartSec = "10s";
|
2019-04-28 02:53:26 +03:00
|
|
|
} // nix-bitcoin-services.defaultHardening
|
2019-05-03 13:44:16 +03:00
|
|
|
// nix-bitcoin-services.nodejs
|
2019-04-28 02:53:26 +03:00
|
|
|
// nix-bitcoin-services.allowTor;
|
2018-12-01 20:26:29 +03:00
|
|
|
};
|
2020-01-12 22:52:37 +03:00
|
|
|
users.users.nanopos = {
|
|
|
|
description = "nanopos User";
|
|
|
|
group = "nanopos";
|
|
|
|
};
|
|
|
|
users.groups.nanopos = {};
|
2020-01-12 22:52:38 +03:00
|
|
|
nix-bitcoin.secrets.nanopos-env.user = "nanopos";
|
2019-01-02 18:17:57 +03:00
|
|
|
};
|
2018-12-01 20:26:29 +03:00
|
|
|
}
|