Skip to content

Commit d9ea977

Browse files
committed
Add plex server module
Added the plex server docker container as a module to the container modules.
1 parent 426b87f commit d9ea977

File tree

3 files changed

+86
-1
lines changed

3 files changed

+86
-1
lines changed

hosts/itxserver/configuration.nix

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ in
1717
# All custom modules
1818
../../modules/containers/stump.nix
1919
../../modules/containers/homeassistant.nix
20+
../../modules/containers/plex.nix
2021
# Any other modules
2122
inputs.sops-nix.nixosModules.sops
2223
];
@@ -71,8 +72,9 @@ in
7172
];
7273
firewall = {
7374
allowedTCPPorts = [
74-
8888
7575
8123
76+
8888
77+
32400
7678
];
7779
allowedUDPPorts = [ ];
7880
};

modules/containers/plex.nix

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Auto-generated using compose2nix v0.3.1. Edited.
2+
{
3+
pkgs,
4+
lib,
5+
config,
6+
...
7+
}@args:
8+
let
9+
inherit (args) inputs;
10+
in
11+
{
12+
imports = [ inputs.sops-nix.nixosModules.sops ];
13+
14+
# Secrets are managed via sops
15+
sops = {
16+
defaultSopsFile = ../../secrets/plex.env.enc;
17+
defaultSopsFormat = "dotenv";
18+
age.keyFile = "/home/lukas/.config/sops/age/keys.txt";
19+
secrets.plex-env = { };
20+
};
21+
22+
# Create persistent directory for postgres data
23+
systemd.tmpfiles.rules = [
24+
"d /srv/plex/config 0750 docker docker -"
25+
"d /srv/plex/transcode 0750 docker docker -"
26+
];
27+
28+
# Runtime
29+
virtualisation.docker = {
30+
enable = true;
31+
autoPrune.enable = true;
32+
};
33+
virtualisation.oci-containers.backend = "docker";
34+
35+
# Containers
36+
virtualisation.oci-containers.containers."plex-server" = {
37+
image = "plexinc/pms-docker";
38+
environment = {
39+
"PLEX_CLAIM" = "<claimToken>";
40+
"TZ" = "Europe/Berlin";
41+
};
42+
environmentFiles = [ config.sops.secrets.plex-env.path ];
43+
volumes = [
44+
"/data/movies:/data/movies:rw"
45+
"/data/music:/data/music:rw"
46+
"/srv/plex/config:/config:rw"
47+
"/srv/plex/transcode:/transcode:rw"
48+
];
49+
log-driver = "journald";
50+
extraOptions = [
51+
"--device=/dev/dri:/dev/dri:rwm"
52+
"--network=host"
53+
];
54+
};
55+
systemd.services."docker-plex-server" = {
56+
serviceConfig = {
57+
Restart = lib.mkOverride 90 "no";
58+
};
59+
partOf = [
60+
"docker-compose-plex-server-root.target"
61+
];
62+
wantedBy = [
63+
"docker-compose-plex-server-root.target"
64+
];
65+
};
66+
67+
# Root service
68+
# When started, this will automatically create all resources and start
69+
# the containers. When stopped, this will teardown all resources.
70+
systemd.targets."docker-compose-plex-server-root" = {
71+
unitConfig = {
72+
Description = "Root target generated by compose2nix.";
73+
};
74+
wantedBy = [ "multi-user.target" ];
75+
};
76+
}

secrets/plex.env.enc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
PLEX_CLAIM=ENC[AES256_GCM,data:S8tE/5MdiRQqNf+VJOFEv14F6590rtsTcQU=,iv:268aqyD5p76v7ozyN0sTGfqU/L2Hi8nt4i/s7tYQCqU=,tag:XmhMNhUIGaNngyUXoYkpEg==,type:str]
2+
sops_age__list_0__map_enc=-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBpMEduaUNyRml5VDFmTkpl\nOSt4U1Jqdkd3ZURhVlRIdlp4OUZlYjQ5Q2hBCkgvbFNPVjAzeXEvQWFiMksxYi9F\nbUZLMVN6UEF5Mlc1U1U0M2ZNZTRySkEKLS0tIHpRWS9LN214Y0dFVG5lZzdwTGNl\nektuV2FCVmNISU0vcVlHNG9ZSGNUMjgK6u+aR9XBhbNm/dKnjtfUx0Y1fvTMoTzA\nDomSeRsBWfMdi2ePbrwvThqmxmLxn90G+DUuoJhKzRPBCRH9U86U5A==\n-----END AGE ENCRYPTED FILE-----\n
3+
sops_age__list_0__map_recipient=age1njkfdv4ayqlqak76az6ezhse8hn3gmgt9ntur2edyz3watx2xdqq3jklqm
4+
sops_lastmodified=2025-06-26T13:51:36Z
5+
sops_mac=ENC[AES256_GCM,data:LN4JVvnDc0vVfGtdlMCsbjwKHhpIhdjg1ff8DWIqbrUBhFyQdaDBOSdE2dpa2EWGTt33OUMFDXlX0vxDoxtJWVfTb80tttMwiYQtFHhmYrtA8Cr3dnVdKvpxEg0dMS4csXL7QyVyW2RqKuoQRdHRY/BEQTcnYOCu9G1HdVn7tE0=,iv:blb7hxRfssqpwa2NuPRXx0jOMVw86Sf9ftbV8zafof8=,tag:TKZbY0qXlAYuu0RvaF5www==,type:str]
6+
sops_unencrypted_suffix=_unencrypted
7+
sops_version=3.10.2

0 commit comments

Comments
 (0)