refactor services
This commit is contained in:
1 parent
a27d701bac
commit
52ae9d193b
8 files changed
+47
-27
No files matched your search
@@ -0,0 +1,57 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.skyg.nixos.server.services.ai;
|
||||
openPorts = [
|
||||
11434
|
||||
10400
|
||||
10300
|
||||
10200
|
||||
];
|
||||
in
|
||||
{
|
||||
options = {
|
||||
skyg.nixos.server.services.ai = {
|
||||
enable = mkEnableOption
|
||||
"Enable AI Services";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
networking.firewall.allowedUDPPorts = openPorts;
|
||||
networking.firewall.allowedTCPPorts = openPorts;
|
||||
virtualisation.oci-containers = {
|
||||
containers = {
|
||||
ollama = {
|
||||
autoStart = true;
|
||||
image = "ollama/ollama";
|
||||
extraOptions = [ "--gpus" "all" ];
|
||||
ports = [ "11434:11434" ];
|
||||
volumes = [ "ollama:/root/.ollama" ];
|
||||
};
|
||||
openwakeword = {
|
||||
autoStart = true;
|
||||
image = "rhasspy/wyoming-openwakeword";
|
||||
cmd = [ "--preload-model" "ok_nabu" ];
|
||||
ports = [ "10400:10400" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
services.wyoming = {
|
||||
faster-whisper.servers.main-eng = {
|
||||
enable = true;
|
||||
device = "cpu";
|
||||
model = "medium.en";
|
||||
language = "en";
|
||||
uri = "tcp://0.0.0.0:10300";
|
||||
};
|
||||
piper.servers.pier = {
|
||||
enable = true;
|
||||
uri = "tcp://0.0.0.0:10200";
|
||||
voice = "en_GB-alan-medium";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let cfg = config.skyg.nixos.server.services.audiobookshelf;
|
||||
in {
|
||||
options = {
|
||||
skyg.nixos.server.services.audiobookshelf = {
|
||||
enable = mkEnableOption
|
||||
"Audiobookshelf, self-hosted audiobook and podcast server.";
|
||||
|
||||
package = mkPackageOption pkgs "audiobookshelf" { };
|
||||
|
||||
configDir = mkOption {
|
||||
description =
|
||||
"Path to Audiobookshelf config folder";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
dataDir = mkOption {
|
||||
description = "Path to Audiobookshelf config and metadata inside of /var/lib.";
|
||||
default = "audiobookshelf";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
metadtaDir = mkOption {
|
||||
description =
|
||||
"Path to Audiobookshelf config folder";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
host = mkOption {
|
||||
description = "The host Audiobookshelf binds to.";
|
||||
default = "127.0.0.1";
|
||||
example = "0.0.0.0";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
port = mkOption {
|
||||
description = "The TCP port Audiobookshelf will listen on.";
|
||||
default = 8000;
|
||||
type = types.port;
|
||||
};
|
||||
|
||||
user = mkOption {
|
||||
description = "User account under which Audiobookshelf runs.";
|
||||
default = "audiobookshelf";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
group = mkOption {
|
||||
description = "Group under which Audiobookshelf runs.";
|
||||
default = "audiobookshelf";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
openFirewall = mkOption {
|
||||
description =
|
||||
"Open ports in the firewall for the Audiobookshelf web interface.";
|
||||
default = false;
|
||||
type = types.bool;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
systemd.services.audiobookshelf = {
|
||||
description =
|
||||
"Audiobookshelf is a self-hosted audiobook and podcast server";
|
||||
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
User = cfg.user;
|
||||
Group = cfg.group;
|
||||
StateDirectory = cfg.dataDir;
|
||||
WorkingDirectory = "/var/lib/${cfg.dataDir}";
|
||||
ExecStart =
|
||||
"${cfg.package}/bin/audiobookshelf --host ${cfg.host} --port ${
|
||||
toString cfg.port
|
||||
} --config ${cfg.configDir} --metadata ${cfg.metadtaDir}";
|
||||
Restart = "on-failure";
|
||||
};
|
||||
};
|
||||
|
||||
users.users = mkIf (cfg.user == "audiobookshelf") {
|
||||
audiobookshelf = {
|
||||
isSystemUser = true;
|
||||
group = cfg.group;
|
||||
home = "/var/lib/${cfg.dataDir}";
|
||||
};
|
||||
};
|
||||
|
||||
users.groups =
|
||||
mkIf (cfg.group == "audiobookshelf") { audiobookshelf = { }; };
|
||||
|
||||
networking.firewall =
|
||||
mkIf cfg.openFirewall { allowedTCPPorts = [ cfg.port ]; };
|
||||
};
|
||||
|
||||
meta.maintainers = with maintainers; [ wietsedv ];
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{ ... }:
|
||||
{
|
||||
imports = [
|
||||
./audiobookshelf.nix
|
||||
./ai-services.nix
|
||||
./jellyfin.nix
|
||||
];
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
cfg = config.skyg.nixos.server.services.jellyfin;
|
||||
user = "jellyfin";
|
||||
group = "jellyfin";
|
||||
in
|
||||
{
|
||||
options = {
|
||||
skyg.nixos.server.services.jellyfin = {
|
||||
enable = mkEnableOption
|
||||
"Enable Jellyfish";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
users.users.${user} = {
|
||||
uid = 7777;
|
||||
isSystemUser = true;
|
||||
};
|
||||
users.groups.${group} = {
|
||||
gid = 7777;
|
||||
members = [
|
||||
user
|
||||
config.skyg.user.name
|
||||
];
|
||||
};
|
||||
users.groups.www-data.members = [
|
||||
user
|
||||
];
|
||||
services.jellyfin = {
|
||||
inherit user group;
|
||||
enable = true;
|
||||
dataDir = "/mnt/apps/jellyfin/data";
|
||||
cacheDir = "/mnt/apps/jellyfin/cache";
|
||||
configDir = "/mnt/apps/jellyfin/config";
|
||||
openFirewall = true;
|
||||
};
|
||||
fileSystems."/mnt/apps/jellyfin" = {
|
||||
device = "terra1.lab.internal:/mnt/Data/apps/jellyfin";
|
||||
fsType = "nfs";
|
||||
options = [ "x-systemd.automount" "noauto" ];
|
||||
};
|
||||
fileSystems."/family-videos" = {
|
||||
device = "tnas1.lab.internal:/mnt/EightTerra/FamilyStorage/Video";
|
||||
fsType = "nfs";
|
||||
options = [ "x-systemd.automount" "noauto" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
{ config, lib, ... }:
|
||||
|
||||
let
|
||||
cfg = config.skyg.nixos.server.services.scrypted;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
skyg.nixos.server.services.scrypted = {
|
||||
enable = lib.mkEnableOption
|
||||
"Enable Scrypted";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
virtualisation.oci-containers = {
|
||||
containers = {
|
||||
scrypted = {
|
||||
autoStart = true;
|
||||
image = "ghcr.io/koush/scrypted";
|
||||
extraOptions = [ "--network=host" ];
|
||||
volumes = [
|
||||
"/var/run/dbus:/var/run/dbus"
|
||||
"/var/run/avahi-daemon/socket:/var/run/avahi-daemon/socket"
|
||||
"/opt/homelab/scrypted/db:/server/volume"
|
||||
"/mnt/EightTerra/NVR:/nvr"
|
||||
];
|
||||
environment = {
|
||||
SCRYPTED_NVR_VOLUME = "/nvr";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user