Media-Box-NixOS-config/configuration.nix

206 lines
5.6 KiB
Nix
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Edit this configuration file to define what should be installed on your system. Help is
# available in the configuration.nix(5) man page and in the NixOS manual (accessible by running
# nixos-help).
{ config, pkgs, ... }:
{
imports =
[ # Include the results of the hardware scan.
./hardware-configuration.nix
];
## This mounts the ZFS pool
boot.supportedFilesystems = [ "zfs" ];
boot.zfs.forceImportRoot = false;
networking.hostId = "1f72512b"; # head -c4 /dev/urandom | od -A none -t x4
##
## uncomment after formating disks
##
#fileSystems."/mnt/media" = {
# device = "media-pool";
# fsType = "zfs";
#};
#
## ZFS snapshots
#services.sanoid = {
# enable = true;
# templates.backup = {
# hourly = 36;
# daily = 30;
# monthly = 3;
# autoprune = true;
# autosnap = true;
# };
#
# datasets."media-pool" = {
# useTemplate = [ "backup" ];
# };
#};
#
#services.zfs.autoScrub = {
# enable = true;
# interval = "*-*-1,15 02:30";
#};
# Bootloader.
boot.loader.systemd-boot.enable = true;
boot.loader.efi.canTouchEfiVariables = true;
# makemkv fix
boot.initrd.kernelModules = [ "sg" ];
networking.hostName = "media-server"; # Define your hostname.
# Enable networking
networking.networkmanager.enable = true;
# Set your time zone.
time.timeZone = "America/New_York";
# Select internationalisation properties.
i18n.defaultLocale = "en_US.UTF-8";
i18n.extraLocaleSettings = {
LC_ADDRESS = "en_US.UTF-8";
LC_IDENTIFICATION = "en_US.UTF-8";
LC_MEASUREMENT = "en_US.UTF-8";
LC_MONETARY = "en_US.UTF-8";
LC_NAME = "en_US.UTF-8";
LC_NUMERIC = "en_US.UTF-8";
LC_PAPER = "en_US.UTF-8";
LC_TELEPHONE = "en_US.UTF-8";
LC_TIME = "en_US.UTF-8";
};
# Configure keymap in X11
services.xserver.xkb = {
layout = "us";
};
# Define a user account. Don't forget to set a password with passwd.
programs.fish.enable = true;
users.users.arm = {
isNormalUser = true;
shell = pkgs.fish;
initialPassword = "changeme";
extraGroups = [ "wheel" "networkmanager" "audio" "video" "cdrom" "input" "docker" "render"];
};
# define Swap file
zramSwap.enable = true;
zramSwap.memoryPercent = 50;
# define jellyfin
services.jellyfin = {
enable = true;
};
# 1. enable vaapi on OS-level
nixpkgs.config.packageOverrides = pkgs: {
vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; };
};
hardware.graphics = {
enable = true;
extraPackages = with pkgs; [
intel-media-driver
intel-vaapi-driver # previously vaapiIntel
vaapiVdpau
libvdpau-va-gl
intel-compute-runtime # OpenCL filter support (hardware tonemapping and subtitle burn-in)
vpl-gpu-rt # QSV on 11th gen or newer
intel-media-sdk # QSV up to 11th gen
];
};
# define docker containers
virtualisation.docker.enable = true;
virtualisation.oci-containers.backend = "docker";
virtualisation.oci-containers.containers = {
# define Channels DVR for Live TV
dvr = {
ports = ["8089:8089"];
autoStart = true;
extraOptions = ["--device=/dev/dri:/dev/dri"];
volumes = [
"/mnt/media/dvr-data:/channels-dvr"
"/mnt/media/dvr:/shares/DVR"
];
image = "fancybits/channels-dvr:tve";
};
# define Automatic Ripping Machine for importing TV shows, Movies, Music, and Data CDs and DVDs
arm = {
ports = ["8080:8080"];
autoStart = true;
volumes = [
"/mnt/media/arm:/home/arm"
"/mnt/media/arm/Music:/home/arm/Music"
"/mnt/media/arm/logs:/home/arm/logs"
"/mnt/media/arm/media:/home/arm/media"
"/mnt/media/arm/config:/etc/arm/config"
];
extraOptions = ["--device=/dev/sr0:/dev/sr0" "--privileged"];
environment = {
ARM_UID = "1000";
ARM_GID = "100";
};
image = "automaticrippingmachine/automatic-ripping-machine:latest";
};
# define youtube downloader for jellyfin
pinchflat = {
ports = ["8945:8945"];
autoStart = true;
volumes = [
"/mnt/media/yt-config:/config"
"/mnt/media/yt-downloads:/downloads"
];
image = "ghcr.io/kieraneglin/pinchflat:latest";
};
};
# Allow unfree packages
nixpkgs.config.allowUnfree = true;
nix.settings.experimental-features = [ "nix-command" "flakes" ];
# adding packaegs
environment.systemPackages = [
pkgs.jellyfin
pkgs.jellyfin-web
pkgs.jellyfin-ffmpeg
# cli tools
pkgs.btop
pkgs.git
(import ./format-zfs-pool.nix { inherit pkgs; })
];
# Some programs need SUID wrappers, can be configured further or are
# started in user sessions.
# programs.mtr.enable = true;
# programs.gnupg.agent = {
# enable = true;
# enableSSHSupport = true;
# };
# Enable the OpenSSH daemon.
services.openssh.enable = true;
# Open ports in the firewall.
networking.firewall.allowedTCPPorts = [
8080
8089
8096
22
];
# networking.firewall.allowedUDPPorts = [ ... ];
# Or disable the firewall altogether.
networking.firewall.enable = true;
# This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions
# on your system were taken. Its perfectly fine and recommended to leave
# this value at the release version of the first install of this system.
# Before changing this value read the documentation for this option
# (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
system.stateVersion = "24.11"; # Did you read the comment?
}