latest work with timers
This commit is contained in:
1 parent
53ed7ca778
commit
de1311fbf9
6 files changed
+93
-54
No files matched your search
@@ -7,5 +7,6 @@
|
||||
./arrs
|
||||
./k8s
|
||||
./services
|
||||
./timers
|
||||
];
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
{ config, lib, ... }:
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.skyg.nixos.server.services.dockge;
|
||||
@@ -7,19 +7,7 @@ in
|
||||
options = {
|
||||
skyg.nixos.server.services.dockge = {
|
||||
enable = lib.mkEnableOption
|
||||
"Enable Scrypted";
|
||||
stacksDir = lib.mkOption {
|
||||
description =
|
||||
"Path to where the stacks are stored";
|
||||
default = "/opt/dockge/stacks";
|
||||
type = lib.types.str;
|
||||
};
|
||||
dataDir = lib.mkOption {
|
||||
description =
|
||||
"Path to where the data dir is stored";
|
||||
default = "/opt/dockge/data";
|
||||
type = lib.types.str;
|
||||
};
|
||||
"Enable Dockge";
|
||||
openFirewall = lib.mkOption {
|
||||
description =
|
||||
"Open ports in the firewall for the Audiobookshelf web interface.";
|
||||
@@ -40,6 +28,30 @@ in
|
||||
allowedTCPPorts = [ cfg.port ];
|
||||
allowedUDPPorts = [ cfg.port ];
|
||||
};
|
||||
system.activationScripts = {
|
||||
dockge-create-volume-stacks = {
|
||||
text = ''
|
||||
${pkgs.docker}/bin/docker volume create \
|
||||
--driver local \
|
||||
--opt type=nfs \
|
||||
--opt o=addr=terra1.lab.internal,rw,nfsvers=4.0,nolock,hard,noatime \
|
||||
--opt device=:/mnt/Data/apps/arrs/dockge/stacks \
|
||||
dockge-stacks
|
||||
'';
|
||||
deps = [ ];
|
||||
};
|
||||
dockge-create-volume-data = {
|
||||
text = ''
|
||||
${pkgs.docker}/bin/docker volume create \
|
||||
--driver local \
|
||||
--opt type=nfs \
|
||||
--opt o=addr=terra1.lab.internal,rw,nfsvers=4.0,nolock,hard,noatime \
|
||||
--opt device=:/mnt/Data/apps/arrs/dockge/data \
|
||||
dockge-data
|
||||
'';
|
||||
deps = [ ];
|
||||
};
|
||||
};
|
||||
virtualisation.oci-containers = {
|
||||
containers = {
|
||||
dockge = {
|
||||
@@ -50,8 +62,8 @@ in
|
||||
];
|
||||
volumes = [
|
||||
"/var/run/docker.sock:/var/run/docker.sock"
|
||||
"${cfg.dataDir}:/app/data"
|
||||
"${cfg.stacksDir}:/opt/stacks"
|
||||
''dockge-data:/app/data''
|
||||
''dockge-stacks:/opt/stacks''
|
||||
];
|
||||
environment = {
|
||||
DOCKGE_STACKS_DIR = "/opt/stacks";
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{ config, lib, ... }:
|
||||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.skyg.nixos.server.services.scrypted;
|
||||
@@ -12,17 +12,36 @@ in
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
system.activationScripts = {
|
||||
scrypted-create-volume-nvr = {
|
||||
text = ''
|
||||
${pkgs.docker}/bin/docker volume create \
|
||||
--driver local \
|
||||
--opt type=nfs \
|
||||
--opt o=addr=tnas1.lab.internal,rw,nfsvers=4.0,nolock,hard,noatime \
|
||||
--opt device=:/mnt/EightTerra/NVR \
|
||||
scrypted-nvr
|
||||
'';
|
||||
deps = [ ];
|
||||
};
|
||||
};
|
||||
skyg.server.timers.scrypted-backups = {
|
||||
script = ''
|
||||
set -eu
|
||||
${pkgs.rsync}/bin/rsync -avpzP --delete /opt/homelab/scrypted /mnt/terra1/Data/apps/
|
||||
'';
|
||||
};
|
||||
virtualisation.oci-containers = {
|
||||
containers = {
|
||||
scrypted = {
|
||||
autoStart = true;
|
||||
autoStart = false;
|
||||
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"
|
||||
"scrypted-nvr:/nvr"
|
||||
];
|
||||
environment = {
|
||||
SCRYPTED_NVR_VOLUME = "/nvr";
|
||||
|
||||
@@ -7,32 +7,38 @@ in {
|
||||
script = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
};
|
||||
timerConfig = lib.mkOption {
|
||||
type = lib.types.submodule;
|
||||
OnCalendar = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "daily";
|
||||
};
|
||||
});
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.timers."backup-jellyfin" = {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnCalendar = "daily";
|
||||
Persistent = true;
|
||||
Unit = "backup-jellyfin.service";
|
||||
};
|
||||
};
|
||||
config = {
|
||||
systemd.timers = builtins.mapAttrs
|
||||
(
|
||||
name: value: {
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnCalendar = value.OnCalendar;
|
||||
Persistent = true;
|
||||
Unit = "${name}.service";
|
||||
};
|
||||
}
|
||||
)
|
||||
cfg;
|
||||
|
||||
systemd.services."backup-jellyfin" = {
|
||||
script = ''
|
||||
set -eu
|
||||
${pkgs.rsync}/bin/rsync -avpzP --delete /opt/jellyfin /mnt/terra1/Data/apps/
|
||||
'';
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = "root";
|
||||
};
|
||||
};
|
||||
systemd.services = builtins.mapAttrs
|
||||
(
|
||||
name: value: {
|
||||
script = value.script;
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = "root";
|
||||
};
|
||||
}
|
||||
)
|
||||
cfg;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user