summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorMarek Mahut <marek.mahut@gmail.com>2019-08-22 23:25:18 +0200
committerGitHub <noreply@github.com>2019-08-22 23:25:18 +0200
commitf4ca6e3dd1b08b1c5b8a59769d018df2db911fe7 (patch)
tree9745432f1ee003f419cbb702bd3cb02754aa89f8 /nixos
parent6f4ab8702fa8b30746af2c49df710fcb3a575aec (diff)
parent20ea4b6dd37072f9c4d64c973f04b6ac5123d980 (diff)
downloadnixpkgs-f4ca6e3dd1b08b1c5b8a59769d018df2db911fe7.tar
nixpkgs-f4ca6e3dd1b08b1c5b8a59769d018df2db911fe7.tar.gz
nixpkgs-f4ca6e3dd1b08b1c5b8a59769d018df2db911fe7.tar.bz2
nixpkgs-f4ca6e3dd1b08b1c5b8a59769d018df2db911fe7.tar.lz
nixpkgs-f4ca6e3dd1b08b1c5b8a59769d018df2db911fe7.tar.xz
nixpkgs-f4ca6e3dd1b08b1c5b8a59769d018df2db911fe7.tar.zst
nixpkgs-f4ca6e3dd1b08b1c5b8a59769d018df2db911fe7.zip
Merge pull request #66722 from mmahut/trezord-emulator
trezord: adding emulator support (plus test)
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/hardware/trezord.nix18
-rw-r--r--nixos/tests/all-tests.nix1
-rw-r--r--nixos/tests/trezord.nix20
3 files changed, 38 insertions, 1 deletions
diff --git a/nixos/modules/services/hardware/trezord.nix b/nixos/modules/services/hardware/trezord.nix
index 20bcbf83109..62824ed7350 100644
--- a/nixos/modules/services/hardware/trezord.nix
+++ b/nixos/modules/services/hardware/trezord.nix
@@ -22,6 +22,22 @@ in {
           Enable Trezor bridge daemon, for use with Trezor hardware bitcoin wallets.
         '';
       };
+
+      emulator.enable = mkOption {
+        type = types.bool;
+        default = false;
+        description = ''
+          Enable Trezor emulator support.
+          '';
+       };
+
+      emulator.port = mkOption {
+        type = types.port;
+        default = 21324;
+        description = ''
+          Listening port for the Trezor emulator.
+          '';
+      };
     };
   };
   
@@ -50,7 +66,7 @@ in {
       path = [];
       serviceConfig = {
         Type = "simple";
-        ExecStart = "${pkgs.trezord}/bin/trezord-go";
+        ExecStart = "${pkgs.trezord}/bin/trezord-go ${optionalString cfg.emulator.enable "-e ${builtins.toString cfg.emulator.port}"}";
         User = "trezord";
       };
     };
diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix
index 4eeee9c35c0..91c1044b4d8 100644
--- a/nixos/tests/all-tests.nix
+++ b/nixos/tests/all-tests.nix
@@ -262,6 +262,7 @@ in
   tinydns = handleTest ./tinydns.nix {};
   tor = handleTest ./tor.nix {};
   transmission = handleTest ./transmission.nix {};
+  trezord = handleTest ./trezord.nix {};
   udisks2 = handleTest ./udisks2.nix {};
   upnp = handleTest ./upnp.nix {};
   uwsgi = handleTest ./uwsgi.nix {};
diff --git a/nixos/tests/trezord.nix b/nixos/tests/trezord.nix
new file mode 100644
index 00000000000..1c85bf53934
--- /dev/null
+++ b/nixos/tests/trezord.nix
@@ -0,0 +1,20 @@
+import ./make-test.nix ({ pkgs, ... }: {
+  name = "trezord";
+  meta = with pkgs.stdenv.lib.maintainers; {
+    maintainers = [ mmahut ];
+  };
+
+  nodes = {
+    machine = { ... }: {
+      services.trezord.enable = true;
+      services.trezord.emulator.enable = true;
+    };
+  };
+
+  testScript = ''
+    startAll;
+    $machine->waitForUnit("trezord.service");
+    $machine->waitForOpenPort(21325);
+    $machine->waitUntilSucceeds("curl -L http://localhost:21325/status/ | grep Version");
+  '';
+})