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}");
|
||||
#};
|
||||
};
|
||||
})]);
|
||||
})
|
||||
]);
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue