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,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