0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-20 17:10:46 +03:00
nixpkgs/nixos/modules/services/hardware/trezord.nix

76 lines
1.4 KiB
Nix
Raw Normal View History

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