From a2ebeed8c68501a5a8fdd943591d51679d37695e Mon Sep 17 00:00:00 2001 From: th3r00t Date: Wed, 20 Aug 2025 10:08:10 -0400 Subject: [PATCH] Modularizing the setup --- configuration.nix | 184 +++-------------------------- flake.nix | 2 +- hardware-configuration.nix | 33 +++++- home-server.nix | 2 +- home-xps13.nix | 2 +- {includes => modules}/hyprland.nix | 0 modules/shares.nix | 141 ++++++++++++++++++++++ modules/sops.nix | 14 +++ {includes => modules}/waybar.nix | 0 9 files changed, 202 insertions(+), 176 deletions(-) rename {includes => modules}/hyprland.nix (100%) create mode 100644 modules/shares.nix create mode 100644 modules/sops.nix rename {includes => modules}/waybar.nix (100%) diff --git a/configuration.nix b/configuration.nix index f2c04ae..8956193 100644 --- a/configuration.nix +++ b/configuration.nix @@ -8,177 +8,26 @@ imports = [ # Include the results of the hardware scan. ./hardware-configuration.nix + ./modules/shares.nix + ./modules/sops.nix ]; nix.settings.experimental-features = [ "nix-command" "flakes" ]; # Bootloader. - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - boot.supportedFilesystems = [ "vfat" "ext4" "cifs" ]; - boot.kernelModules = [ "fuse" "coretemp" "cifs" ]; - sops.age.keyFile = "/var/lib/sops-nix/key.txt"; - systemd.tmpfiles.rules = [ - "d /mnt/books 0755 root root -" - "d /mnt/books_extra 0755 root root -" - "d /mnt/music 0755 root root -" - "d /mnt/music_ext 0755 root root -" - "d /mnt/games 0755 root root -" - "d /mnt/games_ext 0755 root root -" - "d /mnt/roms_ext 0755 root root -" - "d /mnt/podcasts 0755 root root -" - "d /mnt/audiobooks 0755 root root -" - ]; - - fileSystems."/mnt/books" = { - device = "//10.0.0.76/Books"; - fsType = "cifs"; - options = [ - "credentials=/run/secrets/smb" - "vers=3.0" - "uid=1000" "gid=1000" - "file_mode=0664" "dir_mode=0775" - "rw" "iocharset=utf8" "cache=strict" "mfsymlinks" - "_netdev" "nofail" - "x-systemd.automount" "noauto" - "x-systemd.idle-timeout=10min" + boot = { + kernelPackages = pkgs.linuxPackages_latest; + initrd.availableKernelModules = [ + "xhci_pci" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; - }; - fileSystems."/mnt/books_ext" = { - device = "//10.0.0.76/books_ext"; - fsType = "cifs"; - options = [ - "credentials=/run/secrets/smb" - "vers=3.0" - "uid=1000" "gid=1000" - "file_mode=0664" "dir_mode=0775" - "rw" "iocharset=utf8" "cache=strict" "mfsymlinks" - "_netdev" "nofail" - "x-systemd.automount" "noauto" - "x-systemd.idle-timeout=10min" - ]; - }; - fileSystems."/mnt/music" = { - device = "//10.0.0.76/music"; - fsType = "cifs"; - options = [ - "credentials=/run/secrets/smb" - "vers=3.0" - "uid=1000" "gid=1000" - "file_mode=0664" "dir_mode=0775" - "rw" "iocharset=utf8" "cache=strict" "mfsymlinks" - "_netdev" "nofail" - "x-systemd.automount" "noauto" - "x-systemd.idle-timeout=10min" - ]; - }; - fileSystems."/mnt/music_ext" = { - device = "//10.0.0.76/music_ext"; - fsType = "cifs"; - options = [ - "credentials=/run/secrets/smb" - "vers=3.0" - "uid=1000" "gid=1000" - "file_mode=0664" "dir_mode=0775" - "rw" "iocharset=utf8" "cache=strict" "mfsymlinks" - "_netdev" "nofail" - "x-systemd.automount" "noauto" - "x-systemd.idle-timeout=10min" - ]; - }; - fileSystems."/mnt/games" = { - device = "//10.0.0.76/games"; - fsType = "cifs"; - options = [ - "credentials=/run/secrets/smb" - "vers=3.0" - "uid=1000" "gid=1000" - "file_mode=0664" "dir_mode=0775" - "rw" "iocharset=utf8" "cache=strict" "mfsymlinks" - "_netdev" "nofail" - "x-systemd.automount" "noauto" - "x-systemd.idle-timeout=10min" - ]; - }; - fileSystems."/mnt/games_ext" = { - device = "//10.0.0.76/games_ext"; - fsType = "cifs"; - options = [ - "credentials=/run/secrets/smb" - "vers=3.0" - "uid=1000" "gid=1000" - "file_mode=0664" "dir_mode=0775" - "rw" "iocharset=utf8" "cache=strict" "mfsymlinks" - "_netdev" "nofail" - "x-systemd.automount" "noauto" - "x-systemd.idle-timeout=10min" - ]; - }; - fileSystems."/mnt/roms_ext" = { - device = "//10.0.0.76/roms_ext"; - fsType = "cifs"; - options = [ - "credentials=/run/secrets/smb" - "vers=3.0" - "uid=1000" "gid=1000" - "file_mode=0664" "dir_mode=0775" - "rw" "iocharset=utf8" "cache=strict" "mfsymlinks" - "_netdev" "nofail" - "x-systemd.automount" "noauto" - "x-systemd.idle-timeout=10min" - ]; - }; - fileSystems."/mnt/podcasts" = { - device = "//10.0.0.76/podcasts"; - fsType = "cifs"; - options = [ - "credentials=/run/secrets/smb" - "vers=3.0" - "uid=1000" "gid=1000" - "file_mode=0664" "dir_mode=0775" - "rw" "iocharset=utf8" "cache=strict" "mfsymlinks" - "_netdev" "nofail" - "x-systemd.automount" "noauto" - "x-systemd.idle-timeout=10min" - ]; - }; - fileSystems."/mnt/audiobooks" = { - device = "//10.0.0.76/audiobooks"; - fsType = "cifs"; - options = [ - "credentials=/run/secrets/smb" - "vers=3.0" - "uid=1000" "gid=1000" - "file_mode=0664" "dir_mode=0775" - "rw" "iocharset=utf8" "cache=strict" "mfsymlinks" - "_netdev" "nofail" - "x-systemd.automount" "noauto" - "x-systemd.idle-timeout=10min" - ]; - }; - sops.secrets.smb = { - sopsFile = ./secrets/smb.creds; - format = "binary"; - mode = "0400"; - owner = "root"; - group = "root"; - }; - networking.hostName = "xps13"; # Define your hostname. - # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - # networking.wireless.backend = "iwd"; - # networking.wireless.iwd.enable = true; - # networking.wireless.networks = { - # MyLocalTech = { - # pskRaw = "ac1030d721d26deb2c7db10073dfac73244e9621f4462e3e568017da03201e0e"; - # }; - # }; - # networking.networkmanager.enable = true; - networking.wireless = { - enable = true; - userControlled.enable = true; - networks = { - MyLocalTech = { - pskRaw = "ac1030d721d26deb2c7db10073dfac73244e9621f4462e3e568017da03201e0e"; - }; - }; + kernelModules = [ "fuse" "coretemp" "cifs" "kvm-intel" ]; + initrd.kernelModules = [ "ath10k_pci" ]; + loader.systemd-boot.enable = true; + loader.efi.canTouchEfiVariables = true; + supportedFilesystems = [ "vfat" "ext4" "cifs" ]; + extraModulePackages = [ ]; + extraModprobeConfig = '' + options ath10k_pcs irq_mode=1 + options ath10k_core rawmode=1 + ''; }; # Set your time zone. time.timeZone = "America/New_York"; @@ -284,7 +133,6 @@ vim curl age - sops ]; # Some programs need SUID wrappers, can be configured further or are diff --git a/flake.nix b/flake.nix index e17f3e5..d7753d9 100644 --- a/flake.nix +++ b/flake.nix @@ -54,7 +54,7 @@ } ]; }; - nixosConfigurations.xps13 = nixpkgs.lib.nixosSystem { + nixosConfigurations.server = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; specialArgs = { inherit overlays; }; modules = [ diff --git a/hardware-configuration.nix b/hardware-configuration.nix index 2692438..18ba544 100644 --- a/hardware-configuration.nix +++ b/hardware-configuration.nix @@ -8,11 +8,6 @@ [ (modulesPath + "/installer/scan/not-detected.nix") ]; - boot.initrd.availableKernelModules = [ "xhci_pci" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; - boot.initrd.kernelModules = [ ]; - boot.kernelPackages = pkgs.linuxPackages_latest; - boot.kernelModules = [ "kvm-intel" ]; - boot.extraModulePackages = [ ]; fileSystems."/" = { device = "/dev/disk/by-uuid/c888d639-8af5-44c9-8692-24756792a960"; @@ -63,6 +58,34 @@ libglvnd ]; }; + systemd.services.wifi-powersave-off = { + description = "Disable WiFi Power Save"; + wantedBy = [ "multi-user.target" ]; + requires = [ "network-online.target" ]; + after = [ "network-online.target" ]; + serviceConfig.Type = "oneshot"; + script = '' + IF=$(${pkgs.iw}/bin/iw dev | ${pkgs.gawk}/bin/awk "/Interface/ {print \$2; exit}") + if [ -n "$IF" ]; then + ${pkgs.iw}/bin/iw dev "$IF" set power_save off + fi + ''; + }; + networking.hostName = "xps13"; # Define your hostname. + # networking.networkmanager.enable = true; + networking.wireless = { + enable = true; + userControlled.enable = true; + networks = { + MyLocalTech = { + pskRaw = "ac1030d721d26deb2c7db10073dfac73244e9621f4462e3e568017da03201e0e"; + }; + }; + extraConfig = '' + country=US + pmf=1 + ''; + }; hardware.bluetooth = { enable = true; powerOnBoot = true; diff --git a/home-server.nix b/home-server.nix index 3df6389..8235ff0 100644 --- a/home-server.nix +++ b/home-server.nix @@ -41,7 +41,7 @@ * ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH8P/3yzsruekSaZ9b+yk429VTcfCtI1j8jnkNbPAgnr th3r00t@nixos ''; imports = [ - includes/hyprland.nix + modules/hyprland.nix ]; xdg.enable = true; programs.nix-index.enable = true; diff --git a/home-xps13.nix b/home-xps13.nix index 3df6389..8235ff0 100644 --- a/home-xps13.nix +++ b/home-xps13.nix @@ -41,7 +41,7 @@ * ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIH8P/3yzsruekSaZ9b+yk429VTcfCtI1j8jnkNbPAgnr th3r00t@nixos ''; imports = [ - includes/hyprland.nix + modules/hyprland.nix ]; xdg.enable = true; programs.nix-index.enable = true; diff --git a/includes/hyprland.nix b/modules/hyprland.nix similarity index 100% rename from includes/hyprland.nix rename to modules/hyprland.nix diff --git a/modules/shares.nix b/modules/shares.nix new file mode 100644 index 0000000..109eb8e --- /dev/null +++ b/modules/shares.nix @@ -0,0 +1,141 @@ +{ config, pkgs, ... }: +{ + systemd.tmpfiles.rules = [ + "d /mnt/books 0755 root root -" + "d /mnt/books_extra 0755 root root -" + "d /mnt/music 0755 root root -" + "d /mnt/music_ext 0755 root root -" + "d /mnt/games 0755 root root -" + "d /mnt/games_ext 0755 root root -" + "d /mnt/roms_ext 0755 root root -" + "d /mnt/podcasts 0755 root root -" + "d /mnt/audiobooks 0755 root root -" + ]; + + fileSystems."/mnt/books" = { + device = "//10.0.0.76/Books"; + fsType = "cifs"; + options = [ + "credentials=/run/secrets/smb" + "vers=3.0" + "uid=1000" "gid=1000" + "file_mode=0664" "dir_mode=0775" + "rw" "iocharset=utf8" "cache=strict" "mfsymlinks" + "_netdev" "nofail" + "x-systemd.automount" "noauto" + "x-systemd.idle-timeout=10min" + ]; + }; + fileSystems."/mnt/books_ext" = { + device = "//10.0.0.76/books_ext"; + fsType = "cifs"; + options = [ + "credentials=/run/secrets/smb" + "vers=3.0" + "uid=1000" "gid=1000" + "file_mode=0664" "dir_mode=0775" + "rw" "iocharset=utf8" "cache=strict" "mfsymlinks" + "_netdev" "nofail" + "x-systemd.automount" "noauto" + "x-systemd.idle-timeout=10min" + ]; + }; + fileSystems."/mnt/music" = { + device = "//10.0.0.76/music"; + fsType = "cifs"; + options = [ + "credentials=/run/secrets/smb" + "vers=3.0" + "uid=1000" "gid=1000" + "file_mode=0664" "dir_mode=0775" + "rw" "iocharset=utf8" "cache=strict" "mfsymlinks" + "_netdev" "nofail" + "x-systemd.automount" "noauto" + "x-systemd.idle-timeout=10min" + ]; + }; + fileSystems."/mnt/music_ext" = { + device = "//10.0.0.76/music_ext"; + fsType = "cifs"; + options = [ + "credentials=/run/secrets/smb" + "vers=3.0" + "uid=1000" "gid=1000" + "file_mode=0664" "dir_mode=0775" + "rw" "iocharset=utf8" "cache=strict" "mfsymlinks" + "_netdev" "nofail" + "x-systemd.automount" "noauto" + "x-systemd.idle-timeout=10min" + ]; + }; + fileSystems."/mnt/games" = { + device = "//10.0.0.76/games"; + fsType = "cifs"; + options = [ + "credentials=/run/secrets/smb" + "vers=3.0" + "uid=1000" "gid=1000" + "file_mode=0664" "dir_mode=0775" + "rw" "iocharset=utf8" "cache=strict" "mfsymlinks" + "_netdev" "nofail" + "x-systemd.automount" "noauto" + "x-systemd.idle-timeout=10min" + ]; + }; + fileSystems."/mnt/games_ext" = { + device = "//10.0.0.76/games_ext"; + fsType = "cifs"; + options = [ + "credentials=/run/secrets/smb" + "vers=3.0" + "uid=1000" "gid=1000" + "file_mode=0664" "dir_mode=0775" + "rw" "iocharset=utf8" "cache=strict" "mfsymlinks" + "_netdev" "nofail" + "x-systemd.automount" "noauto" + "x-systemd.idle-timeout=10min" + ]; + }; + fileSystems."/mnt/roms_ext" = { + device = "//10.0.0.76/roms_ext"; + fsType = "cifs"; + options = [ + "credentials=/run/secrets/smb" + "vers=3.0" + "uid=1000" "gid=1000" + "file_mode=0664" "dir_mode=0775" + "rw" "iocharset=utf8" "cache=strict" "mfsymlinks" + "_netdev" "nofail" + "x-systemd.automount" "noauto" + "x-systemd.idle-timeout=10min" + ]; + }; + fileSystems."/mnt/podcasts" = { + device = "//10.0.0.76/podcasts"; + fsType = "cifs"; + options = [ + "credentials=/run/secrets/smb" + "vers=3.0" + "uid=1000" "gid=1000" + "file_mode=0664" "dir_mode=0775" + "rw" "iocharset=utf8" "cache=strict" "mfsymlinks" + "_netdev" "nofail" + "x-systemd.automount" "noauto" + "x-systemd.idle-timeout=10min" + ]; + }; + fileSystems."/mnt/audiobooks" = { + device = "//10.0.0.76/audiobooks"; + fsType = "cifs"; + options = [ + "credentials=/run/secrets/smb" + "vers=3.0" + "uid=1000" "gid=1000" + "file_mode=0664" "dir_mode=0775" + "rw" "iocharset=utf8" "cache=strict" "mfsymlinks" + "_netdev" "nofail" + "x-systemd.automount" "noauto" + "x-systemd.idle-timeout=10min" + ]; + }; +} diff --git a/modules/sops.nix b/modules/sops.nix new file mode 100644 index 0000000..25bee9b --- /dev/null +++ b/modules/sops.nix @@ -0,0 +1,14 @@ +{ config, pkgs, ... }: +{ + environment.systemPackages = with pkgs; [ + sops + ]; + sops.age.keyFile = "/var/lib/sops-nix/key.txt"; + sops.secrets.smb = { + sopsFile = ./secrets/smb.creds; + format = "binary"; + mode = "0400"; + owner = "root"; + group = "root"; + }; +} diff --git a/includes/waybar.nix b/modules/waybar.nix similarity index 100% rename from includes/waybar.nix rename to modules/waybar.nix