Skip to content

Commit

Permalink
feat(nix): add basic jellyfin
Browse files Browse the repository at this point in the history
  • Loading branch information
sbulav committed Nov 22, 2024
1 parent d08927c commit c927e04
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 20 deletions.
1 change: 1 addition & 0 deletions nix/modules/darwin/system/security/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ in {
${pkgs.coreutils}/bin/env nix-env -p /nix/var/nix/profiles/system --set /nix/store/*, \
${pkgs.coreutils}/bin/env /nix/store/*/activate, \
/etc/profiles/per-user/${config.${namespace}.user.name}/bin/openconnect, \
/sbin/route, \
/usr/bin/dscacheutil, \
/usr/bin/killall, \
/usr/bin/pkill, \
Expand Down
9 changes: 8 additions & 1 deletion nix/modules/home/security/openconnect/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@
with lib;
with lib.custom; let
cfg = config.${namespace}.security.openconnect;
route_delete_command =
if pkgs.stdenv.isLinux
then "sudo route del -net 192.168.0.0/16"
else if pkgs.stdenv.isDarwin
then "sudo route delete -net 192.168.0.0/16"
else "";

vpnScript = pkgs.writeScriptBin "myvpn" ''
#! ${pkgs.bash}/bin/sh
Expand Down Expand Up @@ -57,7 +64,7 @@ with lib.custom; let
echo "VPN is up and running!"
echo "******************************************************"
echo "Removing LAN routes to VPN"
sudo route del -net 192.168.0.0/16
${route_delete_command}
fi
;;
down)
Expand Down
39 changes: 20 additions & 19 deletions nix/modules/nixos/containers/jellyfin/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ in {
host = "${cfg.host}";
url = "http://${cfg.localAddress}:8096";
route_enabled = cfg.enable;
middleware = "secure-headers";
})
(import ../shared/shared-adguard-dns-rewrite.nix
{
Expand Down Expand Up @@ -58,29 +59,29 @@ in {
"hostPath" = "${cfg.dataPath}/log/";
isReadOnly = false;
};
};

config = {...}: {
systemd.tmpfiles.rules = [
"d /var/lib/jellyfin 700 jellyfin jellyfin -"
];
services.jellyfin = {
enable = true;
};
config = {...}: {
systemd.tmpfiles.rules = [
"d /var/lib/jellyfin 700 jellyfin jellyfin -"
];
services.jellyfin = {
enable = true;
};

networking = {
firewall = {
enable = true;
# https://jellyfin.org/docs/general/networking/index.html#port-bindings
allowedTCPPorts = [8096 8920];
allowedUDPPorts = [1900 7359];
};
# Use systemd-resolved inside the container
# Workaround for bug https://github.com/NixOS/nixpkgs/issues/162686
useHostResolvConf = lib.mkForce false;
networking = {
firewall = {
enable = false;
# https://jellyfin.org/docs/general/networking/index.html#port-bindings
allowedTCPPorts = [8096 8920];
allowedUDPPorts = [1900 7359];
};
services.resolved.enable = true;
system.stateVersion = "24.11";
# 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 = "24.11";
};
};
};
Expand Down

0 comments on commit c927e04

Please sign in to comment.