digitalbitbox: init at 2.2.2 (#33787)

* digitalbitbox: init at 2.2.2

The commits that lead to this have been squashed from independent
commits see branch @vidbina/add/digitalbitbox-wip that did the
following:
- 0a3030fa0ec digitalbitbox: init at 2.2.2
- c18ffa3ffd4 digitalbitbox: moved meta to EOF
- 0c5f3d6972a digitalbitbox: using preConfigure + configureFlags
- a85b1dfc3fd digitalbitbox: nativeBuildInputs
- 90bdd35ef0f digitalbitbox: autoreconfHook
- 91810eea055 digitalbitbox: default installPhase & makeWrapper
- 90e43fb7e2a digitalbitbox: doc rm $PWD hack & printf-tee deal
- fd033b2fe5a digitalbitbox: cleanup, alphabetically sort attrs
- c5907982db3 digitalbitbox: added hardware module
- 88e46bc9ae0 digitalbitbox: added program module
- amend to change name: dbb-app -> digitalbitbox
- amend to add install instructions based on feedback
(https://github.com/NixOS/nixpkgs/pull/33787#issuecomment-362813149)
- amend to add longDescription
- moved program to its own dir
- overridable udev rules handling
- added docs to manual
- added package attr to program module
- added package attr to hardware module

* digitalbitbox: use libsForQt5.callPackage

authored by David Asabina and committed by Jörg Thalheim e41ca3b3 e21057ae

+298
+30
nixos/modules/hardware/digitalbitbox.nix
··· 1 + { config, lib, pkgs, ... }: 2 + 3 + with lib; 4 + 5 + let 6 + cfg = config.hardware.digitalbitbox; 7 + in 8 + 9 + { 10 + options.hardware.digitalbitbox = { 11 + enable = mkOption { 12 + type = types.bool; 13 + default = false; 14 + description = '' 15 + Enables udev rules for Digital Bitbox devices. 16 + ''; 17 + }; 18 + 19 + package = mkOption { 20 + type = types.package; 21 + default = pkgs.digitalbitbox; 22 + defaultText = "pkgs.digitalbitbox"; 23 + description = "The Digital Bitbox package to use. This can be used to install a package with udev rules that differ from the defaults."; 24 + }; 25 + }; 26 + 27 + config = mkIf cfg.enable { 28 + services.udev.packages = [ cfg.package ]; 29 + }; 30 + }
+2
nixos/modules/module-list.nix
··· 31 31 ./hardware/ckb.nix 32 32 ./hardware/cpu/amd-microcode.nix 33 33 ./hardware/cpu/intel-microcode.nix 34 + ./hardware/digitalbitbox.nix 34 35 ./hardware/sensor/iio.nix 35 36 ./hardware/ksm.nix 36 37 ./hardware/mcelog.nix ··· 78 79 ./programs/command-not-found/command-not-found.nix 79 80 ./programs/criu.nix 80 81 ./programs/dconf.nix 82 + ./programs/digitalbitbox/default.nix 81 83 ./programs/environment.nix 82 84 ./programs/fish.nix 83 85 ./programs/freetds.nix
+39
nixos/modules/programs/digitalbitbox/default.nix
··· 1 + { config, lib, pkgs, ... }: 2 + 3 + with lib; 4 + 5 + let 6 + cfg = config.programs.digitalbitbox; 7 + in 8 + 9 + { 10 + options.programs.digitalbitbox = { 11 + enable = mkOption { 12 + type = types.bool; 13 + default = false; 14 + description = '' 15 + Installs the Digital Bitbox application and enables the complementary hardware module. 16 + ''; 17 + }; 18 + 19 + package = mkOption { 20 + type = types.package; 21 + default = pkgs.digitalbitbox; 22 + defaultText = "pkgs.digitalbitbox"; 23 + description = "The Digital Bitbox package to use. This can be used to install a package with udev rules that differ from the defaults."; 24 + }; 25 + }; 26 + 27 + config = mkIf cfg.enable { 28 + environment.systemPackages = [ cfg.package ]; 29 + hardware.digitalbitbox = { 30 + enable = true; 31 + package = cfg.package; 32 + }; 33 + }; 34 + 35 + meta = { 36 + doc = ./doc.xml; 37 + maintainers = with stdenv.lib.maintainers; [ vidbina ]; 38 + }; 39 + }
+85
nixos/modules/programs/digitalbitbox/doc.xml
··· 1 + <chapter xmlns="http://docbook.org/ns/docbook" 2 + xmlns:xlink="http://www.w3.org/1999/xlink" 3 + xmlns:xi="http://www.w3.org/2001/XInclude" 4 + version="5.0" 5 + xml:id="module-programs-digitalbitbox"> 6 + 7 + <title>Digital Bitbox</title> 8 + 9 + <para> 10 + Digital Bitbox is a hardware wallet and second-factor authenticator. 11 + </para> 12 + 13 + <para> 14 + The <literal>digitalbitbox</literal> programs module may be 15 + installed by setting <literal>programs.digitalbitbox</literal> 16 + to <literal>true</literal> in a manner similar to 17 + 18 + <programlisting> 19 + programs.digitalbitbox.enable = true; 20 + </programlisting> 21 + 22 + and bundles the <literal>digitalbitbox</literal> package (see <xref 23 + linkend="sec-digitalbitbox-package" />), which contains the 24 + <literal>dbb-app</literal> and <literal>dbb-cli</literal> binaries, 25 + along with the hardware module (see <xref 26 + linkend="sec-digitalbitbox-hardware-module" />) which sets up the 27 + necessary udev rules to access the device. 28 + </para> 29 + 30 + <para> 31 + Enabling the digitalbitbox module is pretty much the easiest way to 32 + get a Digital Bitbox device working on your system. 33 + </para> 34 + 35 + <para> 36 + For more information, see 37 + <link xlink:href="https://digitalbitbox.com/start_linux" />. 38 + </para> 39 + 40 + <section xml:id="sec-digitalbitbox-package"> 41 + <title>Package</title> 42 + 43 + <para> 44 + The binaries, <literal>dbb-app</literal> (a GUI tool) and 45 + <literal>dbb-cli</literal> (a CLI tool), are available through the 46 + <literal>digitalbitbox</literal> package which could be installed 47 + as follows: 48 + 49 + <programlisting> 50 + environment.systemPackages = [ 51 + pkgs.digitalbitbox 52 + ]; 53 + </programlisting> 54 + </para> 55 + </section> 56 + 57 + 58 + <section xml:id="sec-digitalbitbox-hardware-module"> 59 + <title>Hardware</title> 60 + 61 + <para> 62 + The digitalbitbox hardware package enables the udev rules for 63 + Digital Bitbox devices and may be installed as follows: 64 + 65 + <programlisting> 66 + hardware.digitalbitbox.enable = true; 67 + </programlisting> 68 + </para> 69 + 70 + <para> 71 + In order to alter the udev rules, one may provide different values for 72 + the <literal>udevRule51</literal> and <literal>udevRule52</literal> 73 + attributes by means of overriding as follows: 74 + 75 + <programlisting> 76 + programs.digitalbitbox = { 77 + enable = true; 78 + package = pkgs.digitalbitbox.override { 79 + udevRule51 = "something else"; 80 + }; 81 + }; 82 + </programlisting> 83 + </para> 84 + </section> 85 + </chapter>
+140
pkgs/applications/misc/digitalbitbox/default.nix
··· 1 + { stdenv 2 + , autoreconfHook 3 + , curl 4 + , fetchFromGitHub 5 + , git 6 + , libevent 7 + , libtool 8 + , libqrencode 9 + , libudev 10 + , libusb 11 + , makeWrapper 12 + , pkgconfig 13 + , qtbase 14 + , qttools 15 + , qtwebsockets 16 + , qtmultimedia 17 + , udevRule51 ? '' 18 + , SUBSYSTEM=="usb", TAG+="uaccess", TAG+="udev-acl", SYMLINK+="dbb%n", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2402" 19 + , '' 20 + , udevRule52 ? '' 21 + , KERNEL=="hidraw*", SUBSYSTEM=="hidraw", ATTRS{idVendor}=="03eb", ATTRS{idProduct}=="2402", TAG+="uaccess", TAG+="udev-acl", SYMLINK+="dbbf%n" 22 + , '' 23 + , writeText 24 + }: 25 + 26 + # Enabling the digitalbitbox program 27 + # 28 + # programs.digitalbitbox.enable = true; 29 + # 30 + # will install the digitalbitbox package and enable the corresponding hardware 31 + # module and is by far the easiest way to get started with the Digital Bitbox on 32 + # NixOS. 33 + 34 + # In case you install the package only, please be aware that you may need to 35 + # apply some udev rules to allow the application to identify and access your 36 + # wallet. In a nixos-configuration, one may accomplish this by enabling the 37 + # digitalbitbox hardware module 38 + # 39 + # hardware.digitalbitbox.enable = true; 40 + # 41 + # or by adding the digitalbitbox package to system.udev.packages 42 + # 43 + # system.udev.packages = [ pkgs.digitalbitbox ]; 44 + 45 + # See https://digitalbitbox.com/start_linux for more information. 46 + let 47 + copyUdevRuleToOutput = name: rule: 48 + "cp ${writeText name rule} $out/etc/udev/rules.d/${name}"; 49 + in stdenv.mkDerivation rec { 50 + name = "digitalbitbox-${version}"; 51 + version = "2.2.2"; 52 + 53 + src = fetchFromGitHub { 54 + owner = "digitalbitbox"; 55 + repo = "dbb-app"; 56 + rev = "v${version}"; 57 + sha256 = "1r77fvqrlaryzij5dfbnigzhvg1d12g96qb2gp8dy3xph1j0k3s1"; 58 + }; 59 + 60 + nativeBuildInputs = with stdenv.lib; [ 61 + autoreconfHook 62 + curl 63 + git 64 + makeWrapper 65 + pkgconfig 66 + qttools 67 + ]; 68 + 69 + buildInputs = with stdenv.lib; [ 70 + libevent 71 + libtool 72 + libudev 73 + libusb 74 + libqrencode 75 + 76 + qtbase 77 + qtwebsockets 78 + qtmultimedia 79 + ]; 80 + 81 + LUPDATE="${qttools.dev}/bin/lupdate"; 82 + LRELEASE="${qttools.dev}/bin/lrelease"; 83 + MOC="${qtbase.dev}/bin/moc"; 84 + QTDIR="${qtbase.dev}"; 85 + RCC="${qtbase.dev}/bin/rcc"; 86 + UIC="${qtbase.dev}/bin/uic"; 87 + 88 + configureFlags = [ 89 + "--enable-libusb" 90 + ]; 91 + 92 + hardeningDisable = [ 93 + "format" 94 + ]; 95 + 96 + postInstall = '' 97 + mkdir -p "$out/lib" 98 + cp src/libbtc/.libs/*.so* $out/lib 99 + cp src/libbtc/src/secp256k1/.libs/*.so* $out/lib 100 + cp src/hidapi/libusb/.libs/*.so* $out/lib 101 + cp src/univalue/.libs/*.so* $out/lib 102 + 103 + # [RPATH][patchelf] Avoid forbidden reference error 104 + rm -rf $PWD 105 + 106 + wrapProgram "$out/bin/dbb-cli" --prefix LD_LIBRARY_PATH : "$out/lib" 107 + wrapProgram "$out/bin/dbb-app" --prefix LD_LIBRARY_PATH : "$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 + meta = with stdenv.lib; { 116 + description = "A QT based application for the Digital Bitbox hardware wallet"; 117 + longDescription = '' 118 + Digital Bitbox provides dbb-app, a GUI tool, and dbb-cli, a CLI tool, to manage Digital Bitbox devices. 119 + 120 + 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 121 + 122 + hardware.digitalbitbox.enable = true; 123 + 124 + to the configuration which is equivalent to adding this package to the udev.packages list. 125 + 126 + 127 + The easiest way to use the digitalbitbox package in NixOS is by adding 128 + 129 + programs.digitalbitbox.enable = true; 130 + 131 + to the configuration which installs the package and enables the hardware module. 132 + ''; 133 + homepage = "https://digitalbitbox.com/"; 134 + license = licenses.mit; 135 + maintainers = with maintainers; [ 136 + vidbina 137 + ]; 138 + platforms = platforms.linux; 139 + }; 140 + }
+2
pkgs/top-level/all-packages.nix
··· 121 121 122 122 dieHook = makeSetupHook {} ../build-support/setup-hooks/die.sh; 123 123 124 + digitalbitbox = libsForQt5.callPackage ../applications/misc/digitalbitbox { }; 125 + 124 126 # go 1.9 pin until https://github.com/moby/moby/pull/35739 125 127 dockerTools = callPackage ../build-support/docker { go = go_1_9; }; 126 128