unmanic, calibre

This commit is contained in:
mjallen18
2025-10-02 21:26:27 -05:00
parent e72d1b5d93
commit ee48ca08bd
11 changed files with 320 additions and 116 deletions

View File

@@ -20,7 +20,7 @@ in
user = "nix-apps";
group = "jallen-nas";
openFirewall = true;
acceleration = "cuda";
acceleration = "rocm";
home = "/media/nas/main/nix-app-data/ollama";
};

View File

@@ -0,0 +1,152 @@
{
config,
pkgs,
lib,
namespace,
...
}:
with lib;
let
inherit (lib.${namespace}) mkOpt mkReverseProxyOpt;
cfg = config.${namespace}.services.calibre;
# dataDir = "/library";
# hostAddress = "10.0.1.3";
# calibreUserId = config.users.users.nix-apps.uid;
# calibreGroupId = config.users.groups.jallen-nas.gid;
# calibreConfig =
# { lib, ... }:
# {
# services.calibre-server = {
# enable = true;
# openFirewall = true;
# libraries = [
# dataDir
# ];
# };
# services.calibre-web = {
# enable = true;
# openFirewall = true;
# listen = {
# ip = "0.0.0.0";
# port = cfg.port;
# };
# options = {
# enableBookUploading = true;
# enableBookConversion = true;
# calibreLibrary = dataDir;
# };
# };
# users.users.calibre = {
# isSystemUser = true;
# uid = lib.mkForce calibreUserId;
# group = "calibre";
# };
# users.groups = {
# calibre-web = {
# gid = lib.mkForce calibreGroupId;
# };
# };
# networking = {
# firewall = {
# enable = true;
# allowedTCPPorts = [ cfg.port ];
# };
# # Use systemd-resolved inside the container
# # Workaround for bug https://github.com/NixOS/nixpkgs/issues/162686
# useHostResolvConf = lib.mkForce false;
# };
# services.resolved.enable = true;
# system.stateVersion = "23.11";
# };
# bindMounts = {
# ${dataDir} = {
# hostPath = cfg.dataDir;
# isReadOnly = false;
# };
# "/var/lib/calibre-web" = {
# hostPath = cfg.webDir;
# isReadOnly = false;
# };
# };
# Create reverse proxy configuration using mkReverseProxy
reverseProxyConfig = lib.${namespace}.mkReverseProxy {
name = "calibre";
subdomain = cfg.reverseProxy.subdomain;
url = "http://${cfg.localAddress}:${toString cfg.port}";
middlewares = cfg.reverseProxy.middlewares;
};
# calibreContainer =
# (lib.${namespace}.mkContainer {
# name = "calibre";
# localAddress = cfg.localAddress;
# port = cfg.port;
# bindMounts = bindMounts;
# config = calibreConfig;
# })
# { inherit lib; };
# fullConfig = {
# ${namespace}.services.traefik = lib.mkIf cfg.reverseProxy.enable {
# reverseProxies = [ reverseProxyConfig ];
# };
# }
# // calibreContainer;
in
{
options.${namespace}.services.calibre = {
enable = mkEnableOption "calibre service";
port = mkOpt types.int 8080 "Port for calibre to be hosted on";
webPort = mkOpt types.int 8083 "Port for calibre web to be hosted on";
localAddress = mkOpt types.str "127.0.0.1" "local address of the service";
dataDir = mkOpt types.str "/media/nas/main/books" "Path to the data dir";
webDir = mkOpt types.str "/media/nas/main/nix-app-data/calibre-web" "Path to the web data dir";
reverseProxy = mkReverseProxyOpt;
};
config = mkIf cfg.enable {
${namespace}.services.traefik = lib.mkIf cfg.reverseProxy.enable {
reverseProxies = [ reverseProxyConfig ];
};
services = {
calibre-server = {
enable = false;
openFirewall = true;
port = cfg.port;
libraries = [
cfg.dataDir
];
};
calibre-web = {
enable = true;
openFirewall = true;
dataDir = cfg.webDir;
listen = {
ip = "0.0.0.0";
port = cfg.webPort;
};
options = {
enableBookUploading = true;
enableBookConversion = true;
calibreLibrary = cfg.dataDir;
};
};
};
};
}

View File

@@ -183,8 +183,6 @@ in
# System packages
environment.systemPackages = with pkgs; [
cudaPackages.cudnn
cudatoolkit
ffmpeg
# libtensorflow-bin
nextcloud31

View File

@@ -0,0 +1,61 @@
{
lib,
config,
namespace,
...
}:
with lib;
let
inherit (lib.${namespace}) mkOpt mkReverseProxyOpt;
cfg = config.${namespace}.services.unmanic;
in
{
options.${namespace}.services.unmanic = {
enable = mkEnableOption "unmanic service";
name = mkOpt types.str "unmanic" "container name";
image = mkOpt types.str "josh5/unmanic" "container image";
port = mkOpt types.int 8265 "Port for unmanic to be hosted on";
configPath = mkOpt types.str "" "Path to the data dir";
moviesPath = mkOpt types.str "" "Path to the data dir";
tvPath = mkOpt types.str "" "Path to the data dir";
transcodePath = mkOpt types.str "" "Path to the data dir";
puid = mkOpt types.str "911" "uid";
pgid = mkOpt types.str "1000" "gid";
timeZone = mkOpt types.str "America/Chicago" "Timezone";
reverseProxy = mkReverseProxyOpt;
};
config = mkIf cfg.enable {
virtualisation.oci-containers.containers.${cfg.name} = {
autoStart = true;
image = cfg.image;
extraOptions = [ "--device=/dev/dri" ];
volumes = [
"${cfg.configPath}:/config"
"${cfg.moviesPath}:/library/movies"
"${cfg.tvPath}:/library/tv"
"${cfg.transcodePath}:/tmp/unmanic"
];
ports = [
"${toString cfg.port}:8888"
];
environment = {
PUID = cfg.puid;
PGID = cfg.pgid;
TZ = cfg.timeZone;
};
};
};
}

View File

@@ -16,7 +16,7 @@ in
faster-whisper.servers.hass-whisper = {
enable = true;
useTransformers = false;
device = lib.mkForce "cuda";
device = lib.mkForce "auto";
language = "en";
model = "distil-large-v3";
uri = "tcp://0.0.0.0:10300";