mirror of
https://github.com/aviallon/nixos-lib.git
synced 2026-04-05 17:27:50 +00:00
fix(lint): nixfmt the whole tree
This commit is contained in:
parent
643b136863
commit
bf219a30c2
69 changed files with 2605 additions and 1726 deletions
|
|
@ -1,11 +1,17 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.aviallon.hardware.amd;
|
||||
devCfg = config.aviallon.developer;
|
||||
generalCfg = config.aviallon.general;
|
||||
in {
|
||||
config = mkIf (cfg.enable && cfg.kernelDriver == "amdgpu") {
|
||||
in
|
||||
{
|
||||
config = mkIf (cfg.enable && cfg.kernelDriver == "amdgpu") {
|
||||
boot.initrd.kernelModules = [ "amdgpu" ];
|
||||
|
||||
hardware.amdgpu.legacySupport.enable = true;
|
||||
|
|
@ -22,9 +28,7 @@ in {
|
|||
SUBSYSTEM=="pci", DRIVER=="amdgpu", ATTR{power_dpm_force_performance_level}="auto"
|
||||
'';
|
||||
|
||||
services.xserver.videoDrivers =
|
||||
optional cfg.useProprietary "amdgpu-pro"
|
||||
++ [ "modesetting" ];
|
||||
services.xserver.videoDrivers = optional cfg.useProprietary "amdgpu-pro" ++ [ "modesetting" ];
|
||||
|
||||
hardware.amdgpu.opencl.enable = true;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,16 +1,25 @@
|
|||
{config, pkgs, lib, ...}:
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
generalCfg = config.aviallon.general;
|
||||
enableZenpower = (! isNull (builtins.match "znver[1-3]" generalCfg.cpu.arch)) && (versionOlder kernelVersion "6.13");
|
||||
enableZenpower =
|
||||
(!isNull (builtins.match "znver[1-3]" generalCfg.cpu.arch)) && (versionOlder kernelVersion "6.13");
|
||||
kernelVersion = getVersion config.boot.kernelPackages.kernel;
|
||||
in {
|
||||
in
|
||||
{
|
||||
config = mkIf (generalCfg.cpu.vendor == "amd") {
|
||||
boot.kernel.sysctl = {
|
||||
|
||||
# Why: https://www.phoronix.com/news/Ryzen-Segv-Response
|
||||
# Workaround: https://forums.gentoo.org/viewtopic-p-2605135.html#2605135
|
||||
"kernel.randomize_va_space" = mkIf (generalCfg.cpu.arch == "znver1" ) (warn "Disable Adress Space Layout Randomization on Ryzen 1 CPU" 0);
|
||||
"kernel.randomize_va_space" = mkIf (generalCfg.cpu.arch == "znver1") (
|
||||
warn "Disable Adress Space Layout Randomization on Ryzen 1 CPU" 0
|
||||
);
|
||||
};
|
||||
|
||||
aviallon.boot.cmdline = {
|
||||
|
|
@ -20,26 +29,23 @@ in {
|
|||
else if versionAtLeast kernelVersion "6.3" then
|
||||
"active"
|
||||
else
|
||||
"passive"
|
||||
;
|
||||
} // optionalAttrs (generalCfg.cpu.arch == "znver2") {
|
||||
"passive";
|
||||
}
|
||||
// optionalAttrs (generalCfg.cpu.arch == "znver2") {
|
||||
# Required for Zen 2
|
||||
"amd_pstate.shared_memory" = 1;
|
||||
};
|
||||
|
||||
aviallon.boot.patches = mkIf config.aviallon.optimizations.enable {};
|
||||
aviallon.boot.patches = mkIf config.aviallon.optimizations.enable { };
|
||||
|
||||
boot.extraModulePackages = with config.boot.kernelPackages; []
|
||||
++ optional enableZenpower (info "enable zenpower for Ryzen [1-3] CPU" zenpower)
|
||||
;
|
||||
boot.extraModulePackages =
|
||||
with config.boot.kernelPackages;
|
||||
[ ] ++ optional enableZenpower (info "enable zenpower for Ryzen [1-3] CPU" zenpower);
|
||||
|
||||
boot.kernelModules = []
|
||||
++ optional enableZenpower "zenpower"
|
||||
;
|
||||
boot.kernelModules = [ ] ++ optional enableZenpower "zenpower";
|
||||
|
||||
boot.blacklistedKernelModules = []
|
||||
++ optional enableZenpower "k10-temp" # Superseded by zenpower
|
||||
boot.blacklistedKernelModules =
|
||||
[ ] ++ optional enableZenpower "k10-temp" # Superseded by zenpower
|
||||
;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,15 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.aviallon.hardware.amd;
|
||||
generalCfg = config.aviallon.general;
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.aviallon.hardware.amd = {
|
||||
enable = mkEnableOption "AMD gpus";
|
||||
useProprietary = mkEnableOption "Use proprietary AMDGPU Pro";
|
||||
|
|
@ -14,7 +20,12 @@ in {
|
|||
};
|
||||
kernelDriver = mkOption {
|
||||
description = "wether to use radeon or amdgpu kernel driver";
|
||||
type = with types; enum [ "radeon" "amdgpu" ];
|
||||
type =
|
||||
with types;
|
||||
enum [
|
||||
"radeon"
|
||||
"amdgpu"
|
||||
];
|
||||
default = "amdgpu";
|
||||
};
|
||||
};
|
||||
|
|
@ -25,7 +36,7 @@ in {
|
|||
./radeon.nix
|
||||
./rocm.nix
|
||||
];
|
||||
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
|
||||
aviallon.programs.nvtop = {
|
||||
|
|
|
|||
|
|
@ -1,10 +1,16 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.aviallon.hardware.amd;
|
||||
devCfg = config.aviallon.developer;
|
||||
generalCfg = config.aviallon.general;
|
||||
in {
|
||||
in
|
||||
{
|
||||
config = mkIf (cfg.enable && cfg.kernelDriver == "radeon") {
|
||||
boot.initrd.kernelModules = [ "radeon" ];
|
||||
|
||||
|
|
@ -12,13 +18,13 @@ in {
|
|||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
|
||||
|
||||
];
|
||||
|
||||
services.xserver.videoDrivers = [
|
||||
"modesetting"
|
||||
];
|
||||
|
||||
environment.variables = {};
|
||||
environment.variables = { };
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.aviallon.hardware.amd;
|
||||
|
|
@ -22,25 +27,31 @@ let
|
|||
gxf1036 = "10.3.0";
|
||||
};
|
||||
|
||||
/*autoDetectGPU = pkgs: pkgs.callPackage (
|
||||
{ runCommandLocal,
|
||||
gnugrep,
|
||||
rocmPackages,
|
||||
}: runCommandLocal "hsa-version" { nativeBuildInputs = [ gnugrep rocmPackages.rocminfo ]; } ''
|
||||
set +e
|
||||
mkdir -p $out/
|
||||
echo "Computing HSA version" &>/dev/stderr
|
||||
ls -l /dev/kfd
|
||||
rocminfo &>/dev/stderr
|
||||
rocminfo | grep --only-matching --perl-regexp '^\s*Name:\s+\Kgfx[0-9a-f]+' | tee $out/output
|
||||
''
|
||||
) { };*/
|
||||
/*
|
||||
autoDetectGPU = pkgs: pkgs.callPackage (
|
||||
{ runCommandLocal,
|
||||
gnugrep,
|
||||
rocmPackages,
|
||||
}: runCommandLocal "hsa-version" { nativeBuildInputs = [ gnugrep rocmPackages.rocminfo ]; } ''
|
||||
set +e
|
||||
mkdir -p $out/
|
||||
echo "Computing HSA version" &>/dev/stderr
|
||||
ls -l /dev/kfd
|
||||
rocminfo &>/dev/stderr
|
||||
rocminfo | grep --only-matching --perl-regexp '^\s*Name:\s+\Kgfx[0-9a-f]+' | tee $out/output
|
||||
''
|
||||
) { };
|
||||
*/
|
||||
|
||||
gfxToCompatible = gfxISA: if (hasAttr gfxISA gfxToCompatibleMap) then (getAttr gfxISA gfxToCompatibleMap) else "";
|
||||
in {
|
||||
gfxToCompatible =
|
||||
gfxISA: if (hasAttr gfxISA gfxToCompatibleMap) then (getAttr gfxISA gfxToCompatibleMap) else "";
|
||||
in
|
||||
{
|
||||
|
||||
options.aviallon.hardware.amd.rocm = {
|
||||
enable = (mkEnableOption "ROCm configuration") // { default = true; };
|
||||
enable = (mkEnableOption "ROCm configuration") // {
|
||||
default = true;
|
||||
};
|
||||
gfxISA = mkOption {
|
||||
description = "What is the GFX ISA of your system. Leave blank if you have several GPUs of incompatible ISAs";
|
||||
default = "";
|
||||
|
|
@ -49,47 +60,55 @@ in {
|
|||
};
|
||||
gpuTargets = mkOption {
|
||||
description = "Override supported GPU ISAs in some ROCm packages.";
|
||||
default = [ "803"
|
||||
"900"
|
||||
"906:xnack-"
|
||||
"908:xnack-"
|
||||
"90a:xnack+" "90a:xnack-"
|
||||
"940"
|
||||
"941"
|
||||
"942"
|
||||
"1010"
|
||||
"1012"
|
||||
"1030"
|
||||
"1031"
|
||||
"1100"
|
||||
"1101"
|
||||
"1102" ];
|
||||
example = [ "900" "1031" ];
|
||||
default = [
|
||||
"803"
|
||||
"900"
|
||||
"906:xnack-"
|
||||
"908:xnack-"
|
||||
"90a:xnack+"
|
||||
"90a:xnack-"
|
||||
"940"
|
||||
"941"
|
||||
"942"
|
||||
"1010"
|
||||
"1012"
|
||||
"1030"
|
||||
"1031"
|
||||
"1100"
|
||||
"1101"
|
||||
"1102"
|
||||
];
|
||||
example = [
|
||||
"900"
|
||||
"1031"
|
||||
];
|
||||
type = with types; nullOr (listOf str);
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf (cfg.enable && localCfg.enable) {
|
||||
environment.systemPackages = with pkgs;
|
||||
config = mkIf (cfg.enable && localCfg.enable) {
|
||||
environment.systemPackages =
|
||||
with pkgs;
|
||||
[
|
||||
rocmPackages.rocm-smi
|
||||
#rocmPackages.meta.rocm-ml-libraries
|
||||
#rocmPackages.meta.rocm-hip-runtime
|
||||
|
||||
#pkgs.autoDetectGPU
|
||||
] ++ optionals devCfg.enable [
|
||||
rocmPackages.rocminfo
|
||||
]
|
||||
;
|
||||
++ optionals devCfg.enable [
|
||||
rocmPackages.rocminfo
|
||||
];
|
||||
|
||||
#systemd.tmpfiles.rules = [
|
||||
# "L+ /opt/rocm/hip - - - - ${pkgs.rocmPackages.meta.rocm-hip-runtime}"
|
||||
#"L+ /tmp/hsa-version - - - - ${pkgs.autoDetectGPU}"
|
||||
#"L+ /tmp/hsa-version - - - - ${pkgs.autoDetectGPU}"
|
||||
#];
|
||||
|
||||
environment.variables = {
|
||||
ROC_ENABLE_PRE_VEGA = "1"; # Enable OpenCL with Polaris GPUs
|
||||
} // (mkIf (gfxToCompatible cfg.rocm.gfxISA != "") {
|
||||
ROC_ENABLE_PRE_VEGA = "1"; # Enable OpenCL with Polaris GPUs
|
||||
}
|
||||
// (mkIf (gfxToCompatible cfg.rocm.gfxISA != "") {
|
||||
HSA_OVERRIDE_GFX_VERSION = gfxToCompatible cfg.rocm.gfxISA;
|
||||
});
|
||||
|
||||
|
|
@ -101,14 +120,19 @@ in {
|
|||
];
|
||||
|
||||
nix.settings.substituters = [ "https://nixos-rocm.cachix.org" ];
|
||||
nix.settings.trusted-public-keys = [ "nixos-rocm.cachix.org-1:VEpsf7pRIijjd8csKjFNBGzkBqOmw8H9PRmgAq14LnE=" ];
|
||||
nix.settings.trusted-public-keys = [
|
||||
"nixos-rocm.cachix.org-1:VEpsf7pRIijjd8csKjFNBGzkBqOmw8H9PRmgAq14LnE="
|
||||
];
|
||||
|
||||
nixpkgs.config.rocmSupport = true;
|
||||
|
||||
nixpkgs.overlays = mkIf (! isNull localCfg.gpuTargets) (mkBefore [(final: prev: {
|
||||
nixpkgs.overlays = mkIf (!isNull localCfg.gpuTargets) (mkBefore [
|
||||
(final: prev: {
|
||||
#rocmPackages_5 = final.rocmPackages;
|
||||
rocmPackages = prev.rocmPackages // {
|
||||
clr = prev.rocmPackages.clr.override { localGpuTargets = lib.forEach localCfg.gpuTargets (target: "gfx${target}"); };
|
||||
clr = prev.rocmPackages.clr.override {
|
||||
localGpuTargets = lib.forEach localCfg.gpuTargets (target: "gfx${target}");
|
||||
};
|
||||
rocdbgapi = prev.rocmPackages.rocdbgapi.override { buildDocs = false; };
|
||||
# (oldAttrs: {
|
||||
# passthru = oldAttrs.passthru // {
|
||||
|
|
@ -122,6 +146,7 @@ in {
|
|||
# gpuTargets = lib.forEach localCfg.gpuTargets (target: "gfx${target}");
|
||||
#};
|
||||
};
|
||||
})]);
|
||||
})
|
||||
]);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.aviallon.hardware;
|
||||
|
|
@ -6,7 +11,7 @@ let
|
|||
generalCfg = config.aviallon.general;
|
||||
in
|
||||
{
|
||||
options.aviallon.hardware = { };
|
||||
options.aviallon.hardware = { };
|
||||
|
||||
imports = [
|
||||
./amd
|
||||
|
|
@ -15,6 +20,6 @@ in
|
|||
./mesa.nix
|
||||
];
|
||||
|
||||
config = {};
|
||||
config = { };
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,15 @@
|
|||
{config, pkgs, lib, ...}:
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
generalCfg = config.aviallon.general;
|
||||
throttledService = "throttled";
|
||||
in {
|
||||
in
|
||||
{
|
||||
config = mkIf (generalCfg.cpu.vendor == "intel") {
|
||||
aviallon.boot.cmdline = {
|
||||
"intel_pstate" = "passive";
|
||||
|
|
|
|||
|
|
@ -1,4 +1,9 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.aviallon.hardware.intel;
|
||||
|
|
@ -15,17 +20,19 @@ in
|
|||
imports = [
|
||||
./cpu.nix
|
||||
];
|
||||
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
aviallon.programs.nvtop = {
|
||||
enable = true;
|
||||
backend = [ "intel" ];
|
||||
};
|
||||
|
||||
|
||||
boot.initrd.kernelModules = [ "i915" ];
|
||||
hardware.graphics = {
|
||||
enable = true;
|
||||
extraPackages = with pkgs; []
|
||||
extraPackages =
|
||||
with pkgs;
|
||||
[ ]
|
||||
++ [
|
||||
vaapiVdpau
|
||||
libvdpau-va-gl
|
||||
|
|
@ -38,24 +45,25 @@ in
|
|||
;
|
||||
};
|
||||
|
||||
aviallon.boot.cmdline = {}
|
||||
// optionalAttrs generalCfg.unsafeOptimizations {
|
||||
"i915.mitigations" = "off";
|
||||
"i915.enable_fbc" = 1;
|
||||
}
|
||||
// optionalAttrs laptopCfg.enable {
|
||||
"i915.enable_fbc" = 1;
|
||||
"i915.enable_dc" = 4;
|
||||
}
|
||||
// optionalAttrs (generalCfg.unsafeOptimizations && laptopCfg.enable) {
|
||||
"i915.enable_psr" = 1;
|
||||
}
|
||||
// optionalAttrs devCfg.enable {
|
||||
"i915.enable_gvt" = 1;
|
||||
}
|
||||
// {
|
||||
"i915.fastboot" = 1;
|
||||
};
|
||||
aviallon.boot.cmdline =
|
||||
{ }
|
||||
// optionalAttrs generalCfg.unsafeOptimizations {
|
||||
"i915.mitigations" = "off";
|
||||
"i915.enable_fbc" = 1;
|
||||
}
|
||||
// optionalAttrs laptopCfg.enable {
|
||||
"i915.enable_fbc" = 1;
|
||||
"i915.enable_dc" = 4;
|
||||
}
|
||||
// optionalAttrs (generalCfg.unsafeOptimizations && laptopCfg.enable) {
|
||||
"i915.enable_psr" = 1;
|
||||
}
|
||||
// optionalAttrs devCfg.enable {
|
||||
"i915.enable_gvt" = 1;
|
||||
}
|
||||
// {
|
||||
"i915.fastboot" = 1;
|
||||
};
|
||||
aviallon.hardware.mesa.enable = mkDefault true;
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,10 @@
|
|||
{ config, pkgs, lib, options, ... }:
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
options,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.aviallon.hardware.mesa;
|
||||
|
|
@ -7,13 +13,18 @@ let
|
|||
optimizationsCfg = config.aviallon.optimizations;
|
||||
optimizePkg = optimizationsCfg.optimizePkg;
|
||||
packageWithDefaults = types.package // {
|
||||
merge = loc: defs:
|
||||
let res = mergeDefaultOption loc defs;
|
||||
in if builtins.isPath res || (builtins.isString res && ! builtins.hasContext res)
|
||||
then toDerivation res
|
||||
else res;
|
||||
merge =
|
||||
loc: defs:
|
||||
let
|
||||
res = mergeDefaultOption loc defs;
|
||||
in
|
||||
if builtins.isPath res || (builtins.isString res && !builtins.hasContext res) then
|
||||
toDerivation res
|
||||
else
|
||||
res;
|
||||
};
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.aviallon.hardware.mesa = {
|
||||
enable = mkOption {
|
||||
default = false;
|
||||
|
|
@ -50,7 +61,7 @@ in {
|
|||
type = packageWithDefaults;
|
||||
default = cfg.package;
|
||||
};
|
||||
|
||||
|
||||
internal.package32 = mkOption {
|
||||
internal = true;
|
||||
type = packageWithDefaults;
|
||||
|
|
@ -65,10 +76,8 @@ in {
|
|||
aviallon.hardware.mesa.package32 = mkIf cfg.unstable pkgs.unstable.driversi686Linux.mesa;
|
||||
|
||||
aviallon.hardware.mesa.internal = mkIf cfg.optimized {
|
||||
package = mkDefault (
|
||||
optimizePkg { lto = false; } cfg.package);
|
||||
package32 = mkDefault (
|
||||
optimizePkg { lto = false; } cfg.package32);
|
||||
package = mkDefault (optimizePkg { lto = false; } cfg.package);
|
||||
package32 = mkDefault (optimizePkg { lto = false; } cfg.package32);
|
||||
};
|
||||
|
||||
hardware.graphics = {
|
||||
|
|
|
|||
|
|
@ -1,13 +1,22 @@
|
|||
{config, pkgs, lib, ...}:
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.aviallon.hardware.nvidia;
|
||||
in {
|
||||
in
|
||||
{
|
||||
|
||||
imports = [
|
||||
./proprietary.nix
|
||||
./opensource.nix
|
||||
( mkRenamedOptionModule [ "aviallon" "hardware" "nvidia" "saveAllVram" ] [ "aviallon" "hardware" "nvidia" "proprietary" "saveAllVram" ] )
|
||||
(mkRenamedOptionModule
|
||||
[ "aviallon" "hardware" "nvidia" "saveAllVram" ]
|
||||
[ "aviallon" "hardware" "nvidia" "proprietary" "saveAllVram" ]
|
||||
)
|
||||
];
|
||||
|
||||
options.aviallon.hardware.nvidia = {
|
||||
|
|
@ -16,7 +25,13 @@ in {
|
|||
default = (cfg.variant == "proprietary");
|
||||
};
|
||||
variant = mkOption {
|
||||
type = with types; enum [ "proprietary" "open" "nouveau" ];
|
||||
type =
|
||||
with types;
|
||||
enum [
|
||||
"proprietary"
|
||||
"open"
|
||||
"nouveau"
|
||||
];
|
||||
description = "What driver variant to use";
|
||||
default = "proprietary";
|
||||
example = "nouveau";
|
||||
|
|
@ -28,7 +43,7 @@ in {
|
|||
enable = true;
|
||||
};
|
||||
|
||||
aviallon.hardware.nvidia.useProprietary = mkForce ( cfg.variant == "proprietary" );
|
||||
aviallon.hardware.nvidia.useProprietary = mkForce (cfg.variant == "proprietary");
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,17 +1,33 @@
|
|||
{ config, pkgs, lib, ... }:
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.aviallon.hardware.nvidia;
|
||||
in {
|
||||
in
|
||||
{
|
||||
options.aviallon.hardware.nvidia.nouveau = {
|
||||
config = mkOption {
|
||||
description = "nouveau boot config";
|
||||
type = with types; attrsOf (nullOr (oneOf [ int str bool ]));
|
||||
example = { NvBoost = 1; };
|
||||
default = {};
|
||||
type =
|
||||
with types;
|
||||
attrsOf (
|
||||
nullOr (oneOf [
|
||||
int
|
||||
str
|
||||
bool
|
||||
])
|
||||
);
|
||||
example = {
|
||||
NvBoost = 1;
|
||||
};
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
config = mkIf (cfg.enable && cfg.variant == "nouveau") {
|
||||
boot.initrd.kernelModules = [ "nouveau" ];
|
||||
|
||||
|
|
@ -19,15 +35,14 @@ in {
|
|||
"nouveau.pstate" = 1;
|
||||
"nouveau.runpm" = 1;
|
||||
"nouveau.modeset" = 1;
|
||||
"nouveau.config" = let
|
||||
toValue = v:
|
||||
if isBool v
|
||||
then toString (if v then 1 else 0)
|
||||
else toString v;
|
||||
filteredConfig = filterAttrs (n: v: ! isNull v) cfg.nouveau.config;
|
||||
configList = mapAttrsToList (n: v: "${n}=${toValue v}") filteredConfig;
|
||||
configString = concatStringsSep "," configList;
|
||||
in trace "Nouveau config: ${configString}" configString;
|
||||
"nouveau.config" =
|
||||
let
|
||||
toValue = v: if isBool v then toString (if v then 1 else 0) else toString v;
|
||||
filteredConfig = filterAttrs (n: v: !isNull v) cfg.nouveau.config;
|
||||
configList = mapAttrsToList (n: v: "${n}=${toValue v}") filteredConfig;
|
||||
configString = concatStringsSep "," configList;
|
||||
in
|
||||
trace "Nouveau config: ${configString}" configString;
|
||||
};
|
||||
|
||||
aviallon.hardware.mesa.enable = mkDefault true;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,11 @@
|
|||
{ config, pkgs, lib, options, nixpkgs-unstable, ... }:
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
lib,
|
||||
options,
|
||||
nixpkgs-unstable,
|
||||
...
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
cfg = config.aviallon.hardware.nvidia;
|
||||
|
|
@ -9,9 +16,14 @@ let
|
|||
exec ${options.programs.xwayland.package.default}/bin/xwayland -eglstream "$@"
|
||||
'';
|
||||
|
||||
nvidiaUnstable = config.boot.kernelPackages.callPackage (nixpkgs-unstable + /pkgs/os-specific/linux/nvidia-x11/default.nix) {};
|
||||
cudaUnstable = pkgs: cudaVersion: pkgs.callPackages (nixpkgs-unstable + /pkgs/top-level/cuda-packages.nix) { inherit cudaVersion; };
|
||||
in {
|
||||
nvidiaUnstable = config.boot.kernelPackages.callPackage (
|
||||
nixpkgs-unstable + /pkgs/os-specific/linux/nvidia-x11/default.nix
|
||||
) { };
|
||||
cudaUnstable =
|
||||
pkgs: cudaVersion:
|
||||
pkgs.callPackages (nixpkgs-unstable + /pkgs/top-level/cuda-packages.nix) { inherit cudaVersion; };
|
||||
in
|
||||
{
|
||||
options = {
|
||||
aviallon.hardware.nvidia.proprietary = {
|
||||
gsync = mkEnableOption "Screen is GSYNC monitor";
|
||||
|
|
@ -39,7 +51,12 @@ in {
|
|||
saveAllVram = mkEnableOption "back up all VRAM in /var/tmp before going to sleep. May reduce artifacts after resuming";
|
||||
version = mkOption {
|
||||
description = "What Nvidia version variant to use";
|
||||
type = types.enum [ "production" "stable" "beta" "unstable_beta" ];
|
||||
type = types.enum [
|
||||
"production"
|
||||
"stable"
|
||||
"beta"
|
||||
"unstable_beta"
|
||||
];
|
||||
default = if generalCfg.unsafeOptimizations then "beta" else "stable";
|
||||
example = "unstable_beta";
|
||||
};
|
||||
|
|
@ -49,16 +66,21 @@ in {
|
|||
# Very useful resource.
|
||||
# https://forums.developer.nvidia.com/t/power-mizer-difference-between-powermizerdefault-and-powermizerlevel/46884/3
|
||||
example = [ "PerfLevelSrc=0x2222" ];
|
||||
default = [ "PowerMizerEnable=0x1" "OverrideMaxPerf=0x1" "PowerMizerDefault=0x3" "PowerMizerDefaultAC=0x3" ];
|
||||
default = [
|
||||
"PowerMizerEnable=0x1"
|
||||
"OverrideMaxPerf=0x1"
|
||||
"PowerMizerDefault=0x3"
|
||||
"PowerMizerDefaultAC=0x3"
|
||||
];
|
||||
type = with types; listOf str;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
config = mkIf (cfg.enable && cfg.variant == "proprietary") {
|
||||
|
||||
assertions = [];
|
||||
|
||||
assertions = [ ];
|
||||
|
||||
boot.initrd.kernelModules = [
|
||||
"nvidia"
|
||||
"nvidia_drm"
|
||||
|
|
@ -71,13 +93,15 @@ in {
|
|||
];
|
||||
|
||||
services.xserver.screenSection = ''
|
||||
Option "Coolbits" "${toString cfg.proprietary.coolbits}"
|
||||
Option "InbandStereoSignaling" "true"
|
||||
Option "Coolbits" "${toString cfg.proprietary.coolbits}"
|
||||
Option "InbandStereoSignaling" "true"
|
||||
'';
|
||||
|
||||
services.xserver.exportConfiguration = true;
|
||||
|
||||
services.xserver.displayManager.sddm.wayland.enable = mkIf (!config.aviallon.hardware.intel.enable) (mkDefault false); # Frequent issues with Nvidia GPUs
|
||||
services.xserver.displayManager.sddm.wayland.enable = mkIf (
|
||||
!config.aviallon.hardware.intel.enable
|
||||
) (mkDefault false); # Frequent issues with Nvidia GPUs
|
||||
|
||||
# Fix hybrid sleep with Nvidia GPU
|
||||
systemd.services.nvidia-suspend = {
|
||||
|
|
@ -85,18 +109,19 @@ in {
|
|||
before = [ "systemd-hybrid-sleep.service" ];
|
||||
};
|
||||
hardware.nvidia = {
|
||||
powerManagement = mkIf (config.hardware.nvidia.prime.offload.enable || cfg.proprietary.saveAllVram) {
|
||||
enable = true;
|
||||
finegrained = mkIf config.hardware.nvidia.prime.offload.enable true;
|
||||
};
|
||||
powerManagement =
|
||||
mkIf (config.hardware.nvidia.prime.offload.enable || cfg.proprietary.saveAllVram)
|
||||
{
|
||||
enable = true;
|
||||
finegrained = mkIf config.hardware.nvidia.prime.offload.enable true;
|
||||
};
|
||||
modesetting.enable = true;
|
||||
nvidiaSettings = true;
|
||||
package =
|
||||
if cfg.proprietary.version == "unstable_beta" then
|
||||
nvidiaUnstable.beta # Use bleeding edge version
|
||||
else
|
||||
config.boot.kernelPackages.nvidiaPackages.${cfg.proprietary.version}
|
||||
;
|
||||
config.boot.kernelPackages.nvidiaPackages.${cfg.proprietary.version};
|
||||
};
|
||||
|
||||
aviallon.hardware.nvidia.proprietary.EGLStream = mkDefault (
|
||||
|
|
@ -108,7 +133,8 @@ in {
|
|||
boot.extraModprobeConfig = ''
|
||||
options nvidia NVreg_RegistryDwords="${concatStringsSep ";" cfg.proprietary.registryDwords}"
|
||||
'';
|
||||
aviallon.boot.cmdline = {}
|
||||
aviallon.boot.cmdline =
|
||||
{ }
|
||||
// {
|
||||
"nvidia-drm.modeset" = 1;
|
||||
"nvidia-drm.fbdev" = 1;
|
||||
|
|
@ -120,14 +146,13 @@ in {
|
|||
"nvidia.NVreg_DynamicPowerManagement" = "0x02";
|
||||
"nvidia.NVreg_EnableS0ixPowerManagement" = 1;
|
||||
"nvidia.NVreg_TemporaryFilePath" = "/var/tmp";
|
||||
}
|
||||
;
|
||||
};
|
||||
|
||||
programs.xwayland.package = mkIf cfg.proprietary.EGLStream xwaylandEGLStream;
|
||||
aviallon.programs.allowUnfreeList = [
|
||||
"nvidia-x11"
|
||||
"nvidia-settings"
|
||||
|
||||
|
||||
"cudatoolkit"
|
||||
"cuda_cccl"
|
||||
"libnpp"
|
||||
|
|
@ -157,14 +182,13 @@ in {
|
|||
"__GL_YIELD" = "USLEEP"; # use usleep(0) instead of sched_yield() -> better performance in most cases
|
||||
"__GL_ALLOW_UNOFFICIAL_PROTOCOL" = "1"; # allow unofficial GLX protocol if also set in Xorg conf
|
||||
"__GL_VRR_ALLOWED" = "1"; # Try to enable G-SYNC VRR if screen AND app is compatible
|
||||
"__GL_SYNC_TO_VBLANK" = mkIf (!cfg.proprietary.vsync) (toValue cfg.proprietary.vsync);
|
||||
"__GL_SYNC_TO_VBLANK" = mkIf (!cfg.proprietary.vsync) (toValue cfg.proprietary.vsync);
|
||||
|
||||
# Causes Kwin to fail
|
||||
# https://github.com/ValveSoftware/gamescope/issues/526#issuecomment-1733739097
|
||||
# "__GL_THREADED_OPTIMIZATIONS" = toValue generalCfg.unsafeOptimizations;
|
||||
"KWIN_DRM_USE_EGL_STREAMS" = toValue cfg.proprietary.EGLStream; # Make KWin use EGL Streams if needed, because otherwise performance will be horrible.
|
||||
|
||||
|
||||
# Undocumented, fix for EGL not being found by Nvidia driver: https://github.com/NVIDIA/egl-wayland/issues/39#issuecomment-927288015
|
||||
__EGL_EXTERNAL_PLATFORM_CONFIG_DIRS = "/run/opengl-driver/share/egl/egl_external_platform.d";
|
||||
|
||||
|
|
@ -176,15 +200,19 @@ in {
|
|||
};
|
||||
|
||||
nix.settings.substituters = [ "https://cuda-maintainers.cachix.org" ];
|
||||
nix.settings.trusted-public-keys = [ "cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E=" ];
|
||||
nix.settings.trusted-public-keys = [
|
||||
"cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
|
||||
];
|
||||
|
||||
nixpkgs.overlays = []
|
||||
++ optional (cfg.proprietary.version == "unstable_beta") (final: prev: {
|
||||
cudaPackages_11 = final.unstable.cudaPackages_11;
|
||||
cudaPackages_12 = final.unstable.cudaPackages_12;
|
||||
cudaPackages = final.unstable.cudaPackages;
|
||||
nixpkgs.overlays =
|
||||
[ ]
|
||||
++ optional (cfg.proprietary.version == "unstable_beta") (
|
||||
final: prev: {
|
||||
cudaPackages_11 = final.unstable.cudaPackages_11;
|
||||
cudaPackages_12 = final.unstable.cudaPackages_12;
|
||||
cudaPackages = final.unstable.cudaPackages;
|
||||
|
||||
})
|
||||
;
|
||||
}
|
||||
);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue