refactor(wyoming+): assert instead of import docker module
All checks were successful
Discord / discord commits (push) Has been skipped

This commit is contained in:
matt1432 2024-09-05 08:48:42 -04:00
parent e61ada3cd2
commit 79e642451a
5 changed files with 28 additions and 11 deletions

View file

@ -13,6 +13,7 @@ in {
./modules ./modules
self.nixosModules.docker
self.nixosModules.kmscon self.nixosModules.kmscon
self.nixosModules.server self.nixosModules.server
]; ];

View file

@ -13,6 +13,7 @@ in {
./modules ./modules
self.nixosModules.docker
self.nixosModules.kmscon self.nixosModules.kmscon
self.nixosModules.server self.nixosModules.server
]; ];

View file

@ -7,5 +7,5 @@ self: {
nvidia = import ./nvidia; nvidia = import ./nvidia;
plymouth = import ./plymouth; plymouth = import ./plymouth;
server = import ./server; server = import ./server;
wyoming-plus = import ./wyoming-plus self; wyoming-plus = import ./wyoming-plus;
} }

View file

@ -4,9 +4,10 @@ khepri: {
pkgs, pkgs,
... ...
}: let }: let
inherit (lib) mkOption types; inherit (lib) mkIf mkOption types;
inherit (config.vars) mainUser; inherit (config.vars) mainUser;
cfg = config.khepri;
in { in {
imports = [khepri.nixosModules.default]; imports = [khepri.nixosModules.default];
@ -18,15 +19,20 @@ in {
Directory to place persistent data in. Directory to place persistent data in.
''; '';
}; };
storageDriver = mkOption {
default = "btrfs"; # I use BTRFS on all my servers
type = types.str;
};
}; };
config = { config = mkIf (cfg.compositions != {}) {
users.extraUsers.${mainUser}.extraGroups = ["docker"]; users.extraUsers.${mainUser}.extraGroups = ["docker"];
virtualisation = { virtualisation = {
docker = { docker = {
enable = true; enable = true;
storageDriver = "btrfs"; storageDriver = cfg.storageDriver;
package = pkgs.docker_27; package = pkgs.docker_27;

View file

@ -1,4 +1,4 @@
self: { {
config, config,
lib, lib,
pkgs, pkgs,
@ -10,6 +10,7 @@ self: {
escapeShellArgs escapeShellArgs
flatten flatten
filterAttrs filterAttrs
hasAttr
listToAttrs listToAttrs
map map
mkEnableOption mkEnableOption
@ -26,8 +27,6 @@ self: {
cfg = config.services.wyoming.openwakeword-docker; cfg = config.services.wyoming.openwakeword-docker;
in { in {
imports = [self.nixosModules.docker];
options.services.wyoming.openwakeword-docker = { options.services.wyoming.openwakeword-docker = {
enable = mkEnableOption "Wyoming openWakeWord server"; enable = mkEnableOption "Wyoming openWakeWord server";
@ -114,6 +113,19 @@ in {
}; };
config = { config = {
assertions = [
{
assertion =
(cfg.enable
&& hasAttr "khepri" config
&& hasAttr "rwDataDir" config.khepri) || !cfg.enable;
message = ''
The module `docker` from this same flake is needed to use
this openwakeword implementation.
'';
}
];
systemd.services = let systemd.services = let
unitNames = attrNames ( unitNames = attrNames (
filterAttrs (_: v: v.device == "cpu") config.services.wyoming.faster-whisper.servers filterAttrs (_: v: v.device == "cpu") config.services.wyoming.faster-whisper.servers
@ -147,7 +159,4 @@ in {
}; };
}; };
}; };
# For accurate stack trace
_file = ./default.nix;
} }