From a646cbb078ee8622080e45d268671b6f101e6982 Mon Sep 17 00:00:00 2001 From: Nettika Date: Thu, 11 Jul 2024 21:03:02 -0700 Subject: [PATCH] Reorganize modules Leverage nixos-hardware --- common.nix | 9 ++++- flake.lock | 17 ++++++++ flake.nix | 10 ++--- hosts/marauder/boot.nix | 27 ------------- hosts/marauder/default.nix | 25 ------------ hosts/marauder/hardware.nix | 38 ------------------ {hosts/marauder => marauder}/backup.nix | 0 .../apps.nix => marauder/configuration.nix | 21 ++++++++++ marauder/hardware-configuration.nix | 39 +++++++++++++++++++ .../default.nix => monolith/configuration.nix | 3 +- 10 files changed, 92 insertions(+), 97 deletions(-) delete mode 100644 hosts/marauder/boot.nix delete mode 100644 hosts/marauder/default.nix delete mode 100644 hosts/marauder/hardware.nix rename {hosts/marauder => marauder}/backup.nix (100%) rename hosts/marauder/apps.nix => marauder/configuration.nix (74%) create mode 100644 marauder/hardware-configuration.nix rename hosts/monolith/default.nix => monolith/configuration.nix (82%) diff --git a/common.nix b/common.nix index 8cfd6a4..b6286dc 100644 --- a/common.nix +++ b/common.nix @@ -4,9 +4,16 @@ inherit hostName; networkmanager.enable = true; }; + + boot.loader = { + systemd-boot.enable = true; + efi.canTouchEfiVariables = true; + }; + + nixpkgs.config.allowUnfree = true; nix.settings.experimental-features = [ "nix-command" "flakes" ]; - + users.users = { nettika = { isNormalUser = true; diff --git a/flake.lock b/flake.lock index 41794aa..d24691a 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,21 @@ { "nodes": { + "nixos-hardware": { + "locked": { + "lastModified": 1720737798, + "narHash": "sha256-G/OtEAts7ZUvW5lrGMXSb8HqRp2Jr9I7reBuvCOL54w=", + "owner": "nixos", + "repo": "nixos-hardware", + "rev": "c5013aa7ce2c7ec90acee5d965d950c8348db751", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "master", + "repo": "nixos-hardware", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1720386169, @@ -34,6 +50,7 @@ }, "root": { "inputs": { + "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs", "nixpkgs-unstable": "nixpkgs-unstable" } diff --git a/flake.nix b/flake.nix index 46d8ae3..fc869f2 100644 --- a/flake.nix +++ b/flake.nix @@ -4,30 +4,30 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; + nixos-hardware.url = "github:nixos/nixos-hardware/master"; }; - outputs = { nixpkgs, ... }@inputs: { + outputs = { nixpkgs, nixos-hardware, ... }: { nixosConfigurations = { marauder = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ - ./hosts/marauder + ./marauder/configuration.nix ./common.nix + nixos-hardware.nixosModules.asus-rog-strix-g513im ]; specialArgs = { hostName = "marauder"; - inherit inputs; }; }; monolith = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; modules = [ - ./hosts/monolith + ./monolith/configuration.nix ./common.nix ]; specialArgs = { hostName = "monolith"; - inherit inputs; }; }; }; diff --git a/hosts/marauder/boot.nix b/hosts/marauder/boot.nix deleted file mode 100644 index 05e5c14..0000000 --- a/hosts/marauder/boot.nix +++ /dev/null @@ -1,27 +0,0 @@ -{ ... }: -{ - boot = { - loader = { - systemd-boot.enable = true; - efi.canTouchEfiVariables = true; - }; - initrd = { - systemd.enable = true; - availableKernelModules = [ - "nvme" - "xhci_pci" - "usbhid" - "usb_storage" - "sd_mod" - ]; - }; - kernelModules = ["kvm-amd"]; - kernelParams = [ - "amd_pstate=active" - "quiet" - "loglevel=3" - "udev.log-priority=3" - ]; - plymouth.enable = true; - }; -} diff --git a/hosts/marauder/default.nix b/hosts/marauder/default.nix deleted file mode 100644 index a3071cd..0000000 --- a/hosts/marauder/default.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ config, lib, pkgs, inputs, ... }: -{ - imports = [ - ./apps.nix - ./backup.nix - ./boot.nix - ./hardware.nix - ]; - - nixpkgs.config.allowUnfree = true; - - services = { - xserver = { - enable = true; - desktopManager = { - cinnamon.enable = true; - xterm.enable = false; - }; - }; - displayManager.defaultSession = "cinnamon"; - }; - - time.timeZone = "America/Los_Angeles"; - system.stateVersion = "24.05"; -} diff --git a/hosts/marauder/hardware.nix b/hosts/marauder/hardware.nix deleted file mode 100644 index 354db6a..0000000 --- a/hosts/marauder/hardware.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ pkgs, ... }: -{ - fileSystems = { - "/" = { - device = "/dev/disk/by-uuid/648c6539-892c-40d7-8b07-23fe760df02a"; - fsType = "ext4"; - }; - "/boot" = { - device = "/dev/disk/by-uuid/1D62-C30E"; - fsType = "vfat"; - options = [ "fmask=0022" "dmask=0022" ]; - }; - }; - - hardware = { - enableRedistributableFirmware = true; - cpu.amd.updateMicrocode = true; - opengl = { - enable = true; - driSupport32Bit = true; - extraPackages = [pkgs.vaapiVdpau]; - }; - nvidia.prime = { - offload = { - enable = true; - enableOffloadCmd = true; - }; - amdgpuBusId = "PCI:05:00:0"; - nvidiaBusId = "PCI:01:00:0"; - }; - }; - - services = { - xserver.videoDrivers = ["nvidia"]; - tlp.enable = true; - fstrim.enable = true; - }; -} diff --git a/hosts/marauder/backup.nix b/marauder/backup.nix similarity index 100% rename from hosts/marauder/backup.nix rename to marauder/backup.nix diff --git a/hosts/marauder/apps.nix b/marauder/configuration.nix similarity index 74% rename from hosts/marauder/apps.nix rename to marauder/configuration.nix index 9b93544..f2e8e2d 100644 --- a/hosts/marauder/apps.nix +++ b/marauder/configuration.nix @@ -1,5 +1,10 @@ { pkgs, ... }: { + imports = [ + ./backup.nix + ./hardware-configuration.nix + ]; + environment.systemPackages = with pkgs; [ # Chat clients discord @@ -56,4 +61,20 @@ dedicatedServer.openFirewall = true; }; }; + + services = { + xserver = { + enable = true; + desktopManager = { + cinnamon.enable = true; + xterm.enable = false; + }; + }; + displayManager.defaultSession = "cinnamon"; + }; + + time.timeZone = "America/Los_Angeles"; + + system.stateVersion = "24.05"; } + diff --git a/marauder/hardware-configuration.nix b/marauder/hardware-configuration.nix new file mode 100644 index 0000000..0ac022f --- /dev/null +++ b/marauder/hardware-configuration.nix @@ -0,0 +1,39 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "usbhid" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/648c6539-892c-40d7-8b07-23fe760df02a"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/1D62-C30E"; + fsType = "vfat"; + options = [ "fmask=0022" "dmask=0022" ]; + }; + + swapDevices = [ ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.enp2s0.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp3s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/monolith/default.nix b/monolith/configuration.nix similarity index 82% rename from hosts/monolith/default.nix rename to monolith/configuration.nix index 8aae1f1..cd3b972 100644 --- a/hosts/monolith/default.nix +++ b/monolith/configuration.nix @@ -1,4 +1,5 @@ -{ ... }: { +{ ... }: { time.timeZone = "America/Los_Angeles"; + system.stateVersion = "24.05"; }