about summary refs log tree commit diff
path: root/nixpkgs/nixos/modules/hardware/nitrokey.nix
blob: 02e4c3f46f8d28b590e75aef0d95a9d67393c1f7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
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.groups.${cfg.group} = {};
  };
}