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