Advertisement
Guest User

Jellyfin-container.nix

a guest
Apr 4th, 2025
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. { config, lib, pkgs, ... }: {
  2.  
  3. containers.mediaplayers = {
  4. ephemeral = true;
  5. autoStart = true;
  6. bindMounts = {
  7. "/mnt/data/media" = {
  8. hostPath = "/mnt/data/media";
  9. isReadOnly = false;
  10. };
  11. "/dev/dri" = {
  12. hostPath = "/dev/dri";
  13. isReadOnly = false;
  14. };
  15. "/dev/nvidia0" = {
  16. hostPath = "/dev/nvidia0";
  17. isReadOnly = false;
  18. };
  19. "/dev/nvidiactl" = {
  20. hostPath = "/dev/nvidiactl";
  21. isReadOnly = false;
  22. };
  23. "/dev/nvidia-modeset" = {
  24. hostPath = "/dev/nvidia-modeset";
  25. isReadOnly = false;
  26. };
  27. "/dev/nvidia-uvm" = {
  28. hostPath = "/dev/nvidia-uvm";
  29. isReadOnly = false;
  30. };
  31. "/dev/nvidia-uvm-tools" = {
  32. hostPath = "/dev/nvidia-uvm-tools";
  33. isReadOnly = false;
  34. };
  35. "/dev/nvidia-caps/nvidia-cap1" = {
  36. hostPath = "/dev/nvidia-caps/nvidia-cap1";
  37. isReadOnly = false;
  38. };
  39. "/dev/nvidia-caps/nvidia-cap2" = {
  40. hostPath = "/dev/nvidia-caps/nvidia-cap2";
  41. isReadOnly = false;
  42. };
  43. "/run/opengl-driver" = {
  44. hostPath = "/run/opengl-driver";
  45. isReadOnly = false;
  46. };
  47. };
  48.  
  49. extraFlags = [
  50. "--system-call-filter=@resources"
  51. "--system-call-filter=@system-service"
  52. "--capability=CAP_SYS_ADMIN"
  53. "--bind-ro=/sys/bus/pci/devices"
  54. ];
  55. privateNetwork = true;
  56. hostAddress = "192.168.100.2";
  57. localAddress = "192.168.100.33";
  58.  
  59. config = { config, pkgs, ... }: {
  60. nixpkgs.config.allowUnfree = true;
  61. networking.firewall.enable = false;
  62.  
  63. environment.systemPackages = with pkgs; [ audiobookshelf jellyfin ];
  64.  
  65. hardware.graphics = { enable = true; };
  66. services.xserver.videoDrivers = [ "nvidia" ];
  67.  
  68. hardware.nvidia = {
  69. modesetting.enable = true;
  70. powerManagement.enable = false;
  71. powerManagement.finegrained = false;
  72. open = false;
  73. package = config.boot.kernelPackages.nvidiaPackages.stable;
  74. };
  75.  
  76. hardware.opengl = {
  77. enable = true;
  78. extraPackages = with pkgs; [ cudaPackages.cudatoolkit ];
  79. };
  80.  
  81. users.users.**** = {
  82. isNormalUser = true;
  83. description = "****";
  84. uid = 1000;
  85. extraGroups = [ "networkmanager" "wheel" "video" "render" ];
  86. };
  87. # jellyfin
  88. # services.jellyfin = {
  89. # enable = true;
  90. # user = "methots";
  91. # group = "users";
  92. # dataDir = "/mnt/data/media/.config/jellyfin/data";
  93. # configDir = "/mnt/data/media/.config/jellyfin";
  94. # cacheDir = "/mnt/data/media/.config/jellyfin/cache";
  95. # };
  96.  
  97. systemd.services.jellyfin = {
  98. description = "Jellyfin Media Server";
  99. after = [ "network-online.target" ];
  100. wants = [ "network-online.target" ];
  101. wantedBy = [ "multi-user.target" ];
  102.  
  103. serviceConfig = {
  104. Type = "simple";
  105. User = "*****";
  106. Group = "users";
  107. UMask = "0077";
  108. WorkingDirectory = /mnt/data/media/.config/jellyfin/data;
  109. ExecStart =
  110. "${pkgs.jellyfin}/bin/jellyfin --datadir /mnt/data/media/.config/jellyfin/data --configdir /mnt/data/media/.config/jellyfin --cachedir /mnt/data/media/.config/jellyfin/cache --logdir /mnt/data/media/.config/jellyfin";
  111. Restart = "on-failure";
  112. TimeoutSec = 15;
  113. SuccessExitStatus = [ "0" "143" ];
  114.  
  115. Environment =
  116. [ "NVIDIA_VISIBLE_DEVICES=all" "NVIDIA_DRIVER_CAPABILITIES=all" ];
  117.  
  118. };
  119. };
  120. system.stateVersion = "24.11";
  121. };
  122.  
  123. };
  124.  
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement