From 078dcdc2a766d10c00e60a2ef665dda1a6a3c33c Mon Sep 17 00:00:00 2001 From: Nathan McCarty Date: Fri, 13 May 2022 22:11:39 -0400 Subject: [PATCH] Port perception over to nix --- flake.nix | 22 +++++++++- hardware/perception.nix | 63 +++++++++++++++++++++++++++++ machines/perception.nix | 53 ++++++++++++++++++++++++ system-specific/perception/plex.nix | 31 ++++++++++++++ 4 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 hardware/perception.nix create mode 100644 machines/perception.nix create mode 100644 system-specific/perception/plex.nix diff --git a/flake.nix b/flake.nix index 36296f7..26e18f1 100644 --- a/flake.nix +++ b/flake.nix @@ -146,11 +146,31 @@ ./applications/devel-rust.nix ./modules/docker.nix ./system-specific/oracles/matrix.nix - # ./system-specific/oracles/gitlab-runner.nix + # ./system-specific/oracles/gitlab-runner.nix ./system-specific/oracles/gitea.nix ] ++ serverModules; }; + perception = nixpkgs.lib.nixosSystem { + system = "x86_64-linux"; + specialArgs = { + unstable = import nixpkgs-unstable { + config = { allowUnfree = true; }; + overlays = [ ]; + system = "x86_64-linux"; + }; + fenix = fenix.packages.x86_64-linux; + }; + modules = [ + ./hardware/perception.nix + ./machines/perception.nix + ./home-linux.nix + ./applications/devel-rust.nix + ./modules/docker.nix + ./system-specific/perception/plex.nix + ] ++ serverModules; + }; + x86vm = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = { diff --git a/hardware/perception.nix b/hardware/perception.nix new file mode 100644 index 0000000..668d1da --- /dev/null +++ b/hardware/perception.nix @@ -0,0 +1,63 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ + (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "xhci_pci" "ehci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-intel" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { + device = "/dev/disk/by-uuid/49959c20-a0d0-4b9b-b5bc-f7601640d252"; + fsType = "btrfs"; + options = [ "subvol=root" ]; + }; + + fileSystems."/boot" = + { + device = "/dev/disk/by-uuid/68FE-F04C"; + fsType = "vfat"; + }; + + fileSystems."/nix" = + { + device = "/dev/disk/by-uuid/49959c20-a0d0-4b9b-b5bc-f7601640d252"; + fsType = "btrfs"; + options = [ "subvol=nix" ]; + }; + + fileSystems."/var" = + { + device = "/dev/disk/by-uuid/49959c20-a0d0-4b9b-b5bc-f7601640d252"; + fsType = "btrfs"; + options = [ "subvol=var" ]; + }; + + fileSystems."/home" = + { + device = "/dev/disk/by-uuid/49959c20-a0d0-4b9b-b5bc-f7601640d252"; + fsType = "btrfs"; + options = [ "subvol=home" ]; + }; + + fileSystems."/etc" = + { + device = "/dev/disk/by-uuid/49959c20-a0d0-4b9b-b5bc-f7601640d252"; + fsType = "btrfs"; + options = [ "subvol=etc" ]; + }; + + swapDevices = + [{ device = "/dev/disk/by-uuid/522c68bd-b23b-487d-80e3-fc41e2be130f"; }]; + + # high-resolution display + hardware.video.hidpi.enable = lib.mkDefault true; +} diff --git a/machines/perception.nix b/machines/perception.nix new file mode 100644 index 0000000..9f4b22a --- /dev/null +++ b/machines/perception.nix @@ -0,0 +1,53 @@ +{ config, lib, pkgs, ... }: + +{ + networking = { + hostName = "perception"; + domain = "mccarty.io"; + useDHCP = false; + interfaces.eno1 = { + useDHCP = false; + ipv4.addresses = [ + { + address = "10.0.0.11"; + prefixLength = 21; + } + ]; + }; + defaultGateway = "10.0.4.1"; + nameservers = [ "10.0.0.10" ]; + }; + + # Use the systemd-boot EFI boot loader. + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # Trust ZT interface + networking.firewall.trustedInterfaces = [ "zt5u4uutwm" ]; + + # add plex nfs mount + fileSystems."/var/plex" = { + device = "10.0.0.139:/mnt/tank/root/data/plex"; + fsType = "nfs"; + }; + fileSystems."/var/scratch" = { + device = "10.0.0.139:/mnt/tank/root/scratch"; + fsType = "nfs"; + }; + + # Enable sabnzbd + services.sabnzbd = { + enable = true; + }; + # Enable sonarr + services.sonarr = { + enable = true; + }; + + # Open firewall ports + networking.firewall = { + enable = false; + allowedTCPPorts = [ 8080 8989 9383 ]; + allowedUDPPorts = [ 8080 8989 9383 ]; + }; +} diff --git a/system-specific/perception/plex.nix b/system-specific/perception/plex.nix new file mode 100644 index 0000000..481a3dc --- /dev/null +++ b/system-specific/perception/plex.nix @@ -0,0 +1,31 @@ +{ config, pkgs, ... }: +{ + services.plex = + let + myPlexRaw = pkgs.plexRaw.overrideAttrs (x: + let + # see https://www.plex.tv/media-server-downloads/ for 64bit rpm + version = "1.26.1.5798-99a4a6ac9"; + hash = "sha256-Chu4IULIvkmfMEV0LSg50i6usZJZI3UWOgCHQakbhaY="; + in + { + name = "plex-${version}"; + src = pkgs.fetchurl { + url = "https://downloads.plex.tv/plex-media-server-new/${version}/debian/plexmediaserver_${version}_amd64.deb"; + inherit hash; + }; + } + ); + myPlex = pkgs.plex.override (x: { plexRaw = myPlexRaw; }); + in + { + enable = true; + openFirewall = true; + dataDir = "/var/lib/plex"; + user = "nathan"; + group = "users"; + package = myPlex; + }; + + services.tautulli.enable = true; +}