nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 mkDerivation,
3 lib,
4 autoreconfHook,
5 curl,
6 fetchFromGitHub,
7 git,
8 libevent,
9 libtool,
10 qrencode,
11 udev,
12 libusb1,
13 makeWrapper,
14 pkg-config,
15 qtbase,
16 qttools,
17 qtwebsockets,
18 qtmultimedia,
19 udevRule51 ? ''
20 SUBSYSTEM=="usb", TAG+="uaccess", TAG+="udev-acl", SYMLINK+="dbb%n", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2402"
21 '',
22 udevRule52 ? ''
23 KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2402", TAG+="uaccess", TAG+="udev-acl", SYMLINK+="dbbf%n"
24 '',
25 udevCheckHook,
26 writeText,
27}:
28
29# Enabling the digitalbitbox program
30#
31# programs.digitalbitbox.enable = true;
32#
33# will install the digitalbitbox package and enable the corresponding hardware
34# module and is by far the easiest way to get started with the Digital Bitbox on
35# NixOS.
36
37# In case you install the package only, please be aware that you may need to
38# apply some udev rules to allow the application to identify and access your
39# wallet. In a nixos-configuration, one may accomplish this by enabling the
40# digitalbitbox hardware module
41#
42# hardware.digitalbitbox.enable = true;
43#
44# or by adding the digitalbitbox package to system.udev.packages
45#
46# system.udev.packages = [ pkgs.digitalbitbox ];
47
48# See https://digitalbitbox.com/start_linux for more information.
49let
50 copyUdevRuleToOutput = name: rule: "cp ${writeText name rule} $out/etc/udev/rules.d/${name}";
51in
52mkDerivation rec {
53 pname = "digitalbitbox";
54 version = "3.0.0";
55
56 src = fetchFromGitHub {
57 owner = "digitalbitbox";
58 repo = "dbb-app";
59 rev = "v${version}";
60 sha256 = "ig3+TdYv277D9GVnkRSX6nc6D6qruUOw/IQdQCK6FoA=";
61 };
62
63 nativeBuildInputs = [
64 autoreconfHook
65 curl
66 git
67 makeWrapper
68 pkg-config
69 qttools
70 udevCheckHook
71 ];
72
73 buildInputs = [
74 libevent
75 libtool
76 udev
77 libusb1
78 qrencode
79
80 qtbase
81 qtwebsockets
82 qtmultimedia
83 ];
84
85 LUPDATE = "${qttools.dev}/bin/lupdate";
86 LRELEASE = "${qttools.dev}/bin/lrelease";
87 MOC = "${qtbase.dev}/bin/moc";
88 QTDIR = qtbase.dev;
89 RCC = "${qtbase.dev}/bin/rcc";
90 UIC = "${qtbase.dev}/bin/uic";
91
92 configureFlags = [
93 "--enable-libusb"
94 ];
95
96 hardeningDisable = [
97 "format"
98 ];
99
100 qtWrapperArgs = [ "--prefix LD_LIBRARY_PATH : $out/lib" ];
101
102 postInstall = ''
103 mkdir -p "$out/lib"
104 cp src/libbtc/.libs/*.so* $out/lib
105 cp src/libbtc/src/secp256k1/.libs/*.so* $out/lib
106 cp src/hidapi/libusb/.libs/*.so* $out/lib
107 cp src/univalue/.libs/*.so* $out/lib
108
109 # Provide udev rules as documented in https://digitalbitbox.com/start_linux
110 mkdir -p "$out/etc/udev/rules.d"
111 ${copyUdevRuleToOutput "51-hid-digitalbox.rules" udevRule51}
112 ${copyUdevRuleToOutput "52-hid-digitalbox.rules" udevRule52}
113 '';
114
115 # remove forbidden references to $TMPDIR
116 preFixup = ''
117 for f in "$out"/{bin,lib}/*; do
118 if [ -f "$f" ] && isELF "$f"; then
119 patchelf --shrink-rpath --allowed-rpath-prefixes "$NIX_STORE" "$f"
120 fi
121 done
122 '';
123
124 enableParallelBuilding = true;
125
126 doInstallCheck = true;
127
128 meta = with lib; {
129 description = "QT based application for the Digital Bitbox hardware wallet";
130 longDescription = ''
131 Digital Bitbox provides dbb-app, a GUI tool, and dbb-cli, a CLI tool, to manage Digital Bitbox devices.
132
133 This package will only install the dbb-app and dbb-cli, however; in order for these applications to identify and access Digital Bitbox devices, one may want to enable the digitalbitbox hardware module by adding
134
135 hardware.digitalbitbox.enable = true;
136
137 to the configuration which is equivalent to adding this package to the udev.packages list.
138
139
140 The easiest way to use the digitalbitbox package in NixOS is by adding
141
142 programs.digitalbitbox.enable = true;
143
144 to the configuration which installs the package and enables the hardware module.
145 '';
146 homepage = "https://digitalbitbox.com/";
147 license = licenses.mit;
148 maintainers = with maintainers; [
149 vidbina
150 ];
151 platforms = platforms.linux;
152 };
153}