From ed7df00704df54916c32d40d5e3ef6a9e2939f4d Mon Sep 17 00:00:00 2001 From: Michael Thomson Date: Wed, 15 May 2024 17:08:53 -0400 Subject: [PATCH] split nixos config --- hosts/desktop/configuration.nix | 129 ++++---------------------------- modules/nixos/bootloader.nix | 4 + modules/nixos/env.nix | 5 ++ modules/nixos/i3.nix | 33 ++++++++ modules/nixos/nix-ld.nix | 6 ++ modules/nixos/nm.nix | 3 + modules/nixos/nvidia.nix | 11 +++ modules/nixos/sound.nix | 9 +++ modules/nixos/steam.nix | 9 +++ modules/nixos/user.nix | 27 +++++++ 10 files changed, 120 insertions(+), 116 deletions(-) create mode 100644 modules/nixos/bootloader.nix create mode 100644 modules/nixos/env.nix create mode 100644 modules/nixos/i3.nix create mode 100644 modules/nixos/nix-ld.nix create mode 100644 modules/nixos/nm.nix create mode 100644 modules/nixos/nvidia.nix create mode 100644 modules/nixos/sound.nix create mode 100644 modules/nixos/steam.nix create mode 100644 modules/nixos/user.nix diff --git a/hosts/desktop/configuration.nix b/hosts/desktop/configuration.nix index 1421770..429e425 100644 --- a/hosts/desktop/configuration.nix +++ b/hosts/desktop/configuration.nix @@ -1,130 +1,39 @@ -# 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, inputs, ... }: { imports = - [ # Include the results of the hardware scan. + [ ./hardware-configuration.nix inputs.home-manager.nixosModules.default + ../../modules/nixos/bootloader.nix + ../../modules/nixos/user.nix + ../../modules/nixos/nvidia.nix + ../../modules/nixos/i3.nix + ../../modules/nixos/nm.nix + ../../modules/nixos/sound.nix + ../../modules/nixos/steam.nix + ../../modules/nixos/env.nix ]; -# Kernel boot.kernelPackages = pkgs.linuxPackages_latest; -# Bootloader. - boot.loader.systemd-boot.enable = true; - boot.loader.efi.canTouchEfiVariables = true; + networking.hostName = "desktop"; - networking.hostName = "desktop"; # Define your hostname. -# networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. - -# Enable networking - networking.networkmanager.enable = true; - -# Set your time zone. time.timeZone = "America/Toronto"; -# Select internationalisation properties. i18n.defaultLocale = "en_CA.UTF-8"; - hardware.opengl = { - enable = true; - driSupport = true; - driSupport32Bit = true; - }; - - hardware.nvidia.modesetting.enable = true; - -# i3 relates stuff - environment.pathsToLink = [ "/libexec" ]; - services.xserver = { - enable = true; - - desktopManager = { - xterm.enable = false; - }; - - videoDrivers = [ "nvidia "]; - - displayManager = { - defaultSession = "none+i3"; - lightdm.enable = true; - }; - - windowManager.i3 = { - enable = true; - package = pkgs.i3-gaps; - extraPackages = with pkgs; [ - dmenu - i3status - i3lock - i3blocks - feh - arandr - ]; - }; - - layout = "us"; - xkbVariant = ""; - }; - -# pipewire - security.rtkit.enable = true; - services.pipewire = { - enable = true; - alsa.enable = true; - alsa.support32Bit = true; - pulse.enable = true; - }; - -# Define a user account. Don't forget to set a password with ‘passwd’. - users.users.mthomson = { - shell = pkgs.zsh; - isNormalUser = true; - description = "Michael Thomson"; - extraGroups = [ "networkmanager" "wheel" ]; - packages = with pkgs; []; - }; - -# Allow unfree packages nixpkgs.config.allowUnfree = true; - nix.settings = { - trusted-users = ["mthomson"]; - - substituters = [ - "https://cache.nixos.org" - "https://nix-community.cachix.org" - ]; - - trusted-public-keys = [ - "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" - ]; - }; - - nix.settings.experimental-features = [ "nix-command" "flakes" ]; + environment.systemPackages = with pkgs; [ - neovim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default. + neovim wget git curl ]; - environment.variables.EDITOR = "nvim"; - - programs = { - zsh.enable = true; - steam = { - enable = true; - gamescopeSession.enable = true; - }; - gamemode.enable = true; - }; - home-manager = { extraSpecialArgs = { inherit inputs; }; useGlobalPkgs = true; @@ -134,18 +43,6 @@ }; }; - programs.nix-ld.enable = true; - programs.nix-ld.libraries = with pkgs; [ -# Add any missing dynamic libraries for unpackaged programs -# here, NOT in environment.systemPackages - ]; - -# 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 -# 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 = "23.11"; # Did you read the comment? + system.stateVersion = "23.11"; } diff --git a/modules/nixos/bootloader.nix b/modules/nixos/bootloader.nix new file mode 100644 index 0000000..d39e4ca --- /dev/null +++ b/modules/nixos/bootloader.nix @@ -0,0 +1,4 @@ +{ + boot.loader.systemd-boot.enable = true; + boot.loader.efi.canTouchEfiVariables = true; +} diff --git a/modules/nixos/env.nix b/modules/nixos/env.nix new file mode 100644 index 0000000..2168566 --- /dev/null +++ b/modules/nixos/env.nix @@ -0,0 +1,5 @@ +{ + environment.variables = { + EDITOR = "nvim"; + }; +} diff --git a/modules/nixos/i3.nix b/modules/nixos/i3.nix new file mode 100644 index 0000000..3d50828 --- /dev/null +++ b/modules/nixos/i3.nix @@ -0,0 +1,33 @@ +{ pkgs, ... }: + +{ + environment.pathsToLink = [ "/libexec" ]; + services.xserver = { + enable = true; + + desktopManager = { + xterm.enable = false; + }; + + displayManager = { + defaultSession = "none+i3"; + lightdm.enable = true; + }; + + windowManager.i3 = { + enable = true; + package = pkgs.i3-gaps; + extraPackages = with pkgs; [ + dmenu + i3status + i3lock + i3blocks + feh + arandr + ]; + }; + + layout = "us"; + xkbVariant = ""; + }; +} diff --git a/modules/nixos/nix-ld.nix b/modules/nixos/nix-ld.nix new file mode 100644 index 0000000..db9883b --- /dev/null +++ b/modules/nixos/nix-ld.nix @@ -0,0 +1,6 @@ +{ pkgs, ... }: + +{ + programs.nix-ld.enable = true; + programs.nix-ld.libraries = with pkgs; []; +} diff --git a/modules/nixos/nm.nix b/modules/nixos/nm.nix new file mode 100644 index 0000000..f29d881 --- /dev/null +++ b/modules/nixos/nm.nix @@ -0,0 +1,3 @@ +{ + networking.networkmanager.enable = true; +} diff --git a/modules/nixos/nvidia.nix b/modules/nixos/nvidia.nix new file mode 100644 index 0000000..5fb2d48 --- /dev/null +++ b/modules/nixos/nvidia.nix @@ -0,0 +1,11 @@ +{ + hardware.opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + }; + + hardware.nvidia.modesetting.enable = true; + + services.xserver.videoDrivers = [ "nvidia "]; +} diff --git a/modules/nixos/sound.nix b/modules/nixos/sound.nix new file mode 100644 index 0000000..e372d47 --- /dev/null +++ b/modules/nixos/sound.nix @@ -0,0 +1,9 @@ +{ + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; +} diff --git a/modules/nixos/steam.nix b/modules/nixos/steam.nix new file mode 100644 index 0000000..9b0dc7f --- /dev/null +++ b/modules/nixos/steam.nix @@ -0,0 +1,9 @@ +{ + programs = { + steam = { + enable = true; + gamescopeSession.enable = true; + }; + gamemode.enable = true; + }; +} diff --git a/modules/nixos/user.nix b/modules/nixos/user.nix new file mode 100644 index 0000000..5b03d44 --- /dev/null +++ b/modules/nixos/user.nix @@ -0,0 +1,27 @@ +{ pkgs, ... }: + +{ + programs.zsh.enable = true; + + nix.settings = { + trusted-users = ["mthomson"]; + + substituters = [ + "https://cache.nixos.org" + "https://nix-community.cachix.org" + ]; + + trusted-public-keys = [ + "nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs=" + ]; + }; + + + users.users.mthomson = { + shell = pkgs.zsh; + isNormalUser = true; + description = "Michael Thomson"; + extraGroups = [ "networkmanager" "wheel" ]; + packages = with pkgs; []; + }; +}