summaryrefslogtreecommitdiff
path: root/modules/services
diff options
context:
space:
mode:
Diffstat (limited to 'modules/services')
-rw-r--r--modules/services/trezord.nix47
1 files changed, 47 insertions, 0 deletions
diff --git a/modules/services/trezord.nix b/modules/services/trezord.nix
new file mode 100644
index 0000000..97db519
--- /dev/null
+++ b/modules/services/trezord.nix
@@ -0,0 +1,47 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let
+ cfg = config.services.trezord;
+in {
+ # Options copied from:
+ # https://github.com/NixOS/nixpkgs/blob/9d6e454b857fb472fa35fc8b098fa5ac307a0d7d/nixos/modules/services/hardware/trezord.nix#L16
+ options = {
+ services.trezord = {
+ enable = mkOption {
+ type = types.bool;
+ default = false;
+ description = lib.mdDoc ''
+ Enable Trezor bridge daemon, for use with Trezor hardware wallets.
+ '';
+ };
+
+ emulator.enable = mkOption {
+ type = types.bool;
+ default = false;
+ description = lib.mdDoc ''
+ Enable Trezor emulator support.
+ '';
+ };
+
+ emulator.port = mkOption {
+ type = types.port;
+ default = 21324;
+ description = lib.mdDoc ''
+ Listening port for the Trezor emulator.
+ '';
+ };
+ };
+ };
+
+ config = mkIf cfg.enable {
+ launchd.user.agents.trezord = {
+ serviceConfig = {
+ ProgramArguments = [ "${pkgs.trezord}/bin/trezord-go" ]
+ ++ optionals cfg.emulator.enable [ "-e" (builtins.toString cfg.emulator.port) ];
+ KeepAlive = true;
+ RunAtLoad = true;
+ };
+ };
+ };
+}