From 9503cf06f9298698b62adb4ff8ccb8b19eb89487 Mon Sep 17 00:00:00 2001 From: Dmitry Voronin Date: Wed, 21 Feb 2024 01:58:01 +0300 Subject: [PATCH] System : Attempt to use single HW config. --- .config/bash/module/Bootstrap.sh | 2 + .config/linux/system/flake.nix | 5 ++- .../host/desktop/HardwareConfiguration.nix | 38 ------------------- .../host/fsight/HardwareConfiguration.nix | 2 - .config/linux/system/module/AmdCpu.nix | 4 ++ .../linux/system/module/common/Filesystem.nix | 10 +++++ .../linux/system/module/common/Network.nix | 1 + .config/linux/system/module/common/Swap.nix | 1 + 8 files changed, 22 insertions(+), 41 deletions(-) delete mode 100644 .config/linux/system/host/desktop/HardwareConfiguration.nix create mode 100644 .config/linux/system/module/AmdCpu.nix create mode 100644 .config/linux/system/module/common/Filesystem.nix diff --git a/.config/bash/module/Bootstrap.sh b/.config/bash/module/Bootstrap.sh index ac9c06b..49e75c0 100644 --- a/.config/bash/module/Bootstrap.sh +++ b/.config/bash/module/Bootstrap.sh @@ -58,6 +58,8 @@ function bootstrap_nixos() { parted -s "${target}" mktable gpt parted -s "${target}" mkpart primary 0% 512MB parted -s "${target}" mkpart primary 512MB 100% + parted -s "${target}" name NIXBOOT + parted -s "${target}" name NIXROOT # Format. mkfs.fat -F 32 "${target}1" diff --git a/.config/linux/system/flake.nix b/.config/linux/system/flake.nix index cd0c61e..d9d55d5 100644 --- a/.config/linux/system/flake.nix +++ b/.config/linux/system/flake.nix @@ -19,6 +19,7 @@ ./module/common/Bootloader.nix ./module/common/Distrobox.nix ./module/common/Dotfiles.nix + ./module/common/Filesystem.nix ./module/common/Firewall.nix ./module/common/Kernel.nix ./module/common/Locale.nix @@ -37,7 +38,6 @@ modules = [ ./host/${hostname}/Configuration.nix - ./host/${hostname}/HardwareConfiguration.nix { networking.hostName = hostname; } { system.stateVersion = inputs.self.nixosModules.const.stateVersion; } inputs.self.nixosModules.common @@ -66,6 +66,7 @@ system = "x86_64-linux"; modules = [ ./module/AmdGpu.nix + ./module/AmdCpu.nix ./module/Flatpak.nix ./module/Gnome.nix ./module/PowersaveAmd.nix @@ -88,6 +89,7 @@ system = "x86_64-linux"; modules = [ ./module/AmdGpu.nix + ./module/AmdCpu.nix ./module/Docker.nix ./module/Flatpak.nix ./module/Ftpd.nix @@ -102,6 +104,7 @@ system = "x86_64-linux"; modules = [ ./module/AmdGpu.nix + ./module/AmdCpu.nix ./module/Flatpak.nix ./module/Gnome.nix ./module/PowersaveAmd.nix diff --git a/.config/linux/system/host/desktop/HardwareConfiguration.nix b/.config/linux/system/host/desktop/HardwareConfiguration.nix deleted file mode 100644 index f357380..0000000 --- a/.config/linux/system/host/desktop/HardwareConfiguration.nix +++ /dev/null @@ -1,38 +0,0 @@ -# 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" "ahci" "usb_storage" "usbhid" "sd_mod" ]; - boot.initrd.kernelModules = [ "dm-snapshot" ]; - boot.kernelModules = [ "kvm-amd" ]; - boot.extraModulePackages = [ ]; - - fileSystems."/" = - { device = "/dev/disk/by-uuid/fea39df0-7f07-4c33-88e8-0777ef0d3764"; - fsType = "ext4"; - }; - - fileSystems."/boot" = - { device = "/dev/disk/by-uuid/CEBE-053D"; - fsType = "vfat"; - }; - - 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.enp42s0.useDHCP = lib.mkDefault true; - # networking.interfaces.enp4s0.useDHCP = lib.mkDefault true; - - nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; - hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; -} diff --git a/.config/linux/system/host/fsight/HardwareConfiguration.nix b/.config/linux/system/host/fsight/HardwareConfiguration.nix index 727f599..222c948 100644 --- a/.config/linux/system/host/fsight/HardwareConfiguration.nix +++ b/.config/linux/system/host/fsight/HardwareConfiguration.nix @@ -16,13 +16,11 @@ fsType = "ext4"; }; - 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.ens32.useDHCP = lib.mkDefault true; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; diff --git a/.config/linux/system/module/AmdCpu.nix b/.config/linux/system/module/AmdCpu.nix new file mode 100644 index 0000000..936ada5 --- /dev/null +++ b/.config/linux/system/module/AmdCpu.nix @@ -0,0 +1,4 @@ +{ ... }: { + boot.kernelModules = [ "kvm-amd" ]; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/.config/linux/system/module/common/Filesystem.nix b/.config/linux/system/module/common/Filesystem.nix new file mode 100644 index 0000000..8b49c54 --- /dev/null +++ b/.config/linux/system/module/common/Filesystem.nix @@ -0,0 +1,10 @@ +{ ... }: { + fileSystems."/" = { + device = "/dev/disk/by-partlabel/NIXROOT"; + fsType = "ext4"; + }; + fileSystems."/boot" = { + device = "/dev/disk/by-partlabel/NIXBOOT"; + fsType = "vfat"; + }; +} diff --git a/.config/linux/system/module/common/Network.nix b/.config/linux/system/module/common/Network.nix index a6a5e28..e100bf0 100644 --- a/.config/linux/system/module/common/Network.nix +++ b/.config/linux/system/module/common/Network.nix @@ -1,3 +1,4 @@ { ... }: { networking.networkmanager.enable = true; + networking.useDHCP = true; } diff --git a/.config/linux/system/module/common/Swap.nix b/.config/linux/system/module/common/Swap.nix index 24b1318..88b99ca 100644 --- a/.config/linux/system/module/common/Swap.nix +++ b/.config/linux/system/module/common/Swap.nix @@ -1,3 +1,4 @@ { ... }: { zramSwap.enable = true; + swapDevices = [ ]; }