grub + nvidia (kinda)

This commit is contained in:
nx2
2024-04-05 14:48:12 +02:00
parent 9d0835f94e
commit ecb83a4025
5 changed files with 219 additions and 124 deletions

View File

@@ -1,23 +1,20 @@
# Edit this configuration file to define what should be installed on { config, lib, pkgs, user, allowed, secrets, rice, nvidia, ... }:
# your system. Help is available in the configuration.nix(5) man page, on let
# https://search.nixos.org/options and in the NixOS manual (`nixos-help`). in
{ config, lib, pkgs, user, allowed, secrets, rice, ... }:
{ {
imports = imports = [
[ # Include the results of the hardware scan.
./system-modules/hardware-configuration.nix ./system-modules/hardware-configuration.nix
./system-modules/nvidia.nix # only does stuff if nvidia.enabled
./system-modules/users.nix ./system-modules/users.nix
./system-modules/sound.nix ./system-modules/sound.nix
./system-modules/ollama.nix
./system-modules/grub.nix ./system-modules/grub.nix
./system-modules/dm.nix ./system-modules/dm.nix
./system-modules/hsmw.nix ./system-modules/hsmw.nix
./system-modules/docker.nix
./system-modules/health_reminder.nix ./system-modules/health_reminder.nix
./system-modules/davmail.nix ./system-modules/davmail.nix
./system-modules/docker.nix ./system-modules/ollama.nix
]; ];
networking.hostName = "NxXPS"; networking.hostName = "NxXPS";
@@ -62,6 +59,9 @@
hardware.bluetooth.powerOnBoot = true; # hardware.bluetooth.powerOnBoot = true; #
services.blueman.enable = true; services.blueman.enable = true;
nixpkgs.config.allowUnfree = true;
# nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) allowed.unfree-packages;
# List packages installed in system profile. To search, run: # List packages installed in system profile. To search, run:
# $ nix search wget # $ nix search wget
@@ -81,6 +81,7 @@
direnv direnv
openssl openssl
blueman blueman
dmidecode
]; ];
fonts.packages = with pkgs; [ fonts.packages = with pkgs; [
@@ -90,7 +91,7 @@
] ++ [ ] ++ [
rice.font.base.package rice.font.base.package
rice.font.code.package rice.font.code.package
] ];
programs.gnupg.agent = { programs.gnupg.agent = {
enable = true; enable = true;
@@ -98,7 +99,8 @@
}; };
programs.hyprland = { # config is done with home-manager programs.hyprland = {
# config is done with home-manager
enable = true; enable = true;
xwayland.enable = true; xwayland.enable = true;
}; };

12
flake.lock generated
View File

@@ -23,11 +23,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1711668574, "lastModified": 1712168706,
"narHash": "sha256-u1dfs0ASQIEr1icTVrsKwg2xToIpn7ZXxW3RHfHxshg=", "narHash": "sha256-XP24tOobf6GGElMd0ux90FEBalUtw6NkBSVh/RlA6ik=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "219951b495fc2eac67b1456824cc1ec1fd2ee659", "rev": "1487bdea619e4a7a53a4590c475deabb5a9d1bfb",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -38,11 +38,11 @@
}, },
"nixpkgs-unstable": { "nixpkgs-unstable": {
"locked": { "locked": {
"lastModified": 1711703276, "lastModified": 1712163089,
"narHash": "sha256-iMUFArF0WCatKK6RzfUJknjem0H9m4KgorO/p3Dopkk=", "narHash": "sha256-Um+8kTIrC19vD4/lUCN9/cU9kcOsD1O1m+axJqQPyMM=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "d8fe5e6c92d0d190646fb9f1056741a229980089", "rev": "fd281bd6b7d3e32ddfa399853946f782553163b5",
"type": "github" "type": "github"
}, },
"original": { "original": {

View File

@@ -12,32 +12,50 @@
let let
system = "x86_64-linux"; system = "x86_64-linux";
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
user = "nx2";
pkgs-unstable = nixpkgs-unstable.legacyPackages.${system}; pkgs-unstable = nixpkgs-unstable.legacyPackages.${system};
user = "nx2";
nvidia = rec {
enable = true;
prime = true;
# unfree = if enable then [
unfree = [
"nvidia-x11"
"nvidia-settings"
"nvidia-persistenced"
"cudatoolkit"
"cudatoolkit-11.8.0"
"cudatoolkit-12.2.2"
];
# ] else [];
};
allowed = { allowed = {
unfree-packages = [ unfree-packages = [
"spotify" "spotify"
"cudatoolkit-12.2.2"
"discord" "discord"
"obsidian" "obsidian"
"zoom-us" "zoom-us"
"zoom" "zoom"
"vscode-extension-ms-vscode-remote-remote-ssh"
"vscode-extension-MS-python-vscode-pylance" "vscode-extension-MS-python-vscode-pylance"
]; ] ++ nvidia.unfree ;
inecure-packages = [ inecure-packages = [
"electron-25.9.0" "electron-25.9.0"
]; ];
}; };
secrets = import ./secrets/passwords-and-certificates.nix; secrets = import ./secrets/passwords-and-certificates.nix;
rice = { rice = {
transparency = "0.8"; transparency = "0.9";
colors = { colors = rec {
main-fg = "#ffffff"; main-fg = "#ffffff";
main-bg = "#000000"; main-bg = "#000000";
bubble-fg = "#ffffff"; bubble-fg = main-fg;
bubble-bg = "#222222"; bubble-bg = "#222222";
bubble-border = "#bbbbbb"; bubble-border = "#bbbbbb";
secondary-fg = "#ffffff"; secondary-fg = main-fg;
secondary-bg = "#222255"; secondary-bg = "#222255";
lines = "#bbbbbb"; lines = "#bbbbbb";
accent = "#ff00ff"; accent = "#ff00ff";
@@ -61,7 +79,7 @@
modules = [ modules = [
./configuration.nix ./configuration.nix
]; ];
specialArgs = {inherit user allowed secrets rice;}; specialArgs = { inherit user pkgs-unstable allowed secrets rice nvidia; };
}; };
}; };
@@ -69,7 +87,7 @@
nx2 = home-manager.lib.homeManagerConfiguration { nx2 = home-manager.lib.homeManagerConfiguration {
inherit pkgs; inherit pkgs;
modules = [ ./home.nix ]; modules = [ ./home.nix ];
extraSpecialArgs = {inherit system user allowed secrets pkgs-unstable rice;}; extraSpecialArgs = { inherit system user allowed secrets pkgs-unstable rice nvidia; };
}; };
}; };

View File

@@ -1,51 +1,54 @@
# Do not modify this file! It was generated by nixos-generate-config
# and may be overwritten by future invocations. Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, user, pkgs, modulesPath, ... }: { config, lib, user, pkgs, modulesPath, ... }:
{ {
imports = imports = [
[
(modulesPath + "/installer/scan/not-detected.nix") (modulesPath + "/installer/scan/not-detected.nix")
]; ];
boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "vmd" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ]; boot.initrd.availableKernelModules = [ "xhci_pci" "thunderbolt" "vmd" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];
boot.initrd.kernelModules = [ ]; # boot.initrd.kernelModules = [ ];
boot.kernelModules = [ "kvm-intel" ]; boot.kernelModules = [ "kvm-intel" ];
boot.extraModulePackages = [ ]; boot.extraModulePackages = [ ];
fileSystems."/" = fileSystems."/" = {
# { device = "/dev/disk/by-uuid/9770465e-6b0e-40ec-944a-953fe71cf47a";
{
device = "/dev/disk/by-label/nixos"; device = "/dev/disk/by-label/nixos";
fsType = "ext4"; fsType = "ext4";
}; };
fileSystems."/boot" = fileSystems."/boot" = {
{
device = "/dev/disk/by-label/EFI"; device = "/dev/disk/by-label/EFI";
fsType = "vfat"; fsType = "vfat";
}; };
fileSystems."/home/${user}/shared" = fileSystems."/home/${user}/shared" = {
{
device = "/dev/disk/by-label/shared"; device = "/dev/disk/by-label/shared";
fsType = "ntfs"; fsType = "ntfs";
}; };
swapDevices = [ swapDevices = [
{ { device = "/dev/disk/by-label/swap"; }
device = "/dev/disk/by-label/swap";
# size = 16 * 1024;
}
]; ];
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
# (the default) this is the recommended approach. When using systemd-networkd it's
# still possible to use this option, but it's recommended to use it in conjunction
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
networking.useDHCP = lib.mkDefault true; networking.useDHCP = lib.mkDefault true;
# networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
# from nixos-hardware
services.thermald.enable = lib.mkDefault true;
boot.extraModprobeConfig = ''
options iwlwifi 11n_disable=8
'';
boot.initrd.kernelModules = [ "i915" ];
environment.variables = {
VDPAU_DRIVER = lib.mkIf config.hardware.opengl.enable (lib.mkDefault "va_gl");
};
hardware.opengl.extraPackages = with pkgs; [
(if (lib.versionOlder (lib.versions.majorMinor lib.version) "23.11") then vaapiIntel else intel-vaapi-driver)
libvdpau-va-gl
intel-media-driver
];
} }

72
system-modules/nvidia.nix Normal file
View File

@@ -0,0 +1,72 @@
{ config, pkgs, pkgs-unstable, lib, nvidia, ... }:
let
in
{
config = lib.mkIf nvidia.enable {
environment.systemPackages = with pkgs; [
lshw
nvtop
glxinfo
(pkgs.writeShellScriptBin "nvidia-offload" ''
export __NV_PRIME_RENDER_OFFLOAD=1
export __NV_PRIME_RENDER_OFFLOAD_PROVIDER=NVIDIA-G0
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export __VK_LAYER_NV_optimus=NVIDIA_only
exec "$@"
'')
] ++ [
# pkgs-unstable.nvtopPackages.intel
# pkgs-unstable.nvtopPackages.nvidia
];
# Load nvidia driver for Xorg and Wayland
services.xserver.videoDrivers = [ "nvidia" ];
hardware = {
nvidia = {
prime = lib.mkIf nvidia.prime {
intelBusId = "PCI:0:2:0";
nvidiaBusId = "PCI:1:0:0";
offload = {
enable = true;
enableOffloadCmd = true;
};
};
modesetting.enable = true;
# Modesetting is required.
# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
# Enable this if you have graphical corruption issues or application crashes after waking
# up from sleep. This fixes it by saving the entire VRAM memory to /tmp/ instead
# of just the bare essentials.
powerManagement.enable = true;
# Fine-grained power management. Turns off GPU when not in use.
# Experimental and only works on modern Nvidia GPUs (Turing or newer).
powerManagement.finegrained = true;
# Use the NVidia open source kernel module (not to be confused with the
# independent third-party "nouveau" open source driver).
# Support is limited to the Turing and later architectures. Full list of
# supported GPUs is at:
# https://github.com/NVIDIA/open-gpu-kernel-modules#compatible-gpus
# Only available from driver 515.43.04+
# Currently alpha-quality/buggy, so false is currently the recommended setting.
open = false;
# Enable the Nvidia settings menu,
# accessible via `nvidia-settings`.
nvidiaSettings = true;
# Optionally, you may need to select the appropriate driver version for your specific GPU.
package = config.boot.kernelPackages.nvidiaPackages.stable;
};
opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
};
};
};
}