forked from fort-nix/nix-bitcoin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for ledger and trezor with bitcoin-core/HWI
- Loading branch information
Showing
5 changed files
with
121 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
{ config, lib, pkgs, ... }: | ||
|
||
with lib; | ||
|
||
let | ||
cfg = config.services.hardware-wallets; | ||
dataDir = "/var/lib/hardware-wallets/"; | ||
enabled = cfg.ledger || cfg.trezor; | ||
in { | ||
options.services.hardware-wallets = { | ||
ledger = mkOption { | ||
type = types.bool; | ||
default = false; | ||
description = '' | ||
If enabled, the ledger udev rules will be installed. | ||
''; | ||
}; | ||
trezor = mkOption { | ||
type = types.bool; | ||
default = false; | ||
description = '' | ||
If enabled, the trezor udev rules will be installed. | ||
''; | ||
}; | ||
group = mkOption { | ||
type = types.string; | ||
default = "hardware-wallets"; | ||
description = '' | ||
Group the hardware wallet udev rules apply to. | ||
''; | ||
}; | ||
}; | ||
|
||
config = mkMerge [ | ||
{ | ||
# Create group | ||
users.groups."${cfg.group}" = {}; | ||
} | ||
(mkIf cfg.ledger { | ||
# Ledger Nano S according to https://github.com/LedgerHQ/udev-rules/blob/master/add_udev_rules.sh | ||
# Don't use rules from nixpkgs because we want to use our own group. | ||
services.udev.packages = lib.singleton (pkgs.writeTextFile { | ||
name = "ledger-udev-rules"; | ||
destination = "/etc/udev/rules.d/20-ledger.rules"; | ||
text = '' | ||
SUBSYSTEMS=="usb", ATTRS{idVendor}=="2c97", ATTRS{idProduct}=="0001", MODE="0660", GROUP="${cfg.group}" | ||
''; | ||
}); | ||
}) | ||
(mkIf cfg.trezor { | ||
# Don't use rules from nixpkgs because we want to use our own group. | ||
services.udev.packages = lib.singleton (pkgs.writeTextFile { | ||
name = "trezord-udev-rules"; | ||
destination = "/etc/udev/rules.d/52-trezor.rules"; | ||
text = '' | ||
# TREZOR v1 (One) | ||
SUBSYSTEM=="usb", ATTR{idVendor}=="534c", ATTR{idProduct}=="0001", MODE="0660", GROUP="${cfg.group}", TAG+="uaccess", SYMLINK+="trezor%n" | ||
KERNEL=="hidraw*", ATTRS{idVendor}=="534c", ATTRS{idProduct}=="0001", MODE="0660", GROUP="${cfg.group}", TAG+="uaccess" | ||
# TREZOR v2 (T) | ||
SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="53c0", MODE="0660", GROUP="${cfg.group}", TAG+="uaccess", SYMLINK+="trezor%n" | ||
SUBSYSTEM=="usb", ATTR{idVendor}=="1209", ATTR{idProduct}=="53c1", MODE="0660", GROUP="${cfg.group}", TAG+="uaccess", SYMLINK+="trezor%n" | ||
KERNEL=="hidraw*", ATTRS{idVendor}=="1209", ATTRS{idProduct}=="53c1", MODE="0660", GROUP="${cfg.group}", TAG+="uaccess" | ||
''; | ||
}); | ||
services.trezord.enable = true; | ||
}) | ||
]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
{ stdenv, fetchurl, fetchFromGitHub, python35 }: | ||
|
||
with stdenv.lib; | ||
with python35.pkgs; | ||
|
||
let | ||
buildInputs = [ mnemonic ecdsa typing-extensions hidapi libusb1 pyaes ]; | ||
in | ||
buildPythonPackage rec { | ||
pname = "hwi"; | ||
version = "1.0.0"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "bitcoin-core"; | ||
repo = "HWI"; | ||
rev = "4dd56fda3cd9cade8abc482e43e7733ddc8360a9"; | ||
sha256 = "1xy2iq95b8a4cm9k5yzsi8lx1ha0dral3lhshbl1mfm1fi9ch3nk"; | ||
}; | ||
|
||
# TODO: enable tests | ||
doCheck = false; | ||
|
||
inherit buildInputs; | ||
propagatedBuildInputs = buildInputs; | ||
|
||
meta = with lib; { | ||
homepage = https://github.com/bitcoin-core/hwi; | ||
}; | ||
} |