From ba002a4215b91ccad0464c29b10c5cc7a2714261 Mon Sep 17 00:00:00 2001 From: Kai Harries Date: Fri, 5 May 2017 22:15:39 +0200 Subject: [PATCH 1/4] nitrokey-app: 0.6.3 -> 1.0 The nitrokey-app is now fetched from git because a submodule is needed for compilation. --- .../nitrokey-app/FixInstallDestination.patch | 11 --------- .../security/nitrokey-app/HeaderPath.patch | 13 ----------- pkgs/tools/security/nitrokey-app/default.nix | 23 ++++++++++--------- 3 files changed, 12 insertions(+), 35 deletions(-) delete mode 100644 pkgs/tools/security/nitrokey-app/FixInstallDestination.patch delete mode 100644 pkgs/tools/security/nitrokey-app/HeaderPath.patch diff --git a/pkgs/tools/security/nitrokey-app/FixInstallDestination.patch b/pkgs/tools/security/nitrokey-app/FixInstallDestination.patch deleted file mode 100644 index 7acd7239b392..000000000000 --- a/pkgs/tools/security/nitrokey-app/FixInstallDestination.patch +++ /dev/null @@ -1,11 +0,0 @@ ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -273,7 +273,7 @@ - # Install autocompletion scripts - install(FILES - ${CMAKE_SOURCE_DIR}/data/bash-autocomplete/nitrokey-app -- DESTINATION /etc/bash_completion.d -+ DESTINATION etc/bash_completion.d - ) - - install(FILES diff --git a/pkgs/tools/security/nitrokey-app/HeaderPath.patch b/pkgs/tools/security/nitrokey-app/HeaderPath.patch deleted file mode 100644 index 695b7559116c..000000000000 --- a/pkgs/tools/security/nitrokey-app/HeaderPath.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/src/utils/hid_libusb.c b/src/utils/hid_libusb.c -index bd8c14e..537292d 100644 ---- a/src/utils/hid_libusb.c -+++ b/src/utils/hid_libusb.c -@@ -44,7 +44,7 @@ - #include - - /* GNU / LibUSB */ --#include "libusb.h" -+#include "libusb-1.0/libusb.h" - #include "iconv.h" - - #include "hidapi.h" diff --git a/pkgs/tools/security/nitrokey-app/default.nix b/pkgs/tools/security/nitrokey-app/default.nix index 5e1baa4f57bf..39504e0b4f5b 100644 --- a/pkgs/tools/security/nitrokey-app/default.nix +++ b/pkgs/tools/security/nitrokey-app/default.nix @@ -1,29 +1,30 @@ -{ stdenv, cmake, fetchFromGitHub, libusb1, pkgconfig, qt5 }: +{ stdenv, cmake, fetchgit, hidapi, libusb1, pkgconfig, qt5 }: stdenv.mkDerivation rec { name = "nitrokey-app"; - version = "0.6.3"; + version = "1.0"; - src = fetchFromGitHub { - owner = "Nitrokey"; - repo = "nitrokey-app"; - rev = "v${version}"; - sha256 = "1l5l4lwxmyd3jrafw19g12sfc42nd43sv7h7i4krqxnkk6gfx11q"; + src = fetchgit { + url = "https://github.com/Nitrokey/nitrokey-app.git"; + rev = "refs/tags/v${version}"; + sha256 = "0i910d1xrl4bfrg5ifkj3w4dp31igaxncy2yf97y4rsc8094bcb1"; }; buildInputs = [ + hidapi libusb1 qt5.qtbase + qt5.qttranslations ]; nativeBuildInputs = [ cmake pkgconfig ]; - patches = [ - ./FixInstallDestination.patch - ./HeaderPath.patch - ]; cmakeFlags = "-DHAVE_LIBAPPINDICATOR=NO"; + postPatch = '' + substituteInPlace CMakeLists.txt --replace 'DESTINATION ''${UDEV_MAIN_DIR}' 'DESTINATION lib/udev/rules.d' + substituteInPlace data/41-nitrokey.rules --replace 'plugdev' 'wheel' + ''; meta = with stdenv.lib; { description = "Provides extra functionality for the Nitrokey Pro and Storage"; longDescription = '' From 932091f33306d2c9b7062f1555377283f38c8f81 Mon Sep 17 00:00:00 2001 From: Franz Pletz Date: Wed, 24 May 2017 23:58:04 +0200 Subject: [PATCH 2/4] nitrokey-app: 1.0 -> 1.1 --- pkgs/tools/security/nitrokey-app/default.nix | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/pkgs/tools/security/nitrokey-app/default.nix b/pkgs/tools/security/nitrokey-app/default.nix index 39504e0b4f5b..1443409c0226 100644 --- a/pkgs/tools/security/nitrokey-app/default.nix +++ b/pkgs/tools/security/nitrokey-app/default.nix @@ -2,12 +2,12 @@ stdenv.mkDerivation rec { name = "nitrokey-app"; - version = "1.0"; + version = "1.1"; src = fetchgit { url = "https://github.com/Nitrokey/nitrokey-app.git"; rev = "refs/tags/v${version}"; - sha256 = "0i910d1xrl4bfrg5ifkj3w4dp31igaxncy2yf97y4rsc8094bcb1"; + sha256 = "11pz1p5qgghkr5f8s2wg34zqhxk2vq465i73w1h479j88x35rdp0"; }; buildInputs = [ @@ -21,10 +21,7 @@ stdenv.mkDerivation rec { pkgconfig ]; cmakeFlags = "-DHAVE_LIBAPPINDICATOR=NO"; - postPatch = '' - substituteInPlace CMakeLists.txt --replace 'DESTINATION ''${UDEV_MAIN_DIR}' 'DESTINATION lib/udev/rules.d' - substituteInPlace data/41-nitrokey.rules --replace 'plugdev' 'wheel' - ''; + meta = with stdenv.lib; { description = "Provides extra functionality for the Nitrokey Pro and Storage"; longDescription = '' @@ -35,6 +32,6 @@ stdenv.mkDerivation rec { homepage = https://github.com/Nitrokey/nitrokey-app; repositories.git = https://github.com/Nitrokey/nitrokey-app.git; license = licenses.gpl3; - maintainer = maintainers.kaiha; + maintainers = with maintainers; [ kaiha fpletz ]; }; } From 5e4a797888e0612f00a0509918d1d9aaa5219d9d Mon Sep 17 00:00:00 2001 From: Franz Pletz Date: Wed, 24 May 2017 23:58:33 +0200 Subject: [PATCH 3/4] nitrokey-udev-rules: init --- .../security/nitrokey-app/udev-rules.nix | 25 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 1 + 2 files changed, 26 insertions(+) create mode 100644 pkgs/tools/security/nitrokey-app/udev-rules.nix diff --git a/pkgs/tools/security/nitrokey-app/udev-rules.nix b/pkgs/tools/security/nitrokey-app/udev-rules.nix new file mode 100644 index 000000000000..99947a0eefef --- /dev/null +++ b/pkgs/tools/security/nitrokey-app/udev-rules.nix @@ -0,0 +1,25 @@ +{ stdenv, nitrokey-app +, group ? "nitrokey" +}: + +stdenv.mkDerivation { + name = "nitrokey-udev-rules"; + + inherit (nitrokey-app) src; + + dontBuild = true; + + patchPhase = '' + substituteInPlace data/41-nitrokey.rules --replace plugdev "${group}" + ''; + + installPhase = '' + mkdir -p $out/etc/udev/rules.d + cp data/41-nitrokey.rules $out/etc/udev/rules.d + ''; + + meta = { + description = "udev rules for Nitrokeys"; + inherit (nitrokey-app.meta) homepage license maintainers; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 1f033de3b8f6..90ed231bf1eb 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -18825,6 +18825,7 @@ with pkgs; xrq = callPackage ../applications/misc/xrq { }; nitrokey-app = callPackage ../tools/security/nitrokey-app { }; + nitrokey-udev-rules = callPackage ../tools/security/nitrokey-app/udev-rules.nix { }; fpm2 = callPackage ../tools/security/fpm2 { }; From 839647e630474aeb172540df4305a26a70343766 Mon Sep 17 00:00:00 2001 From: Franz Pletz Date: Thu, 25 May 2017 00:01:07 +0200 Subject: [PATCH 4/4] nitrokey module: init --- nixos/modules/hardware/nitrokey.nix | 41 +++++++++++++++++++++++++++++ nixos/modules/module-list.nix | 1 + 2 files changed, 42 insertions(+) create mode 100644 nixos/modules/hardware/nitrokey.nix diff --git a/nixos/modules/hardware/nitrokey.nix b/nixos/modules/hardware/nitrokey.nix new file mode 100644 index 000000000000..bd440de69722 --- /dev/null +++ b/nixos/modules/hardware/nitrokey.nix @@ -0,0 +1,41 @@ +{ config, lib, pkgs, ... }: + +with lib; + +let + + cfg = config.hardware.nitrokey; + +in + +{ + options.hardware.nitrokey = { + enable = mkOption { + type = types.bool; + default = false; + description = '' + Enables udev rules for Nitrokey devices. By default grants access + to users in the "nitrokey" group. You may want to install the + nitrokey-app package, depending on your device and needs. + ''; + }; + + group = mkOption { + type = types.str; + default = "nitrokey"; + example = "wheel"; + description = '' + Grant access to Nitrokey devices to users in this group. + ''; + }; + }; + + config = mkIf cfg.enable { + services.udev.packages = [ + (pkgs.nitrokey-udev-rules.override (attrs: + { inherit (cfg) group; } + )) + ]; + users.extraGroups."${cfg.group}" = {}; + }; +} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index a3405c069b34..1bd9001b5540 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -39,6 +39,7 @@ ./hardware/network/intel-3945abg.nix ./hardware/network/ralink.nix ./hardware/network/rtl8192c.nix + ./hardware/nitrokey.nix ./hardware/opengl.nix ./hardware/pcmcia.nix ./hardware/usb-wwan.nix