From e0d51e823a34ff5c4caddb70e18f88972ed98ae9 Mon Sep 17 00:00:00 2001 From: Crony Akatsuki Date: Sun, 17 Mar 2024 17:18:40 +0100 Subject: [PATCH] Modulize the config more. --- nixos/configuration.nix | 51 +++++-------------------------- nixos/modules/appimages.nix | 11 +++++++ nixos/modules/esync.nix | 11 +++++++ nixos/modules/network-manager.nix | 9 ++++++ nixos/modules/ryzenadj.nix | 14 +++++++++ 5 files changed, 52 insertions(+), 44 deletions(-) create mode 100644 nixos/modules/appimages.nix create mode 100644 nixos/modules/esync.nix create mode 100644 nixos/modules/network-manager.nix create mode 100644 nixos/modules/ryzenadj.nix diff --git a/nixos/configuration.nix b/nixos/configuration.nix index 54d3668..09121a3 100644 --- a/nixos/configuration.nix +++ b/nixos/configuration.nix @@ -8,6 +8,10 @@ ./modules/disable-hibernation.nix ./modules/dns-over-https.nix ./modules/nvidia.nix + ./modules/network-manager.nix + ./modules/esync.nix + ./modules/ryzenadj.nix + ./modules/appimages.nix ]; # Bootloader. @@ -17,15 +21,15 @@ # Current lts kernel boot.kernelPackages = pkgs.linuxPackages; + # load amdgpu and nouveau at boot + boot.initrd.kernelModules = [ "amdgpu" ]; + # Enable gsp # boot.kernelParams = [ # "nouveau.config=NvGspRM=1" # "nouveau.debug=info,VBIOS=info,gsp=debug" # ]; - # load amdgpu and nouveau at boot - boot.initrd.kernelModules = [ "amdgpu" ]; - # Set the hostname networking.hostName = "nixos"; @@ -35,14 +39,6 @@ # Allow unfree packages nixpkgs.config.allowUnfree = true; - # Enable networking - networking.networkmanager.enable = true; - - # Set iwd as wifi backend - networking.wireless.iwd.enable = true; - networking.networkmanager.wifi.backend = "iwd"; - networking.networkmanager.wifi.powersave = false; - # Set your time zone. time.timeZone = "Europe/Zagreb"; @@ -217,16 +213,6 @@ # Add ~/.local/bin to path environment.localBinInPath = true; - # Allow appimages to run manually - boot.binfmt.registrations.appimage = { - wrapInterpreterInShell = false; - interpreter = "${pkgs.appimage-run}/bin/appimage-run"; - recognitionType = "magic"; - offset = 0; - mask = "\\xff\\xff\\xff\\xff\\x00\\x00\\x00\\x00\\xff\\xff\\xff"; - magicOrExtension = "\\x7fELF....AI\\x02"; - }; - # Automatic cleanup and optimization nix.optimise.automatic = true; nix.gc = { @@ -235,29 +221,6 @@ options = "--delete-older-than 15d"; }; - # Set power settings for my laptop cpu - systemd.services.ryzenadj = { - enable = true; - description = "Set my ryzen cpu power."; - serviceConfig = { - Type = "oneshot"; - ExecStart = toString (pkgs.writeShellScript "ryzenadj-setup" '' - ${pkgs.ryzenadj}/bin/ryzenadj --stapm-limit 35000 --fast-limit 35000 --slow-limit 35000 --slow-time 60 --stapm-time 1000 --tctl-temp 90 --vrmmax-current 65000 - ''); - }; - wantedBy = [ "default.target" ]; - }; - - # Esync - systemd.extraConfig = "DefaultLimitNOFILE=1048576"; - - security.pam.loginLimits = [{ - domain = "*"; - type = "hard"; - item = "nofile"; - value = "1048576"; - }]; - # Enable virt manager virtualisation.libvirtd.enable = true; programs.virt-manager.enable = true; diff --git a/nixos/modules/appimages.nix b/nixos/modules/appimages.nix new file mode 100644 index 0000000..9a3bb9c --- /dev/null +++ b/nixos/modules/appimages.nix @@ -0,0 +1,11 @@ +{ pkgs, ... }: { + # Allow appimages to run manually + boot.binfmt.registrations.appimage = { + wrapInterpreterInShell = false; + interpreter = "${pkgs.appimage-run}/bin/appimage-run"; + recognitionType = "magic"; + offset = 0; + mask = "\\xff\\xff\\xff\\xff\\x00\\x00\\x00\\x00\\xff\\xff\\xff"; + magicOrExtension = "\\x7fELF....AI\\x02"; + }; +} diff --git a/nixos/modules/esync.nix b/nixos/modules/esync.nix new file mode 100644 index 0000000..145928b --- /dev/null +++ b/nixos/modules/esync.nix @@ -0,0 +1,11 @@ +{ ... }: { + # Esync + systemd.extraConfig = "DefaultLimitNOFILE=1048576"; + + security.pam.loginLimits = [{ + domain = "*"; + type = "hard"; + item = "nofile"; + value = "1048576"; + }]; +} diff --git a/nixos/modules/network-manager.nix b/nixos/modules/network-manager.nix new file mode 100644 index 0000000..8c7de94 --- /dev/null +++ b/nixos/modules/network-manager.nix @@ -0,0 +1,9 @@ +{ ... }: { + # Enable networking + networking.networkmanager.enable = true; + + # Set iwd as wifi backend + networking.wireless.iwd.enable = true; + networking.networkmanager.wifi.backend = "iwd"; + networking.networkmanager.wifi.powersave = false; +} diff --git a/nixos/modules/ryzenadj.nix b/nixos/modules/ryzenadj.nix new file mode 100644 index 0000000..312018c --- /dev/null +++ b/nixos/modules/ryzenadj.nix @@ -0,0 +1,14 @@ +{ pkgs, ... }: { + # Set power settings for my laptop cpu + systemd.services.ryzenadj = { + enable = true; + description = "Set my ryzen cpu power."; + serviceConfig = { + Type = "oneshot"; + ExecStart = toString (pkgs.writeShellScript "ryzenadj-setup" '' + ${pkgs.ryzenadj}/bin/ryzenadj --stapm-limit 35000 --fast-limit 35000 --slow-limit 35000 --slow-time 60 --stapm-time 1000 --tctl-temp 90 --vrmmax-current 65000 + ''); + }; + wantedBy = [ "default.target" ]; + }; +}