From 07bbb996e5850226f0f38138f8fe615c5162f655 Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Sun, 18 Jun 2023 15:51:52 -0400 Subject: [PATCH] nix: Continue modularization of system modules --- modules/boot.nix | 14 ++++++ modules/default.nix | 6 +++ modules/gamemode.nix | 18 ++++++++ modules/home-manager.nix | 17 +++++++ modules/networking.nix | 28 ++++++++++++ modules/nix.nix | 15 +++++++ modules/vmware.nix | 10 +++++ src/main.nix | 97 ---------------------------------------- 8 files changed, 108 insertions(+), 97 deletions(-) create mode 100644 modules/boot.nix create mode 100644 modules/gamemode.nix create mode 100644 modules/home-manager.nix create mode 100644 modules/networking.nix create mode 100644 modules/nix.nix create mode 100644 modules/vmware.nix diff --git a/modules/boot.nix b/modules/boot.nix new file mode 100644 index 0000000..65c0e1d --- /dev/null +++ b/modules/boot.nix @@ -0,0 +1,14 @@ +{ + boot.loader = { + systemd-boot = { + enable = true; + editor = false; + configurationLimit = 10; + }; + + timeout = 0; + efi.canTouchEfiVariables = true; + }; + + boot.tmp.useTmpfs = true; +} diff --git a/modules/default.nix b/modules/default.nix index 56497d5..059da43 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -1,10 +1,15 @@ { imports = [ + ./boot.nix ./dual-function-keys.nix ./fish.nix ./fonts.nix + ./gamemode.nix ./greetd.nix + ./home-manager.nix ./hyprland.nix + ./networking.nix + ./nix.nix ./piper.nix ./pipewire.nix ./starship.nix @@ -12,5 +17,6 @@ ./thunar.nix ./user.nix ./virtualization.nix + ./vmware.nix ]; } diff --git a/modules/gamemode.nix b/modules/gamemode.nix new file mode 100644 index 0000000..2397f5e --- /dev/null +++ b/modules/gamemode.nix @@ -0,0 +1,18 @@ +{ pkgs, ... }: + +{ + programs.gamemode = { + enable = true; + settings = { + general = { + renice = 10; + igpu_power_threshold = -1; + }; + + custom = { + start = "${pkgs.libnotify}/bin/notify-send 'Note' 'gamemode started from host.'"; + end = "${pkgs.libnotify}/bin/notify-send 'Note' 'gamemode ended from host."; + }; + }; + }; +} diff --git a/modules/home-manager.nix b/modules/home-manager.nix new file mode 100644 index 0000000..e6084bf --- /dev/null +++ b/modules/home-manager.nix @@ -0,0 +1,17 @@ +let VARIABLES = import ../src/variables.nix; in { + home-manager = { + useGlobalPkgs = true; + useUserPackages = true; + + sharedModules = [{ + home.stateVersion = VARIABLES.stateVersion; + }]; + + users = { + user = { + home.username = VARIABLES.username; + home.homeDirectory = "/home/${VARIABLES.username}"; + }; + }; + }; +} diff --git a/modules/networking.nix b/modules/networking.nix new file mode 100644 index 0000000..017c033 --- /dev/null +++ b/modules/networking.nix @@ -0,0 +1,28 @@ +let VARIABLES = import ../src/variables.nix; in { + networking = { + hostName = VARIABLES.hostname; + + networkmanager = { + enable = true; + wifi.macAddress = "random"; + ethernet.macAddress = "random"; + + unmanaged = [ "interface-name:ve-*" ]; + }; + + useHostResolvConf = true; + + nat = { + enable = true; + internalInterfaces = [ "ve-+" ]; + externalInterface = "wg-mullvad"; + + forwardPorts = [ + { + destination = "192.168.100.11:80"; + sourcePort = 11918; + } + ]; + }; + }; +} diff --git a/modules/nix.nix b/modules/nix.nix new file mode 100644 index 0000000..fe60e25 --- /dev/null +++ b/modules/nix.nix @@ -0,0 +1,15 @@ +{ pkgs, ... }: + +{ + nix = { + package = pkgs.nixFlakes; + + settings = { + experimental-features = [ "nix-command" "flakes" "repl-flake" ]; + auto-optimise-store = true; + + substituters = ["https://nix-gaming.cachix.org"]; + trusted-public-keys = ["nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4="]; + }; + }; +} diff --git a/modules/vmware.nix b/modules/vmware.nix new file mode 100644 index 0000000..6647d2e --- /dev/null +++ b/modules/vmware.nix @@ -0,0 +1,10 @@ +{ + virtualisation.vmware.host = { + enable = true; + extraConfig = /* config */ '' + # Enable 3D acceleration on the host + mks.gl.allowUnsupportedDrivers = "TRUE" + mks.vk.allowUnsupportedDevices = "TRUE" + ''; + }; +} diff --git a/src/main.nix b/src/main.nix index 15f3614..905af26 100644 --- a/src/main.nix +++ b/src/main.nix @@ -26,49 +26,11 @@ let VARIABLES = import ./variables.nix; in { i18n.defaultLocale = VARIABLES.defaultLocale; i18n.supportedLocales = VARIABLES.supportedLocales; - # nix - nix.package = pkgs.nixFlakes; - nix.settings.experimental-features = [ "nix-command" "flakes" "repl-flake" ]; - nix.settings.auto-optimise-store = true; - - nix.settings = { - substituters = ["https://nix-gaming.cachix.org"]; - trusted-public-keys = ["nix-gaming.cachix.org-1:nbjlureqMbRAxR1gJ/f3hxemL9svXaZF/Ees8vCUUs4="]; - }; - hardware.opengl.driSupport32Bit = true; - boot.loader = { - systemd-boot = { - enable = true; - editor = false; - configurationLimit = 10; - }; - - timeout = 0; - efi.canTouchEfiVariables = true; - }; - - boot.tmp.useTmpfs = true; - programs.neovim.enable = true; programs.npm.enable = true; - programs.gamemode = { - enable = true; - settings = { - general = { - renice = 10; - igpu_power_threshold = -1; - }; - - custom = { - start = "${pkgs.libnotify}/bin/notify-send 'Note' 'gamemode started from host.'"; - end = "${pkgs.libnotify}/bin/notify-send 'Note' 'gamemode ended from host."; - }; - }; - }; - environment.systemPackages = with pkgs; [ hypr-contrib.packages."${VARIABLES.system}".grimblast nix-gaming.packages."${VARIABLES.system}".osu-stable @@ -177,18 +139,6 @@ let VARIABLES = import ./variables.nix; in { environment.defaultPackages = [ ]; system.stateVersion = VARIABLES.stateVersion; - # home-manager - home-manager = { - useGlobalPkgs = true; - useUserPackages = true; - - sharedModules = [ - { - home.stateVersion = VARIABLES.stateVersion; - } - ]; - }; - systemd.extraConfig = "DefaultTimeoutStopSec=10s"; # Prevent hanging on shutdown services.logind.lidSwitch = "ignore"; # Don't suspend on lid close @@ -197,28 +147,6 @@ let VARIABLES = import ./variables.nix; in { time.timeZone = "${VARIABLES.timezone}"; # Timezone - # user - - home-manager.users.user = { - home.username = VARIABLES.username; - home.homeDirectory = "/home/${VARIABLES.username}"; - }; - - # networking - networking = { - hostName = VARIABLES.hostname; - - networkmanager = { - enable = true; - wifi.macAddress = "random"; - ethernet.macAddress = "random"; - - unmanaged = [ "interface-name:ve-*" ]; - }; - - useHostResolvConf = true; - }; - services.resolved.llmnr = "false"; systemd.services.NetworkManager-wait-online.enable = false; @@ -231,30 +159,5 @@ let VARIABLES = import ./variables.nix; in { networking.firewall.allowedTCPPorts = [ 11918 ]; - networking = { - nat = { - enable = true; - internalInterfaces = [ "ve-+" ]; - externalInterface = "wg-mullvad"; - - forwardPorts = [ - { - destination = "192.168.100.11:80"; - sourcePort = 11918; - } - ]; - }; - }; - - virtualisation.vmware.host = { - enable = true; - extraConfig = /* config */ '' - # Enable 3D acceleration on the host - mks.gl.allowUnsupportedDrivers = "TRUE" - mks.vk.allowUnsupportedDevices = "TRUE" - ''; - }; - - zramSwap.enable = true; # Swap }