some refactoring and modularizing locale

This commit is contained in:
cnst
2024-10-23 20:11:01 +02:00
parent 86046c6414
commit b7784f9b15
58 changed files with 256 additions and 165 deletions

View File

@@ -0,0 +1,20 @@
{
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.nixos.hardware.bluetooth;
in {
options = {
nixos.hardware.bluetooth.enable = mkEnableOption "Enables bluetooth";
};
config = mkIf cfg.enable {
hardware = {
bluetooth = {
enable = true;
powerOnBoot = false;
};
};
};
}

View File

@@ -0,0 +1,32 @@
{
# pkgs,
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.nixos.hardware.graphics.amd;
in {
options = {
nixos.hardware.graphics.amd.enable = mkEnableOption "Enables AMD graphics";
};
config = mkIf cfg.enable {
hardware = {
graphics = {
enable = true;
enable32Bit = true;
# extraPackages = with pkgs; [
# libva
# vaapiVdpau
# libvdpau-va-gl
# amdvlk
# vulkan-tools
# ];
# extraPackages32 = with pkgs.pkgsi686Linux; [
# vaapiVdpau
# libvdpau-va-gl
# ];
};
};
};
}

View File

@@ -0,0 +1,72 @@
{
pkgs,
config,
lib,
...
}: let
nvidia-offload = pkgs.writeShellScriptBin "nvidia-offload" ''
export LIBVA_DRIVER_NAME=nvidia
export GBM_BACKEND=nvidia-drm
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export __GL_VRR_ALLOWED=1
export XDG_SESSION_TYPE=wayland
export NVD_BACKEND=direct
export ELECTRON_OZONE_PLATFORM_HINT=auto
exec "$@"
'';
inherit (lib) types mkIf mkEnableOption mkOption;
cfg = config.nixos.hardware.graphics.nvidia;
in {
options = {
nixos.hardware.graphics.nvidia = {
enable = mkEnableOption "Enables NVidia graphics";
package = mkOption {
type = types.enum ["stable" "beta" "production" "latest"];
default = "stable";
description = "Choose between the stable, beta, latest, or production NVidia driver package";
};
};
};
config = mkIf cfg.enable {
environment.systemPackages = with pkgs; [
egl-wayland
];
hardware = {
graphics = {
enable = true;
enable32Bit = true;
extraPackages = with pkgs; [
nvidia-offload
libva
vaapiVdpau
libvdpau-va-gl
intel-media-driver
nvidia-vaapi-driver
vulkan-tools
];
extraPackages32 = with pkgs.pkgsi686Linux; [
vaapiVdpau
libvdpau-va-gl
];
};
nvidia = {
package =
if cfg.package == "beta"
then config.boot.kernelPackages.nvidiaPackages.beta
else if cfg.package == "latest"
then config.boot.kernelPackages.nvidiaPackages.latest
else if cfg.package == "production"
then config.boot.kernelPackages.nvidiaPackages.prodution
else config.boot.kernelPackages.nvidiaPackages.stable;
modesetting.enable = true;
powerManagement = {
enable = false;
finegrained = false;
};
open = true;
nvidiaSettings = true;
};
};
};
}

View File

@@ -0,0 +1,20 @@
{
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption;
cfg = config.nixos.hardware.logitech;
in {
options = {
nixos.hardware.logitech.enable = mkEnableOption "Enables logitech";
};
config = mkIf cfg.enable {
hardware = {
logitech.wireless = {
enable = true;
enableGraphical = true;
};
};
};
}

View File

@@ -0,0 +1,62 @@
{
config,
lib,
...
}: let
inherit (lib) mkIf mkEnableOption mkOption types;
cfg = config.nixos.hardware.network;
in {
options = {
nixos = {
hardware = {
network = {
enable = mkEnableOption "Enable the custom networking module";
hostName = mkOption {
type = types.str;
default = "default-hostname";
description = "Hostname for the nixos.";
};
interfaces = mkOption {
type = types.attrsOf (types.submodule {
options = {
allowedTCPPorts = mkOption {
type = types.listOf types.int;
default = [];
description = "List of allowed TCP ports for this interface.";
};
};
});
default = {};
description = "Network interface configurations.";
};
nm-applet = {
enable = mkEnableOption "Enables the nm-applet service.";
indicator = mkOption {
type = types.bool;
default = false;
description = "Enables the nm-applet indicator.";
};
};
};
};
};
};
config = mkIf cfg.enable {
networking = {
networkmanager.enable = true;
inherit (cfg) hostName;
nftables.enable = true;
firewall = {
enable = true;
inherit (cfg) interfaces;
};
};
programs.nm-applet = {
enable = cfg.nm-applet.enable;
indicator = cfg.nm-applet.indicator;
};
};
}