at 23.11-pre 1.5 kB view raw
1{ config, lib, pkgs, ... }: 2 3with lib; 4let 5 cfg = config.services.trezord; 6in { 7 8 ### docs 9 10 meta = { 11 doc = ./trezord.md; 12 }; 13 14 ### interface 15 16 options = { 17 services.trezord = { 18 enable = mkOption { 19 type = types.bool; 20 default = false; 21 description = lib.mdDoc '' 22 Enable Trezor bridge daemon, for use with Trezor hardware bitcoin wallets. 23 ''; 24 }; 25 26 emulator.enable = mkOption { 27 type = types.bool; 28 default = false; 29 description = lib.mdDoc '' 30 Enable Trezor emulator support. 31 ''; 32 }; 33 34 emulator.port = mkOption { 35 type = types.port; 36 default = 21324; 37 description = lib.mdDoc '' 38 Listening port for the Trezor emulator. 39 ''; 40 }; 41 }; 42 }; 43 44 ### implementation 45 46 config = mkIf cfg.enable { 47 services.udev.packages = [ pkgs.trezor-udev-rules ]; 48 49 systemd.services.trezord = { 50 description = "Trezor Bridge"; 51 after = [ "network.target" ]; 52 wantedBy = [ "multi-user.target" ]; 53 path = []; 54 serviceConfig = { 55 Type = "simple"; 56 ExecStart = "${pkgs.trezord}/bin/trezord-go ${optionalString cfg.emulator.enable "-e ${builtins.toString cfg.emulator.port}"}"; 57 User = "trezord"; 58 }; 59 }; 60 61 users.users.trezord = { 62 group = "trezord"; 63 description = "Trezor bridge daemon user"; 64 isSystemUser = true; 65 }; 66 67 users.groups.trezord = {}; 68 }; 69} 70