summaryrefslogtreecommitdiffstats
path: root/nixos/modules/hardware/coral.nix
blob: 4b0cadfc3cf0016330e3fac717aee676c174fc63 (plain)
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
{
  config,
  lib,
  pkgs,
  ...
}:

let
  inherit (lib)
    mkEnableOption
    mkIf
    mkMerge
    ;

  cfg = config.hardware.coral;
in

{
  options.hardware.coral = {
    usb.enable = mkEnableOption "Coral USB support";
    pcie.enable = mkEnableOption "Coral PCIe support";
  };

  config = mkMerge [
    (mkIf (cfg.usb.enable || cfg.pcie.enable) {
      users.groups.coral = { };
    })
    (mkIf cfg.usb.enable {
      services.udev.packages = with pkgs; [ libedgetpu ];
    })
    (mkIf cfg.pcie.enable {
      boot.extraModulePackages = with config.boot.kernelPackages; [ gasket ];
      services.udev.extraRules = ''
        SUBSYSTEM=="apex",MODE="0660",GROUP="coral"
      '';
    })
  ];
}