2017-02-08 17:18:22 +01:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
cfg = config.services.trezord;
|
|
|
|
in {
|
|
|
|
|
|
|
|
### interface
|
|
|
|
|
|
|
|
options = {
|
|
|
|
services.trezord = {
|
|
|
|
enable = mkOption {
|
|
|
|
type = types.bool;
|
|
|
|
default = false;
|
|
|
|
description = ''
|
|
|
|
Enable Trezor bridge daemon, for use with Trezor hardware bitcoin wallets.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
### implementation
|
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
services.udev.packages = lib.singleton (pkgs.writeTextFile {
|
|
|
|
name = "trezord-udev-rules";
|
|
|
|
destination = "/etc/udev/rules.d/51-trezor.rules";
|
|
|
|
text = ''
|
2018-09-24 19:26:56 +02:00
|
|
|
# TREZOR v1 (One)
|
2018-10-26 14:53:31 +02:00
|
|
|
SUBSYSTEM=="usb", ATTR{idVendor}=="534c", ATTR{idProduct}=="0001", MODE="0660", GROUP="trezord", TAG+="uaccess", SYMLINK+="trezor%n"
|
|
|
|
KERNEL=="hidraw*", ATTRS{idVendor}=="534c", ATTRS{idProduct}=="0001", MODE="0660", GROUP="trezord", TAG+="uaccess"
|
2018-09-24 19:26:56 +02:00
|
|
|
|
|
|
|
# TREZOR v2 (T)
|
2018-10-26 14:53:31 +02:00
|
|
|
SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="53c0", MODE="0660", GROUP="trezord", TAG+="uaccess", SYMLINK+="trezor%n"
|
|
|
|
SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="53c1", MODE="0660", GROUP="trezord", TAG+="uaccess", SYMLINK+="trezor%n"
|
|
|
|
KERNEL=="hidraw*", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="53c1", MODE="0660", GROUP="trezord", TAG+="uaccess"
|
2017-02-08 17:18:22 +01:00
|
|
|
'';
|
|
|
|
});
|
|
|
|
|
|
|
|
systemd.services.trezord = {
|
|
|
|
description = "TREZOR Bridge";
|
|
|
|
after = [ "systemd-udev-settle.service" "network.target" ];
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
path = [];
|
|
|
|
serviceConfig = {
|
|
|
|
Type = "simple";
|
2018-04-11 00:12:32 +02:00
|
|
|
ExecStart = "${pkgs.trezord}/bin/trezord-go";
|
2017-02-08 17:18:22 +01:00
|
|
|
User = "trezord";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
users.users.trezord = {
|
|
|
|
group = "trezord";
|
|
|
|
description = "Trezor bridge daemon user";
|
|
|
|
};
|
|
|
|
|
|
|
|
users.groups.trezord = {};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|