so much organization

This commit is contained in:
mjallen18
2025-06-29 14:50:34 -05:00
parent ca155505be
commit 532c97cf00
58 changed files with 354 additions and 992 deletions

70
modules/amd/default.nix Executable file
View File

@@ -0,0 +1,70 @@
{
lib,
pkgs,
config,
...
}:
let
cfg = config.share.hardware.amd;
pkgsVersion = pkgs;#.unstable;
in
{
imports = [ ./options.nix ];
config = lib.mkIf cfg.enable {
boot = {
kernelModules = [ "nct6775" ];
kernelParams = [ (if cfg.enable then "amdgpu.ppfeaturemask=0xffffffff" else null) ];
};
# Configure programs
programs.corectrl = {
enable = cfg.corectrl.enable;
package = pkgsVersion.corectrl;
};
# Configure environment
environment = {
# Force radv
variables = {
AMD_VULKAN_ICD = "RADV";
STEAM_FORCE_DESKTOPUI_SCALING = "1.0";
GDK_SCALE = "1";
};
};
# Configure polkit
security.polkit = lib.mkIf cfg.corectrl.enablePolkit {
extraConfig = ''
polkit.addRule(function(action, subject) {
if ((action.id == "org.corectrl.helper.init" ||
action.id == "org.corectrl.helperkiller.init") &&
subject.local == true &&
subject.active == true &&
subject.isInGroup("${cfg.corectrl.polkitGroup}")) {
return polkit.Result.YES;
}
});
'';
};
# nixpkg is broken so need to manually define
systemd.services.lactd = lib.mkIf cfg.lact.enable {
description = "AMDGPU Control Daemon";
path = with pkgsVersion; [
bash
lact
];
script = ''
lact daemon
'';
wantedBy = [ "multi-user.target" ];
after = [ "multi-user.target" ];
};
# Configure environment
environment = {
systemPackages = with pkgsVersion; lib.mkIf cfg.lact.enable [ lact ];
};
};
}

27
modules/amd/options.nix Executable file
View File

@@ -0,0 +1,27 @@
{ lib, ... }:
with lib;
{
options.share.hardware.amd = {
enable = mkEnableOption "amd hardware config";
corectrl.enable = mkOption {
type = types.bool;
default = false;
};
corectrl.enablePolkit = mkOption {
type = types.bool;
default = false;
};
corectrl.polkitGroup = mkOption {
type = types.str;
default = "wheel";
};
lact.enable = mkOption {
type = types.bool;
default = false;
};
};
}