summary refs log tree commit diff
path: root/nixos/modules/hardware
diff options
context:
space:
mode:
authorFranz Pletz <fpletz@fnordicwalking.de>2017-05-25 00:01:07 +0200
committerFranz Pletz <fpletz@fnordicwalking.de>2017-05-26 00:47:46 +0200
commit839647e630474aeb172540df4305a26a70343766 (patch)
tree0623a217b09aaad4554139ca21f0fc9055e6f7a0 /nixos/modules/hardware
parent5e4a797888e0612f00a0509918d1d9aaa5219d9d (diff)
downloadnixlib-839647e630474aeb172540df4305a26a70343766.tar
nixlib-839647e630474aeb172540df4305a26a70343766.tar.gz
nixlib-839647e630474aeb172540df4305a26a70343766.tar.bz2
nixlib-839647e630474aeb172540df4305a26a70343766.tar.lz
nixlib-839647e630474aeb172540df4305a26a70343766.tar.xz
nixlib-839647e630474aeb172540df4305a26a70343766.tar.zst
nixlib-839647e630474aeb172540df4305a26a70343766.zip
nitrokey module: init
Diffstat (limited to 'nixos/modules/hardware')
-rw-r--r--nixos/modules/hardware/nitrokey.nix41
1 files changed, 41 insertions, 0 deletions
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}" = {};
+  };
+}