summary refs log tree commit diff
path: root/nixos/modules/services/hardware/trezord.nix
diff options
context:
space:
mode:
authorAndrew Cann <shum@canndrew.org>2017-02-09 00:18:22 +0800
committerJoachim F <joachifm@users.noreply.github.com>2017-02-08 17:18:22 +0100
commit3082647e740cd6df15f9515c3c436d1344b52b53 (patch)
tree5382581d222888587a4cbbb9fad0c960d7492f52 /nixos/modules/services/hardware/trezord.nix
parentae02508c2a378a5721769bb466b12e8a4ff2e7a2 (diff)
downloadnixpkgs-3082647e740cd6df15f9515c3c436d1344b52b53.tar
nixpkgs-3082647e740cd6df15f9515c3c436d1344b52b53.tar.gz
nixpkgs-3082647e740cd6df15f9515c3c436d1344b52b53.tar.bz2
nixpkgs-3082647e740cd6df15f9515c3c436d1344b52b53.tar.lz
nixpkgs-3082647e740cd6df15f9515c3c436d1344b52b53.tar.xz
nixpkgs-3082647e740cd6df15f9515c3c436d1344b52b53.tar.zst
nixpkgs-3082647e740cd6df15f9515c3c436d1344b52b53.zip
trezord: init at 1.2.0 (#22054)
Diffstat (limited to 'nixos/modules/services/hardware/trezord.nix')
-rw-r--r--nixos/modules/services/hardware/trezord.nix54
1 files changed, 54 insertions, 0 deletions
diff --git a/nixos/modules/services/hardware/trezord.nix b/nixos/modules/services/hardware/trezord.nix
new file mode 100644
index 00000000000..38d0a3a1d75
--- /dev/null
+++ b/nixos/modules/services/hardware/trezord.nix
@@ -0,0 +1,54 @@
+{ 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 = ''
+        SUBSYSTEM=="usb", ATTR{idVendor}=="534c", ATTR{idProduct}=="0001", MODE="0666", GROUP="dialout", SYMLINK+="trezor%n"
+        KERNEL=="hidraw*", ATTRS{idVendor}=="534c", ATTRS{idProduct}=="0001",  MODE="0666", GROUP="dialout"
+      '';
+    });
+
+    systemd.services.trezord = {
+      description = "TREZOR Bridge";
+      after = [ "systemd-udev-settle.service" "network.target" ];
+      wantedBy = [ "multi-user.target" ];
+      path = [];
+      serviceConfig = {
+        Type = "simple";
+        ExecStart = "${pkgs.trezord}/bin/trezord -f";
+        User = "trezord";
+      };
+    };
+
+    users.users.trezord = {
+      group = "trezord";
+      description = "Trezor bridge daemon user";
+    };
+
+    users.groups.trezord = {};
+  };
+}
+