From 4d2d3705fb9c5f695b3a5aee593209d0a6b78b1e Mon Sep 17 00:00:00 2001 From: jacekpoz Date: Thu, 15 Feb 2024 17:04:34 +0100 Subject: [PATCH] start moving shit to options --- hosts/niks/configuration.nix | 90 ------------------- hosts/niks/default.nix | 1 + hosts/niks/profile.nix | 14 +++ modules/other/default.nix | 2 - options/common/cpu/amd.nix | 11 +++ options/common/docs.nix | 25 ++++++ options/common/gpu/amd.nix | 26 ++++++ options/common/oomd.nix | 8 ++ .../other => options/common}/pin-registry.nix | 0 .../common}/preserve-system.nix | 0 options/desktop/bluetooth.nix | 6 ++ options/desktop/opentabletdriver.nix | 6 ++ options/desktop/power-supply.nix | 30 +++++++ options/desktop/suspend.nix | 18 ++++ 14 files changed, 145 insertions(+), 92 deletions(-) create mode 100644 hosts/niks/profile.nix create mode 100644 options/common/cpu/amd.nix create mode 100644 options/common/docs.nix create mode 100644 options/common/gpu/amd.nix create mode 100644 options/common/oomd.nix rename {modules/other => options/common}/pin-registry.nix (100%) rename {modules/other => options/common}/preserve-system.nix (100%) create mode 100644 options/desktop/bluetooth.nix create mode 100644 options/desktop/opentabletdriver.nix create mode 100644 options/desktop/power-supply.nix create mode 100644 options/desktop/suspend.nix diff --git a/hosts/niks/configuration.nix b/hosts/niks/configuration.nix index 5d553ee1..67a4bce5 100644 --- a/hosts/niks/configuration.nix +++ b/hosts/niks/configuration.nix @@ -39,22 +39,6 @@ ]; }; - documentation = { - enable = true; - dev.enable = true; - doc.enable = false; - info.enable = false; - man = { - enable = true; - generateCaches = false; - man-db.enable = false; - mandoc.enable = true; - }; - nixos = { - includeAllModules = true; - }; - }; - networking = { hostName = config'.hostname; networkmanager = { @@ -73,11 +57,6 @@ services.NetworkManager-wait-online.wantedBy = lib.mkForce []; # default is [ "network-online.target" ] }; - systemd.oomd = { - enable = true; - enableUserSlices = true; - }; - time.timeZone = "Europe/Warsaw"; nix = { @@ -154,10 +133,6 @@ AMD_VULKAN_ICD = "radv"; }; - systemPackages = with pkgs; [ - man-pages - man-pages-posix - ]; }; services = { @@ -198,37 +173,6 @@ enableSSHSupport = true; }; - hardware = { - opentabletdriver = { - enable = true; - daemon.enable = true; - }; - bluetooth = { - enable = true; - input.General.ClassicBondedOnly = true; - }; - opengl = { - enable = true; - driSupport = true; - driSupport32Bit = true; - extraPackages = with pkgs; [ - mesa - amdvlk - libdrm - libva - vaapiVdpau - libvdpau-va-gl - ]; - extraPackages32 = with pkgs; [ - driversi686Linux.mesa - driversi686Linux.amdvlk - driversi686Linux.vaapiVdpau - driversi686Linux.libvdpau-va-gl - ]; - }; - cpu.amd.updateMicrocode = true; - }; - services.btrfs = { autoScrub = { enable = true; @@ -248,45 +192,11 @@ }; services.udev = { - extraRules = let - inherit (inputs.hyprland.packages.${pkgs.system}) hyprland; - - power_supply = pkgs.writeShellScript "on_power_supply" '' - ${pkgs.asusctl}/bin/asusctl profile -P Performance - #${pkgs.supergfxctl}/bin/supergfxctl -m Hybrid - ${config.boot.kernelPackages.cpupower}/bin/cpupower frequency-set -g performance - ${hyprland}/bin/hyprctl keyword decoration:blur:enabled true - ${hyprland}/bin/hyprctl keyword animations:enabled true - ''; - battery = pkgs.writeShellScript "on_battery" '' - ${pkgs.asusctl}/bin/asusctl profile -P Quiet - #${pkgs.supergfxctl}/bin/supergfxctl -m Integrated - ${config.boot.kernelPackages.cpupower}/bin/cpupower frequency-set -g powersave - ${hyprland}/bin/hyprctl keyword decoration:blur:enabled false - ${hyprland}/bin/hyprctl keyword animations:enabled false - ''; - in '' - SUBSYSTEM=="power_supply",ENV{POWER_SUPPLY_ONLINE}=="1",RUN+="${power_supply}" - SUBSYSTEM=="power_supply",ENV{POWER_SUPPLY_ONLINE}=="0",RUN+="${battery}" - ''; packages = with pkgs; [ yubikey-personalization ]; }; - powerManagement = { - enable = true; - powerDownCommands = '' - ${pkgs.mpc-cli}/bin/mpc pause - ${inputs.nixpkgs-wayland.packages.${pkgs.system}.swaylock-effects}/bin/swaylock - ${pkgs.coreutils-full}/bin/sleep 1 - ''; - powerUpCommands = '' - ${inputs.hyprland.packages.${pkgs.system}.hyprland}/bin/hyprctl dispatch dpms off HDMI-A-1 - ${inputs.hyprland.packages.${pkgs.system}.hyprland}/bin/hyprctl dispatch dpms on HDMI-A-1 - ''; - }; - # this makes usb devices autosuspend #powerManagement.powertop.enable = true; diff --git a/hosts/niks/default.nix b/hosts/niks/default.nix index 4c6eece1..e0a85c74 100644 --- a/hosts/niks/default.nix +++ b/hosts/niks/default.nix @@ -4,6 +4,7 @@ _: { ./fcitx5.nix ./hardware-configuration.nix #./mullvad.nix + ./profile.nix ./programs.nix #./restic.nix ./waydroid.nix diff --git a/hosts/niks/profile.nix b/hosts/niks/profile.nix new file mode 100644 index 00000000..4b0ac504 --- /dev/null +++ b/hosts/niks/profile.nix @@ -0,0 +1,14 @@ +_: { + imports = [ + ../../options/common/cpu/amd.nix + ../../options/common/docs.nix + ../../options/common/gpu/amd.nix + ../../options/common/oomd.nix + ../../options/common/pin-registry.nix + ../../options/common/preserve-system.nix + ../../options/desktop/bluetooth.nix + ../../options/desktop/opentabletdriver.nix + ../../options/desktop/power-supply.nix + ../../options/desktop/suspend.nix + ]; +} diff --git a/modules/other/default.nix b/modules/other/default.nix index 1dc84249..6f186888 100644 --- a/modules/other/default.nix +++ b/modules/other/default.nix @@ -1,8 +1,6 @@ _: { imports = [ ./home-manager.nix - ./pin-registry.nix - ./preserve-system.nix ./xdg.nix ]; } diff --git a/options/common/cpu/amd.nix b/options/common/cpu/amd.nix new file mode 100644 index 00000000..1ea10c2d --- /dev/null +++ b/options/common/cpu/amd.nix @@ -0,0 +1,11 @@ +_: { + hardware.cpu.amd.updateMicrocode = true; + + services.auto-epp = { + enable = true; + settings.Settings = { + epp_state_for_BAT = "power"; + epp_state_for_AC = "balance_power"; + }; + }; +} diff --git a/options/common/docs.nix b/options/common/docs.nix new file mode 100644 index 00000000..ab1b8c03 --- /dev/null +++ b/options/common/docs.nix @@ -0,0 +1,25 @@ +{ + pkgs, + ... +}: { + documentation = { + enable = true; + dev.enable = true; + doc.enable = false; + info.enable = false; + man = { + enable = true; + generateCaches = false; + man-db.enable = false; + mandoc.enable = true; + }; + nixos = { + includeAllModules = true; + }; + }; + + environment.systemPackages = with pkgs; [ + man-pages + man-pages-posix + ]; +} diff --git a/options/common/gpu/amd.nix b/options/common/gpu/amd.nix new file mode 100644 index 00000000..926d4592 --- /dev/null +++ b/options/common/gpu/amd.nix @@ -0,0 +1,26 @@ +{ + pkgs, + ... +}: { + hardware = { + opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + extraPackages = with pkgs; [ + mesa + amdvlk + libdrm + libva + vaapiVdpau + libvdpau-va-gl + ]; + extraPackages32 = with pkgs; [ + driversi686Linux.mesa + driversi686Linux.amdvlk + driversi686Linux.vaapiVdpau + driversi686Linux.libvdpau-va-gl + ]; + }; + }; +} diff --git a/options/common/oomd.nix b/options/common/oomd.nix new file mode 100644 index 00000000..64b06d9b --- /dev/null +++ b/options/common/oomd.nix @@ -0,0 +1,8 @@ +_: { + systemd.oomd = { + enable = true; + enableSystemSlice = true; + enableRootSlice = true; + enableUserSlices = true; + }; +} diff --git a/modules/other/pin-registry.nix b/options/common/pin-registry.nix similarity index 100% rename from modules/other/pin-registry.nix rename to options/common/pin-registry.nix diff --git a/modules/other/preserve-system.nix b/options/common/preserve-system.nix similarity index 100% rename from modules/other/preserve-system.nix rename to options/common/preserve-system.nix diff --git a/options/desktop/bluetooth.nix b/options/desktop/bluetooth.nix new file mode 100644 index 00000000..de892b53 --- /dev/null +++ b/options/desktop/bluetooth.nix @@ -0,0 +1,6 @@ +_: { + hardware.bluetooth = { + enable = true; + input.General.ClassicBondedOnly = true; + }; +} diff --git a/options/desktop/opentabletdriver.nix b/options/desktop/opentabletdriver.nix new file mode 100644 index 00000000..a5dd053d --- /dev/null +++ b/options/desktop/opentabletdriver.nix @@ -0,0 +1,6 @@ +_: { + hardware.opentabletdriver = { + enable = true; + daemon.enable = true; + }; +} diff --git a/options/desktop/power-supply.nix b/options/desktop/power-supply.nix new file mode 100644 index 00000000..4914643e --- /dev/null +++ b/options/desktop/power-supply.nix @@ -0,0 +1,30 @@ +{ + config, + inputs, + pkgs, + ... +}: { + services.udev = { + extraRules = let + inherit (inputs.hyprland.packages.${pkgs.system}) hyprland; + + power_supply = pkgs.writeShellScript "on_power_supply" '' + ${pkgs.asusctl}/bin/asusctl profile -P Performance + #${pkgs.supergfxctl}/bin/supergfxctl -m Hybrid + ${config.boot.kernelPackages.cpupower}/bin/cpupower frequency-set -g performance + ${hyprland}/bin/hyprctl keyword decoration:blur:enabled true + ${hyprland}/bin/hyprctl keyword animations:enabled true + ''; + battery = pkgs.writeShellScript "on_battery" '' + ${pkgs.asusctl}/bin/asusctl profile -P Quiet + #${pkgs.supergfxctl}/bin/supergfxctl -m Integrated + ${config.boot.kernelPackages.cpupower}/bin/cpupower frequency-set -g powersave + ${hyprland}/bin/hyprctl keyword decoration:blur:enabled false + ${hyprland}/bin/hyprctl keyword animations:enabled false + ''; + in '' + SUBSYSTEM=="power_supply",ENV{POWER_SUPPLY_ONLINE}=="1",RUN+="${power_supply}" + SUBSYSTEM=="power_supply",ENV{POWER_SUPPLY_ONLINE}=="0",RUN+="${battery}" + ''; + }; +} diff --git a/options/desktop/suspend.nix b/options/desktop/suspend.nix new file mode 100644 index 00000000..ee0ddc39 --- /dev/null +++ b/options/desktop/suspend.nix @@ -0,0 +1,18 @@ +{ + inputs, + pkgs, + ... +}: { + powerManagement = { + enable = true; + powerDownCommands = '' + ${pkgs.mpc-cli}/bin/mpc pause + ${inputs.nixpkgs-wayland.packages.${pkgs.system}.swaylock-effects}/bin/swaylock + ${pkgs.coreutils-full}/bin/sleep 1 + ''; + powerUpCommands = '' + ${inputs.hyprland.packages.${pkgs.system}.hyprland}/bin/hyprctl dispatch dpms off HDMI-A-1 + ${inputs.hyprland.packages.${pkgs.system}.hyprland}/bin/hyprctl dispatch dpms on HDMI-A-1 + ''; + }; +}