From 2b2a669741df5025854714a9bb4ee61b02aef682 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Thu, 21 Nov 2024 14:56:52 +0100 Subject: [PATCH] nixos/coral: init Provides a small wrapper to enable support for Coral USB and PCIe devices. --- .../manual/release-notes/rl-2411.section.md | 2 + nixos/modules/hardware/coral.nix | 38 +++++++++++++++++++ nixos/modules/module-list.nix | 1 + 3 files changed, 41 insertions(+) create mode 100644 nixos/modules/hardware/coral.nix diff --git a/nixos/doc/manual/release-notes/rl-2411.section.md b/nixos/doc/manual/release-notes/rl-2411.section.md index e62065775b91..22ae9f241409 100644 --- a/nixos/doc/manual/release-notes/rl-2411.section.md +++ b/nixos/doc/manual/release-notes/rl-2411.section.md @@ -85,6 +85,8 @@ ## New Modules {#sec-release-24.11-new-modules} +- [Coral](https://coral.ai/), hardware support for Coral.ai Edge TPU devices. Available as [hardware.coral.usb.enable](#opt-hardware.coral.usb.enable) and [hardware.coral.pcie.enable](#opt-hardware.coral.pcie.enable). + - [Cyrus IMAP](https://github.com/cyrusimap/cyrus-imapd), an email, contacts and calendar server. Available as [services.cyrus-imap](#opt-services.cyrus-imap.enable) service. - [TaskChampion Sync-Server](https://github.com/GothenburgBitFactory/taskchampion-sync-server), a [Taskwarrior 3](https://taskwarrior.org/docs/upgrade-3/) sync server. Available as [services.taskchampion-sync-server](#opt-services.taskchampion-sync-server.enable). diff --git a/nixos/modules/hardware/coral.nix b/nixos/modules/hardware/coral.nix new file mode 100644 index 000000000000..4b0cadfc3cf0 --- /dev/null +++ b/nixos/modules/hardware/coral.nix @@ -0,0 +1,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" + ''; + }) + ]; +} diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index cc107eefe505..a1b8f52c0773 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -52,6 +52,7 @@ ./hardware/bladeRF.nix ./hardware/brillo.nix ./hardware/ckb-next.nix + ./hardware/coral.nix ./hardware/corectrl.nix ./hardware/cpu/amd-microcode.nix ./hardware/cpu/amd-sev.nix