diff options
author | Jon Santmyer <jon@jonsantmyer.com> | 2024-01-07 12:00:08 -0500 |
---|---|---|
committer | Jon Santmyer <jon@jonsantmyer.com> | 2024-01-07 12:00:08 -0500 |
commit | 7b79203f54853733d4fae88943829d0e24e6e49f (patch) | |
tree | a352d199fad7453332b9308a6295164157729f27 /modules/hardware | |
parent | 184bd30bcb303104a4981ac742d8f8961c5477e7 (diff) | |
download | nix-config-7b79203f54853733d4fae88943829d0e24e6e49f.tar.gz nix-config-7b79203f54853733d4fae88943829d0e24e6e49f.tar.bz2 nix-config-7b79203f54853733d4fae88943829d0e24e6e49f.zip |
massive overhaul
Diffstat (limited to 'modules/hardware')
-rw-r--r-- | modules/hardware/audio.nix | 44 | ||||
-rw-r--r-- | modules/hardware/bluetooth.nix | 34 | ||||
-rw-r--r-- | modules/hardware/cpu.nix | 27 | ||||
-rw-r--r-- | modules/hardware/gpu.nix | 61 | ||||
-rw-r--r-- | modules/hardware/network.nix | 27 |
5 files changed, 181 insertions, 12 deletions
diff --git a/modules/hardware/audio.nix b/modules/hardware/audio.nix new file mode 100644 index 0000000..3ffa32a --- /dev/null +++ b/modules/hardware/audio.nix @@ -0,0 +1,44 @@ +{ + config, + options, + lib, + pkgs, + ... +}: let + audioConfig = config.modules.hardware.audio; + device = config.modules.device; +in { + options.modules.hardware.audio = { + enable = lib.mkOption { + type = lib.types.bool; + default = true; + }; + }; + + config = lib.mkIf (audioConfig.enable) (lib.mkMerge [ + { + security.rtkit.enable = true; + services.pipewire = { + enable = true; + alsa.enable = true; + alsa.support32Bit = true; + pulse.enable = true; + }; + + user.extraGroups = ["audio"]; + home.packages = [pkgs.pavucontrol]; + } + (lib.mkIf (device.hasBluetooth) { + home.configFile = { + "wireplumber/bluetooth.lua.d/51-bluez-config.lua".text = '' + bluez_monitor.properties = { + ["bluez5.enable-sbc-xq"] = true, + ["bluez5.enable-msbc"] = true, + ["bluez5.enable-hw-volume"] = true, + ["bluez5.headset-roles"] = "[ hsp_hs hsp_ag hfp_hf hfp_ag ]" + } + ''; + }; + }) + ]); +} diff --git a/modules/hardware/bluetooth.nix b/modules/hardware/bluetooth.nix index 1465d68..7f835bf 100644 --- a/modules/hardware/bluetooth.nix +++ b/modules/hardware/bluetooth.nix @@ -1,16 +1,26 @@ -{ config, lib, pkgs, ... }: { - hardware.bluetooth.enable = true; - services.blueman.enable = true; + config, + options, + lib, + pkgs, + ... +}: let + bluetoothConfig = config.modules.hardware.bluetooth; + device = config.modules.device; +in { + options.modules.hardware.bluetooth = { + enable = lib.mkOption { + type = lib.types.bool; + default = true; + }; + }; - environment.etc = { - "wireplumber/bluetooth.lua.d/51-bluez-config.lua".text = '' -bluez_monitor.properties = { - ["bluez5.enable-sbc-xq"] = true, - ["bluez5.enable-msbc"] = true, - ["bluez5.enable-hw-volume"] = true, - ["bluez5.headset-roles"] = "[ hsp_hs hsp_ag hfp_hf hfp_ag ]" -} - ''; + config = lib.mkIf (bluetoothConfig.enable && device.hasBluetooth) { + hardware.bluetooth = { + enable = true; + package = pkgs.bluez; + powerOnBoot = true; + }; + user.extraGroups = ["bluetooth"]; }; } diff --git a/modules/hardware/cpu.nix b/modules/hardware/cpu.nix new file mode 100644 index 0000000..8bf2923 --- /dev/null +++ b/modules/hardware/cpu.nix @@ -0,0 +1,27 @@ +{ + config, + options, + lib, + ... +}: let + cpuConfig = config.modules.hardware.cpu; + device = config.modules.device; +in { + options.modules.hardware.cpu = { + enable = lib.mkOption { + type = lib.types.bool; + default = true; + }; + }; + + config = lib.mkIf (cpuConfig.enable) (lib.mkMerge [ + { + hardware.enableRedistributableFirmware = true; + environment.systemPackages = [config.boot.kernelPackages.cpupower]; + } + (lib.mkIf (device.cpu == "intel") { + hardware.cpu.intel.updateMicrocode = true; + boot.kernelModules = ["kvm-intel"]; + }) + ]); +} diff --git a/modules/hardware/gpu.nix b/modules/hardware/gpu.nix new file mode 100644 index 0000000..d7dfe17 --- /dev/null +++ b/modules/hardware/gpu.nix @@ -0,0 +1,61 @@ +{ + config, + options, + lib, + pkgs, + ... +}: let + gpuConfig = config.modules.hardware.gpu; + device = config.modules.device; +in { + options.modules.hardware.gpu = { + enable = lib.mkOption { + type = lib.types.bool; + default = true; + }; + }; + + config = lib.mkIf (gpuConfig.enable) (lib.mkMerge [ + { + hardware.opengl = { + enable = true; + driSupport = true; + driSupport32Bit = true; + }; + } + (lib.mkIf (device.gpu == "intel") { + boot.initrd.kernelModules = ["i915"]; + services.xserver.videoDrivers = ["modesetting"]; + + hardware.opengl.extraPackages = [ + pkgs.intel-compute-runtime + pkgs.intel-media-driver + pkgs.vaapiIntel + pkgs.vaapiVdpau + pkgs.libvdpau-va-gl + ]; + + environment.variables.VDPAU_DRIVER = "va_gl"; + }) + (lib.mkIf (device.gpu == "nvidia") { + services.xserver.videoDrivers = ["nvidia"]; + hardware.nvidia = { + modesetting.enable = true; + powerManagement.enable = false; + powerManagement.finegrained = false; + open = false; + nvidiaSettings = true; + package = config.boot.kernelPackages.nvidiaPackages.beta; + }; + boot.initrd.kernelModules = [ + "nvidia" + "nvidia_modeset" + "nvidia_uvm" + "nvidia_drm" + ]; + boot.extraModprobeConfig = '' + options modeset=1 fbdev=1 + ''; + }) + ]); +} diff --git a/modules/hardware/network.nix b/modules/hardware/network.nix new file mode 100644 index 0000000..8c54349 --- /dev/null +++ b/modules/hardware/network.nix @@ -0,0 +1,27 @@ +{ + config, + options, + lib, + ... +}: let + networkConfig = config.modules.hardware.network; + device = config.modules.device; +in { + options.modules.hardware.network = { + enable = lib.mkOption { + type = lib.types.bool; + default = true; + }; + }; + + config = lib.mkIf (networkConfig.enable) { + networking = { + hostName = device.name; + hostId = builtins.substring 0 8 ( + builtins.hashString "md5" config.networking.hostName + ); + networkmanager.enable = true; + }; + user.extraGroups = ["networkmanager"]; + }; +} |