diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9d369fd --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +hosts/nas/*.conf +hosts/nas/*.users \ No newline at end of file diff --git a/hosts/nas/configuration.nix b/hosts/nas/configuration.nix index 7744e50..028454e 100644 --- a/hosts/nas/configuration.nix +++ b/hosts/nas/configuration.nix @@ -8,7 +8,7 @@ let password = "$y$j9T$EkPXmsmIMFFZ.WRrBYCxS1$P0kwo6e4.WM5DsqUcEqWC3MrZp5KfCjxffraMFZWu06"; hostname = "jallen-nas"; - allowedPorts = [ 2342 61208 ]; + allowedPorts = [ 2342 3493 61208 ]; enableDisplayManager = false; in { imports = [ # Include the results of the hardware scan. @@ -72,58 +72,6 @@ in { }; }; - services.grafana = { - enable = true; - settings.server = { - http_port = 2342; - domain = hostname; - serve_from_sub_path = true; - http_addr = ""; - }; - dataDir = "/mnt/ssd/nix-app-data/grafana"; - }; - - services.prometheus = { - enable = true; - port = 9001; - exporters = { - node = { - enable = true; - enabledCollectors = [ "diskstats" "systemd" ]; - port = 9002; - }; - smartctl = { - enable = true; - group = "disk"; - devices = [ - "/dev/sda" - "/dev/sdb" - "/dev/sdc" - "/dev/sdd" - "/dev/sde" - "/dev/sdf" - "/dev/sdg" - "/dev/sdh" - "/dev/sdi" - "/dev/nvme0n1" - "/dev/nvme1n1" - ]; - }; - }; - - scrapeConfigs = [{ - job_name = hostname; - static_configs = [{ - targets = [ - "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" - "127.0.0.1:${ - toString config.services.prometheus.exporters.smartctl.port - }" - ]; - }]; - }]; - }; - share.hardware.nvidia = { enable = true; enableBeta = true; @@ -163,14 +111,14 @@ in { services = { # Enable the X11 windowing system. xserver = { - enable = true; + enable = enableDisplayManager; # Enable the Plasma 6 Desktop Environment. displayManager = { sddm.enable = enableDisplayManager; - defaultSession = "plasmawayland"; + #defaultSession = "plasma"; }; - desktopManager.plasma6.enable = true; + desktopManager.plasma5.enable = enableDisplayManager; }; # Set to enable Flatpak @@ -178,9 +126,9 @@ in { # Enable RDP xrdp = { - enable = true; + enable = enableDisplayManager; defaultWindowManager = "startplasma-x11"; - openFirewall = true; + openFirewall = enableDisplayManager; }; avahi = { @@ -208,6 +156,62 @@ in { ''; }; }; + + apcupsd = { + enable = true; + }; + + grafana = { + enable = true; + settings.server = { + http_port = 2342; + domain = hostname; + serve_from_sub_path = true; + http_addr = ""; + }; + dataDir = "/mnt/ssd/nix-app-data/grafana"; + }; + + prometheus = { + enable = true; + port = 9001; + exporters = { + node = { + enable = true; + enabledCollectors = [ "diskstats" "systemd" ]; + port = 9002; + }; + smartctl = { + enable = true; + group = "disk"; + devices = [ + "/dev/sda" + "/dev/sdb" + "/dev/sdc" + "/dev/sdd" + "/dev/sde" + "/dev/sdf" + "/dev/sdg" + "/dev/sdh" + "/dev/sdi" + "/dev/nvme0n1" + "/dev/nvme1n1" + ]; + }; + }; + + scrapeConfigs = [{ + job_name = hostname; + static_configs = [{ + targets = [ + "127.0.0.1:${toString config.services.prometheus.exporters.node.port}" + "127.0.0.1:${ + toString config.services.prometheus.exporters.smartctl.port + }" + ]; + }]; + }]; + }; }; systemd.services = { @@ -252,13 +256,16 @@ in { allowPing = true; extraCommands = "iptables -t raw -A OUTPUT -p udp -m udp --dport 137 -j CT --helper netbios-ns"; # TODO is this needed? - allowedTCPPorts = [ allowedPorts ]; - allowedUDPPorts = [ allowedPorts ]; + allowedTCPPorts = allowedPorts; + allowedUDPPorts = allowedPorts; }; }; # Configure environment environment = { + etc."nut/upsd.conf".source = ./upsd.conf; + etc."nut/upsd.users".source = ./upsd.users; + etc."nut/upsmon.conf".source = ./upsmon.conf; # List packages installed in system profile. To search, run: # $ nix search wget systemPackages = with pkgs; [ @@ -276,6 +283,7 @@ in { binutils gcc nodejs-18_x + nut ]; }; @@ -285,6 +293,16 @@ in { virt-manager.enable = true; nix-ld.enable = true; }; + + power.ups = { + enable = true; + mode = "netserver"; + ups."nasups" = { + driver = "usbhid-ups"; + port = "auto"; + description = "NAS UPS"; + }; + }; # Configure nixpkgs nixpkgs = { @@ -348,13 +366,22 @@ in { extraGroups = [ "jallen-nas" ]; # Enable ‘sudo’ for the user. hashedPassword = password; }; + + groups.nut.name = "nut"; + users.upsuser = { + group = "nut"; + isNormalUser = false; + isSystemUser = true; + createHome = true; + home = "/var/lib/nut"; + hashedPassword = password; + }; }; # Virtualisation virtualisation = { docker = { enable = true; - # enableNvidia = true; enableOnBoot = true; };