From 0e47cae3954f6fb491225d8bb4fa5b05da335e80 Mon Sep 17 00:00:00 2001 From: Atridad Lahiji Date: Thu, 29 May 2025 23:48:27 -0600 Subject: [PATCH] Config overhaul --- README.md | 3 + configuration.nix | 167 +++++------------------------------------ modules/aliases.nix | 29 +++++++ modules/audio.nix | 19 +++++ modules/boot.nix | 10 +++ modules/desktop.nix | 22 ++++++ modules/hardware.nix | 21 ++++++ modules/locale.nix | 9 +++ modules/networking.nix | 20 +++++ modules/packages.nix | 32 ++++++++ modules/programs.nix | 11 +++ modules/services.nix | 14 ++++ modules/users.nix | 13 ++++ 13 files changed, 220 insertions(+), 150 deletions(-) create mode 100644 README.md create mode 100644 modules/aliases.nix create mode 100644 modules/audio.nix create mode 100644 modules/boot.nix create mode 100644 modules/desktop.nix create mode 100644 modules/hardware.nix create mode 100644 modules/locale.nix create mode 100644 modules/networking.nix create mode 100644 modules/packages.nix create mode 100644 modules/programs.nix create mode 100644 modules/services.nix create mode 100644 modules/users.nix diff --git a/README.md b/README.md new file mode 100644 index 0000000..a278a13 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# My NixOS Config + +Use `nix:help` to list all commands diff --git a/configuration.nix b/configuration.nix index 3b174f8..db42a5e 100644 --- a/configuration.nix +++ b/configuration.nix @@ -1,162 +1,29 @@ -# 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 - ]; - - # Bootloader. - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; - - # Use latest kernel. - boot.kernelPackages = pkgs.linuxPackages_latest; - - networking.hostName = "lavitz"; # Define your hostname. - # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - - # Configure network proxy if necessary - # networking.proxy.default = "http://user:password@proxy:port/"; - # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; - - # Enable networking - networking.networkmanager.enable = true; - - # Set your time zone. - time.timeZone = "America/Edmonton"; - - # Select internationalisation properties. - i18n.defaultLocale = "en_CA.UTF-8"; - - # Enable the X11 windowing system. - services.xserver.enable = true; - - # Enable the GNOME Desktop Environment. - services.xserver.displayManager.gdm.enable = true; - services.xserver.desktopManager.gnome.enable = true; - - # Configure keymap in X11 - services.xserver.xkb = { - layout = "us"; - variant = ""; - }; - - # Enable CUPS to print documents. - services.printing.enable = true; - - # Enable sound with pipewire. - services.pulseaudio.enable = false; - security.rtkit.enable = true; - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - # If you want to use JACK applications, uncomment this - #jack.enable = true; - - # use the example session manager (no others are packaged yet so this is enabled by default, - # no need to redefine it in your config for now) - #media-session.enable = true; - }; - - # Enable touchpad support (enabled default in most desktopManager). - # services.xserver.libinput.enable = true; - - # Define a user account. Don't forget to set a password with ‘passwd’. - users.users.atridad = { - isNormalUser = true; - description = "Atridad"; - extraGroups = [ "networkmanager" "wheel" ]; - packages = with pkgs; [ - # thunderbird - ]; - }; - - # Allow unfree packages - nixpkgs.config.allowUnfree = true; - - environment.shellAliases = { - rebuild = "sudo nixos-rebuild switch"; - confedit = "sudo nano ~/Developer/nix/configuration.nix"; - confcpy="sudo rm -rf /etc/nixos/configuration.nix && sudo cp ~/Developer/nix/configuration.nix /etc/nixos/configuration.nix && cd ~/Developer/nix && git add -A && git commit -m \"$(date -u +%s)\" && git push"; - }; - - # Sleep - systemd.sleep.extraConfig = '' - AllowSuspend=no - AllowHibernation=no - AllowHybridSleep=no - AllowSuspendThenHibernate=no - ''; - - # Packages: - environment.systemPackages = with pkgs; [ - pkgs.vivaldi - pkgs.zed-editor - pkgs.discord - pkgs.bitwarden-desktop - pkgs.signal-desktop-bin - pkgs.ghostty - pkgs.spotify - pkgs.git - pkgs.git - pkgs.go - pkgs.nodejs_24 - pkgs.zig - pkgs.python3Full - pkgs.openssh - gnomeExtensions.appindicator - pkgs.vlc + imports = [ + # Include the results of the hardware scan + ./hardware-configuration.nix + + # Import modular configuration files + ./modules/boot.nix + ./modules/networking.nix + ./modules/locale.nix + ./modules/desktop.nix + ./modules/audio.nix + ./modules/users.nix + ./modules/packages.nix + ./modules/programs.nix + ./modules/hardware.nix + ./modules/services.nix + ./modules/aliases.nix ]; - - # Programs - # Steam - programs.steam = { - enable = true; - remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play - dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server - localNetworkGameTransfers.openFirewall = true; # Open ports in the firewall for Steam Local Network Game Transfers - }; - - # Enable OpenGL - hardware.graphics = { - enable = true; - }; - - # Load nvidia driver for Xorg and Wayland - services.xserver.videoDrivers = ["nvidia"]; - - hardware.nvidia = { - modesetting.enable = true; - powerManagement.enable = true; - powerManagement.finegrained = false; - gsp.enable = true; - open = true; - nvidiaSettings = true; - package = config.boot.kernelPackages.nvidiaPackages.beta; - }; - - # Enable the OpenSSH daemon. - services.openssh.enable = true; - - # Open ports in the firewall. - # networking.firewall.allowedTCPPorts = [ ... ]; - # networking.firewall.allowedUDPPorts = [ ... ]; - # Or disable the firewall altogether. - # networking.firewall.enable = false; # 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. It‘s perfectly fine and recommended to leave + # on your system were taken. It's 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 = "25.05"; # Did you read the comment? - } diff --git a/modules/aliases.nix b/modules/aliases.nix new file mode 100644 index 0000000..70347bf --- /dev/null +++ b/modules/aliases.nix @@ -0,0 +1,29 @@ +{ config, pkgs, ... }: + +{ + environment.shellAliases = { + # Help command - shows all available nix commands + "nix:help" = "echo '\n🔧 NixOS Configuration Commands:\n\n📋 Basic Operations:\n nix:rebuild - Rebuild and switch to new configuration\n nix:conf:edit - Edit the main configuration file\n nix:conf:sync - Sync local config to /etc/nixos/ without rebuild\n\n📝 Module Editing:\n nix:edit:boot - Edit boot configuration\n nix:edit:net - Edit networking configuration\n nix:edit:desktop - Edit desktop configuration\n nix:edit:audio - Edit audio configuration\n nix:edit:users - Edit user configuration\n nix:edit:pkgs - Edit packages configuration\n nix:edit:programs - Edit programs configuration\n nix:edit:hardware - Edit hardware configuration\n nix:edit:services - Edit services configuration\n nix:edit:aliases - Edit aliases configuration\n\n🔄 Git Operations:\n nix:conf:push - Copy config to /etc/nixos/, commit changes, and push to remote\n nix:conf:pull - Pull latest changes from remote and sync to /etc/nixos/\n\n💡 Use nix:help to see this list anytime!\n'"; + + # Basic operations + "nix:rebuild" = "sudo nixos-rebuild switch"; + "nix:conf:edit" = "sudo nano ~/Developer/nix/configuration.nix"; + "nix:conf:sync" = "sudo rm -rf /etc/nixos/configuration.nix && sudo cp ~/Developer/nix/configuration.nix /etc/nixos/configuration.nix && sudo rm -rf /etc/nixos/modules && sudo cp -r ~/Developer/nix/modules /etc/nixos/"; + + # Module editing shortcuts + "nix:edit:boot" = "sudo nano ~/Developer/nix/modules/boot.nix"; + "nix:edit:net" = "sudo nano ~/Developer/nix/modules/networking.nix"; + "nix:edit:desktop" = "sudo nano ~/Developer/nix/modules/desktop.nix"; + "nix:edit:audio" = "sudo nano ~/Developer/nix/modules/audio.nix"; + "nix:edit:users" = "sudo nano ~/Developer/nix/modules/users.nix"; + "nix:edit:pkgs" = "sudo nano ~/Developer/nix/modules/packages.nix"; + "nix:edit:programs" = "sudo nano ~/Developer/nix/modules/programs.nix"; + "nix:edit:hardware" = "sudo nano ~/Developer/nix/modules/hardware.nix"; + "nix:edit:services" = "sudo nano ~/Developer/nix/modules/services.nix"; + "nix:edit:aliases" = "sudo nano ~/Developer/nix/modules/aliases.nix"; + + # Git operations + "nix:conf:push" = "sudo rm -rf /etc/nixos/configuration.nix && sudo cp ~/Developer/nix/configuration.nix /etc/nixos/configuration.nix && sudo rm -rf /etc/nixos/modules && sudo cp -r ~/Developer/nix/modules /etc/nixos/ && cd ~/Developer/nix && git add -A && git commit -m \"$(date -u +%s)\" && git push"; + "nix:conf:pull" = "cd ~/Developer/nix && git pull && sudo rm -rf /etc/nixos/configuration.nix && sudo cp ~/Developer/nix/configuration.nix /etc/nixos/configuration.nix && sudo rm -rf /etc/nixos/modules && sudo cp -r ~/Developer/nix/modules /etc/nixos/"; + }; +} \ No newline at end of file diff --git a/modules/audio.nix b/modules/audio.nix new file mode 100644 index 0000000..382fc70 --- /dev/null +++ b/modules/audio.nix @@ -0,0 +1,19 @@ +{ config, pkgs, ... }: + +{ + # Enable sound with pipewire + services.pulseaudio.enable = false; + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + # If you want to use JACK applications, uncomment this + #jack.enable = true; + + # use the example session manager (no others are packaged yet so this is enabled by default, + # no need to redefine it in your config for now) + #media-session.enable = true; + }; +} \ No newline at end of file diff --git a/modules/boot.nix b/modules/boot.nix new file mode 100644 index 0000000..9d4461a --- /dev/null +++ b/modules/boot.nix @@ -0,0 +1,10 @@ +{ config, pkgs, ... }: + +{ + # Bootloader + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; + + # Use latest kernel + boot.kernelPackages = pkgs.linuxPackages_latest; +} \ No newline at end of file diff --git a/modules/desktop.nix b/modules/desktop.nix new file mode 100644 index 0000000..ae808d0 --- /dev/null +++ b/modules/desktop.nix @@ -0,0 +1,22 @@ +{ config, pkgs, ... }: + +{ + # Enable the X11 windowing system + services.xserver.enable = true; + + # Enable the GNOME Desktop Environment + services.xserver.displayManager.gdm.enable = true; + services.xserver.desktopManager.gnome.enable = true; + + # Configure keymap in X11 + services.xserver.xkb = { + layout = "us"; + variant = ""; + }; + + # Enable CUPS to print documents + services.printing.enable = true; + + # Enable touchpad support (enabled default in most desktopManager) + # services.xserver.libinput.enable = true; +} \ No newline at end of file diff --git a/modules/hardware.nix b/modules/hardware.nix new file mode 100644 index 0000000..ccb6afe --- /dev/null +++ b/modules/hardware.nix @@ -0,0 +1,21 @@ +{ config, pkgs, ... }: + +{ + # Enable OpenGL + hardware.graphics = { + enable = true; + }; + + # Load nvidia driver for Xorg and Wayland + services.xserver.videoDrivers = ["nvidia"]; + + hardware.nvidia = { + modesetting.enable = true; + powerManagement.enable = true; + powerManagement.finegrained = false; + gsp.enable = true; + open = true; + nvidiaSettings = true; + package = config.boot.kernelPackages.nvidiaPackages.beta; + }; +} \ No newline at end of file diff --git a/modules/locale.nix b/modules/locale.nix new file mode 100644 index 0000000..c352879 --- /dev/null +++ b/modules/locale.nix @@ -0,0 +1,9 @@ +{ config, pkgs, ... }: + +{ + # Time zone + time.timeZone = "America/Edmonton"; + + # Internationalization properties + i18n.defaultLocale = "en_CA.UTF-8"; +} \ No newline at end of file diff --git a/modules/networking.nix b/modules/networking.nix new file mode 100644 index 0000000..860617d --- /dev/null +++ b/modules/networking.nix @@ -0,0 +1,20 @@ +{ config, pkgs, ... }: + +{ + # Networking configuration + networking.hostName = "lavitz"; # Define your hostname. + # networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. + + # Configure network proxy if necessary + # networking.proxy.default = "http://user:password@proxy:port/"; + # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; + + # Enable networking + networking.networkmanager.enable = true; + + # Open ports in the firewall. + # networking.firewall.allowedTCPPorts = [ ... ]; + # networking.firewall.allowedUDPPorts = [ ... ]; + # Or disable the firewall altogether. + # networking.firewall.enable = false; +} \ No newline at end of file diff --git a/modules/packages.nix b/modules/packages.nix new file mode 100644 index 0000000..f6a7d38 --- /dev/null +++ b/modules/packages.nix @@ -0,0 +1,32 @@ +{ config, pkgs, ... }: + +{ + # Allow unfree packages + nixpkgs.config.allowUnfree = true; + + # System packages + environment.systemPackages = with pkgs; [ + # Browsers and communication + vivaldi + discord + signal-desktop-bin + + # Development tools + zed-editor + git + go + nodejs_24 + zig + python3Full + openssh + + # Desktop applications + bitwarden-desktop + ghostty + spotify + vlc + + # GNOME extensions + gnomeExtensions.appindicator + ]; +} \ No newline at end of file diff --git a/modules/programs.nix b/modules/programs.nix new file mode 100644 index 0000000..aba710f --- /dev/null +++ b/modules/programs.nix @@ -0,0 +1,11 @@ +{ config, pkgs, ... }: + +{ + # Steam + programs.steam = { + enable = true; + remotePlay.openFirewall = true; # Open ports in the firewall for Steam Remote Play + dedicatedServer.openFirewall = true; # Open ports in the firewall for Source Dedicated Server + localNetworkGameTransfers.openFirewall = true; # Open ports in the firewall for Steam Local Network Game Transfers + }; +} \ No newline at end of file diff --git a/modules/services.nix b/modules/services.nix new file mode 100644 index 0000000..52c9897 --- /dev/null +++ b/modules/services.nix @@ -0,0 +1,14 @@ +{ config, pkgs, ... }: + +{ + # Enable the OpenSSH daemon + services.openssh.enable = true; + + # Sleep configuration + systemd.sleep.extraConfig = '' + AllowSuspend=no + AllowHibernation=no + AllowHybridSleep=no + AllowSuspendThenHibernate=no + ''; +} \ No newline at end of file diff --git a/modules/users.nix b/modules/users.nix new file mode 100644 index 0000000..da7f5f6 --- /dev/null +++ b/modules/users.nix @@ -0,0 +1,13 @@ +{ config, pkgs, ... }: + +{ + # Define a user account. Don't forget to set a password with 'passwd'. + users.users.atridad = { + isNormalUser = true; + description = "Atridad"; + extraGroups = [ "networkmanager" "wheel" ]; + packages = with pkgs; [ + # thunderbird + ]; + }; +} \ No newline at end of file