feat: migrate remaining applications, services, and user configurations
This commit is contained in:
parent
3a8f6e6451
commit
2960480557
26 changed files with 2903 additions and 0 deletions
189
modules/apps/calibre/default.nix
Normal file
189
modules/apps/calibre/default.nix
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.homelab.apps.calibre;
|
||||
|
||||
PUID = toString config.users.users.calibre.uid;
|
||||
PGID = toString config.users.groups.media.gid;
|
||||
|
||||
books = "/srv/books";
|
||||
calibre-config = "/srv/calibre-config";
|
||||
calibre-web-config = "/srv/calibre-web-config";
|
||||
|
||||
networkName = "calibre";
|
||||
proxyNet = config.homelab.apps.traefik.sharedNetworkName;
|
||||
in {
|
||||
options.homelab.apps.calibre = {
|
||||
enable = lib.mkEnableOption "Calibre (Desktop + Web)";
|
||||
desktop.enable = lib.mkEnableOption "Calibre Desktop (KasmVNC)";
|
||||
web.enable = lib.mkEnableOption "Calibre Web";
|
||||
};
|
||||
|
||||
config = lib.mkMerge [
|
||||
{
|
||||
homelab.apps.calibre = lib.mkIf cfg.enable {
|
||||
desktop.enable = true;
|
||||
web.enable = true;
|
||||
};
|
||||
}
|
||||
|
||||
# Common
|
||||
(lib.mkIf (cfg.desktop.enable || cfg.web.enable) {
|
||||
homelab = {
|
||||
users.media.enable = true;
|
||||
virtualisation.containers.enable = true;
|
||||
};
|
||||
|
||||
users.users.calibre = {
|
||||
uid = lib.mkForce 3010;
|
||||
isSystemUser = true;
|
||||
group = config.users.groups.media.name;
|
||||
home = "/var/empty";
|
||||
shell = null;
|
||||
};
|
||||
|
||||
fileSystems."${books}" = {
|
||||
device = "192.168.0.11:/mnt/SMALL/MEDIA/BOOKS";
|
||||
fsType = "nfs";
|
||||
options = [
|
||||
"rw"
|
||||
"auto"
|
||||
"nfsvers=4.2"
|
||||
"rsize=1048576" "wsize=1048576"
|
||||
"soft"
|
||||
"timeo=600" "retrans=2"
|
||||
"_netdev" "nosuid" "tcp"
|
||||
];
|
||||
};
|
||||
|
||||
# Make sure the Docker network exists.
|
||||
systemd.services."docker-${networkName}-create-network" = {
|
||||
requiredBy = [
|
||||
"docker-calibre.service"
|
||||
];
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
RemainAfterExit = true;
|
||||
};
|
||||
script = ''
|
||||
if ! ${pkgs.docker}/bin/docker network ls | grep -q ${networkName}; then
|
||||
${pkgs.docker}/bin/docker network create ${networkName}
|
||||
fi
|
||||
'';
|
||||
};
|
||||
})
|
||||
|
||||
# Calibre desktop
|
||||
(lib.mkIf cfg.desktop.enable {
|
||||
fileSystems."${calibre-config}" = {
|
||||
device = "192.168.0.11:/mnt/SMALL/CONFIG/CALIBRE";
|
||||
fsType = "nfs";
|
||||
options = [
|
||||
"rw"
|
||||
"auto"
|
||||
"nfsvers=4.2"
|
||||
"rsize=1048576" "wsize=1048576"
|
||||
"soft"
|
||||
"timeo=600" "retrans=2"
|
||||
"_netdev" "nosuid" "tcp"
|
||||
];
|
||||
};
|
||||
|
||||
virtualisation.oci-containers.containers.calibre = let
|
||||
innerPort = 8080;
|
||||
in {
|
||||
hostname = "calibre";
|
||||
image = "lscr.io/linuxserver/calibre:v8.10.0-ls354";
|
||||
autoStart = true;
|
||||
ports = [
|
||||
# Open ports if you don't use Traefik
|
||||
"9480:${toString innerPort}" # Calibre desktop GUI
|
||||
#"9481:8181" # Calibre desktop GUI HTTPS
|
||||
#"9581:8081" # Calibre webserver gui
|
||||
];
|
||||
extraOptions = [
|
||||
"--network=${networkName}"
|
||||
"--network=${proxyNet}"
|
||||
|
||||
# syscalls are unkown to Docker
|
||||
#"--security-opt" "seccomp=unconfined"
|
||||
];
|
||||
environment = {
|
||||
inherit PUID PGID;
|
||||
#UMASK = "022";
|
||||
|
||||
TZ = config.time.timeZone;
|
||||
|
||||
#PASSWORD = "";
|
||||
#CLI_ARGS = "";
|
||||
};
|
||||
volumes = [
|
||||
"${calibre-config}:/config"
|
||||
|
||||
"${books}:/media/books"
|
||||
];
|
||||
labels = {
|
||||
"traefik.enable" = "true";
|
||||
"traefik.docker.network" = proxyNet;
|
||||
"traefik.http.routers.calibre.rule" = "Host(`calibre.depeuter.dev`)";
|
||||
"traefik.http.services.calibre.loadbalancer.server.port" = toString innerPort;
|
||||
};
|
||||
};
|
||||
})
|
||||
|
||||
# Calibre Web
|
||||
(lib.mkIf cfg.web.enable {
|
||||
fileSystems."${calibre-web-config}" = {
|
||||
device = "192.168.0.11:/mnt/SMALL/CONFIG/CALIBRE-WEB";
|
||||
fsType = "nfs";
|
||||
options = [
|
||||
"rw"
|
||||
"auto"
|
||||
"nfsvers=4.2"
|
||||
"rsize=1048576" "wsize=1048576"
|
||||
"soft"
|
||||
"timeo=600" "retrans=2"
|
||||
"_netdev" "nosuid" "tcp"
|
||||
];
|
||||
};
|
||||
|
||||
virtualisation.oci-containers.containers.calibre-web = let
|
||||
innerPort = 8083;
|
||||
in {
|
||||
hostname = "calibre-web";
|
||||
image = "lscr.io/linuxserver/calibre-web:0.6.25-ls346";
|
||||
autoStart = true;
|
||||
ports = [
|
||||
# Open ports if you don't use Traefik
|
||||
"8083:${toString innerPort}" # Web UI
|
||||
];
|
||||
extraOptions = [
|
||||
"--network=${networkName}"
|
||||
"--network=${proxyNet}"
|
||||
];
|
||||
environment = {
|
||||
inherit PUID PGID;
|
||||
#UMASK = "022";
|
||||
|
||||
TZ = config.time.timeZone;
|
||||
|
||||
# (x86-64 only) Adds the ability to perform ebook conversion
|
||||
DOCKER_MODS = "linuxserver/mods:universal-calibre";
|
||||
# Allow Google Oauth
|
||||
#OAUTHLIB_RELAX_TOKEN_SCOPE = "1";
|
||||
};
|
||||
volumes = [
|
||||
"${calibre-web-config}:/config"
|
||||
|
||||
"${books}:/media/books"
|
||||
];
|
||||
labels = {
|
||||
"traefik.enable" = "true";
|
||||
"traefik.docker.network" = proxyNet;
|
||||
"traefik.http.routers.calibre-web.rule" = "Host(`books.depeuter.dev`)";
|
||||
"traefik.http.services.calibre-web.loadbalancer.server.port" = toString innerPort;
|
||||
};
|
||||
};
|
||||
})
|
||||
];
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue