Athena-OS / athena-nix

Athena OS Nix configuration files focused on Cybersecurity. Learn, practice and enjoy with any hacking tool!
https://athenaos.org
MIT License
150 stars 17 forks source link

[QUESTION]: How can I install nvidia driver on Athena Nix #9

Open DDrozdzz-1066 opened 5 months ago

AkechiShiro commented 5 months ago

It is the same as installing the driver under NixOS, follow the instruction here : https://nixos.wiki/wiki/Nvidia

AkechiShiro commented 2 months ago

@D3vil0p3r TBC

DerDennisOP commented 2 months ago

I have a module laying around we can add this somewhere:

{ config, pkgs, lib, ... }: let
  datacenterEnabled = config.hardware.nvidia.datacenter.enable;
in {
  options = {
    hardware.nvidia.rtx = lib.mkEnableOption "Enable NVIDIA RTX support";
  };

  config = lib.mkIf config.hardware.nvidia.rtx {
    programs.atop.atopgpu.enable = true;
    services.xserver.videoDrivers = lib.optional (!datacenterEnabled) "nvidia";
    environment.systemPackages = with pkgs; [
      nvitop
      cudaPackages.cudnn
      cudatoolkit
    ];

    boot = {
      extraModulePackages = [ config.hardware.nvidia.package ];
      initrd.kernelModules = lib.optionals (!datacenterEnabled) [
        "nvidia"
        "nvidia_modeset"
        "nvidia_drm"
        "nvidia_uvm"
      ];
    };

    hardware = {
      graphics.enable = !datacenterEnabled;
      nvidia = {
        open = false;
        nvidiaPersistenced = true;
        prime.offload.enable = datacenterEnabled;
        powerManagement.enable = datacenterEnabled;
        powerManagement.finegrained = datacenterEnabled;
        package = let
          driver = config.boot.kernelPackages.nvidiaPackages;
        in
          if datacenterEnabled then driver.dc_535 else driver.beta;
      };
    };
  };
}
D3vil0p3r commented 2 months ago

It should be managed at install level. Athena installer has several ways to recon your GPU. I should check if the autogpu driver install was implemented or not

D3vil0p3r commented 2 months ago

@DerDennisOP can you implement Nvidia and AMDGpu modules in Athena Nix but by setting them as false? So the installer will switch them to true if one of those gpu is detected?

DerDennisOP commented 2 months ago

tbh I have no idea about the installer, but we can add some nvidia hardware module and turn it on when needed. Whatever you decide. I havn't had problems with amd gpus yet, since setting them up is as simple as that:

hardware.graphics = {
  enable = true;
  enable32Bit = true;
};
AkechiShiro commented 2 months ago

Is a module really needed, doesn't nixos-generate-config already detects hardware and generates proper configuration ? Also using : https://github.com/NixOS/nixos-hardware

DerDennisOP commented 2 months ago

Is a module really needed, doesn't nixos-generate-config already detects hardware and generates proper configuration ? Also using : https://github.com/NixOS/nixos-hardware

no thats not the case

AkechiShiro commented 2 months ago

Are you sure it's a good idea to introduce a new module ?

I can't help but wonder why all these are for : image

We won't be able to detect drivers breaking on platforms better than what is already in nixos-hardware especially on MacOS platforms.

I believe we shouldn't reinvent the wheel to use iGPU and dGPU but just my 2cent, I'm pretty sure most hardware quirks for specific platform needs to go upstream and should not be handled by the installer directly.

AkechiShiro commented 2 months ago

Btw here are the module you're looking to write I think : https://github.com/NixOS/nixos-hardware/blob/d830ad47cc992b4a46b342bbc79694cbd0e980b2/common/gpu/

AkechiShiro commented 2 months ago

IMHO, here is what we should try and auto detect, to import profiles for hardware quirks during install :

If you want to work on it let me know @DerDennisOP I maybe able to help

DerDennisOP commented 2 months ago

Is a module really needed, doesn't nixos-generate-config already detects hardware and generates proper configuration ? Also using : https://github.com/NixOS/nixos-hardware

no thats not the case

Are you sure you're familiar with Nix ?

I can't help but wonder why all these are for : image

We won't be able to detect drivers breaking on platforms better than what is already in nixos-hardware especially on MacOS platforms.

I believe we shouldn't reinvent the wheel to use iGPU and dGPU but just my 2cent, I'm pretty sure most hardware quirks for specific platform needs to go upstream and should not be handled by the installer directly.

we cant use nixos-hardware since it has servers and desktops that are common builds there wont be every user specific configuration there. we might be able to take a module from there. But since I'm not familiar with this I'm sure you can handle it alone better ;)

AkechiShiro commented 2 months ago

I still don't understand your comment, I'm sorry if I miss anything but profiles are specific to hardware platforms, common modules are only defined so options can be toggled on/off, see for instance these framework laptops profiles :

I don't see any Framework servers yet, if you happen to see any let me know

User configuration should be left to users, if they want to run bleeding edge Nvidia drivers, they could override the profile.

D3vil0p3r commented 2 months ago

Are you sure you're familiar with Nix ?

@AkechiShiro thank you for reviewing your comment. @DerDennisOP what is your proposal? The installer practically detects the GPU model implemented on the system and my idea was to switch to true Nvidia or AMD nix attributes.

DerDennisOP commented 2 months ago

@D3vil0p3r I would say adding a module enabling all the options needed options for Nvidia and AMD. After that we can just enable it by setting e.g. a "gpu" value to "nvidia" or "amd"

D3vil0p3r commented 2 months ago

@D3vil0p3r I would say adding a module enabling all the options needed options for Nvidia and AMD. After that we can just enable it by setting e.g. a "gpu" value to "nvidia" or "amd"

Yes. It can be also changed automatically by Aegis installer once implemented. Im trying to make cyber-toolnix as a module instead of a Rust program.