3b842e5fe7
Remove use of nixops-specific 'keys' group and key services. Instead: - Add nix-bitcoin-secrets.target, which should be required by all units that depend on secrets. (To keep it simple, it's okay to meet the secrets dependency indirectly by e.g. depending on bitcoind.) Various secret deployment methods can use this target by setting up the secrets before activating the target. In case of nixops we just specify that nixops' keys.target comes before nix-bitcoin-secrets.target. If the target is left undefined in the case of manual secrets deployment, systemd will simply ignore unit dependencies on the target. - Allow all users to access the secrets dir. The access protection for the individual secret files is unchanged. This allows us to drop the unit dependency on the nixops 'keys' group.
79 lines
1.8 KiB
Nix
79 lines
1.8 KiB
Nix
{ config, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
nix-bitcoin-services = pkgs.callPackage ./nix-bitcoin-services.nix { };
|
|
cfg = config.services.nanopos;
|
|
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 {
|
|
type = types.ints.u16;
|
|
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 {
|
|
users.users.nanopos = {
|
|
description = "nanopos User";
|
|
group = "nanopos";
|
|
};
|
|
users.groups.nanopos = {};
|
|
|
|
systemd.services.nanopos = {
|
|
description = "Run nanopos";
|
|
wantedBy = [ "multi-user.target" ];
|
|
requires = [ "lightning-charge.service" ];
|
|
after = [ "lightning-charge.service" ];
|
|
serviceConfig = {
|
|
EnvironmentFile = "/secrets/lightning-charge-api-token-for-nanopos";
|
|
ExecStart = "${pkgs.nanopos}/bin/nanopos -y ${cfg.itemsFile} -p ${toString cfg.port} --show-bolt11";
|
|
|
|
User = "nanopos";
|
|
Restart = "on-failure";
|
|
RestartSec = "10s";
|
|
} // nix-bitcoin-services.defaultHardening
|
|
// nix-bitcoin-services.nodejs
|
|
// nix-bitcoin-services.allowTor;
|
|
};
|
|
};
|
|
}
|