2020-04-24 23:36:52 +00:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.trezord;
|
|
|
|
in {
|
|
|
|
|
|
|
|
### docs
|
|
|
|
|
|
|
|
meta = {
|
2023-02-02 18:25:31 +00:00
|
|
|
doc = ./trezord.md;
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2020-08-20 17:08:02 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.trezord = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Enable Trezor bridge daemon, for use with Trezor hardware bitcoin wallets.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
emulator.enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Enable Trezor emulator support.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
emulator.port = mkOption {
|
|
|
|
type = types.port;
|
|
|
|
default = 21324;
|
2024-04-21 15:54:59 +00:00
|
|
|
description = ''
|
2020-04-24 23:36:52 +00:00
|
|
|
Listening port for the Trezor emulator.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2020-08-20 17:08:02 +00:00
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
services.udev.packages = [ pkgs.trezor-udev-rules ];
|
|
|
|
|
|
|
|
systemd.services.trezord = {
|
2020-12-29 15:07:52 +00:00
|
|
|
description = "Trezor Bridge";
|
2021-03-09 03:18:52 +00:00
|
|
|
after = [ "network.target" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
path = [];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
|
|
|
ExecStart = "${pkgs.trezord}/bin/trezord-go ${optionalString cfg.emulator.enable "-e ${builtins.toString cfg.emulator.port}"}";
|
|
|
|
User = "trezord";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
users.users.trezord = {
|
|
|
|
group = "trezord";
|
|
|
|
description = "Trezor bridge daemon user";
|
|
|
|
isSystemUser = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
users.groups.trezord = {};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|