[nvidia] Move into module

This commit is contained in:
Tibo De Peuter 2023-10-20 22:28:37 +02:00
parent 00e003214f
commit b57c8c329a
9 changed files with 87 additions and 48 deletions

View file

@ -34,10 +34,12 @@
utils.lib.mkFlake { utils.lib.mkFlake {
inherit self inputs; inherit self inputs;
channelsConfig = { channelsConfig.allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) [
allowUnfree.allowUnfreePredicate = pkg: builtins.elem (utils.lib.getName pkg) [ "nvidia-x11"
"nvidia-settings"
"corefonts"
"vista-fonts"
]; ];
};
sharedOverlays = [ sharedOverlays = [
(import ./overlays/letter) (import ./overlays/letter)
@ -51,6 +53,10 @@
specialArgs = { specialArgs = {
pkgs-unstable = import nixpkgs-unstable { pkgs-unstable = import nixpkgs-unstable {
inherit system; inherit system;
config.allowUnfreePredicate = pkg: builtins.elem (nixpkgs.lib.getName pkg) [
"obsidian"
"spotify"
];
}; };
}; };

View file

@ -31,6 +31,7 @@
"/nix" = { "/nix" = {
device = "/dev/disk/by-label/NIX-STORE"; device = "/dev/disk/by-label/NIX-STORE";
fsType = "ext4"; fsType = "ext4";
options = [ "noatime" ];
}; };
"/mnt/Nextcloud" = { "/mnt/Nextcloud" = {

View file

@ -3,13 +3,15 @@
{ {
imports = [ imports = [
./hardware-configuration.nix ./hardware-configuration.nix
../../modules-old/hardware/nvidia.nix
../../modules-old ../../modules-old
]; ];
sisyphus = { sisyphus = {
users.tdpeuter.enable = true; users.tdpeuter.enable = true;
hardware.nvidia.enable = true;
hardware.nvidia.model = "T2000";
programs = { programs = {
home-manager.enable = true; home-manager.enable = true;
sops.enable = true; sops.enable = true;

View file

@ -1,15 +1,26 @@
{ inputs, lib, config, pkgs, ... }: { inputs, lib, config, pkgs, ... }:
{ {
# Nix Flakes nix = {
nix.package = pkgs.nixFlakes; # Allow Nix Flakes
nix.extraOptions = '' # Keep derivations so shells don't break (direnv)
# If the disk has less than 100MiB, free up to 2GiB by garbage-collecting.
extraOptions = ''
experimental-features = nix-command flakes experimental-features = nix-command flakes
keep-outputs = true keep-outputs = true
keep-derivations = true keep-derivations = true
min-free = ${toString (100 * 1024 * 1024)}
max-free = ${toString (2048 * 1024 * 1024)}
''; '';
# Scheduled garbage-collect
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 30d";
};
package = pkgs.nixFlakes;
};
# Select internationalisation properties.
i18n.defaultLocale = "en_GB.UTF-8"; i18n.defaultLocale = "en_GB.UTF-8";
console = { console = {
# font = "Lat2-Terminus16"; # font = "Lat2-Terminus16";

View file

@ -1,33 +0,0 @@
{ inputs, lib, config, pkgs, ... }:
let
nvidia-offload = 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 "$@"
'';
in
{
nixpkgs.config.allowUnfree = true;
services.xserver.videoDrivers = [ "nvidia" ];
hardware = {
opengl.enable = true;
nvidia = {
open = true;
package = config.boot.kernelPackages.nvidiaPackages.stable;
modesetting.enable = true;
};
};
# Offloading
# environment.systemPackages = [ nvidia-offload ];
# hardware.nvidia.prime = {
# offload.enable = true;
# intelBusId = "PCI::00:02:0";
# nvidiaBusId = "PCI:01:00:0";
# };
}

View file

@ -1,5 +1,6 @@
{ {
imports = [ imports = [
./hardware
./programs ./programs
./services ./services
./virtualisation ./virtualisation

View file

@ -0,0 +1,5 @@
{
imports = [
./nvidia
];
}

View file

@ -0,0 +1,46 @@
{ config, lib, pkgs, ... }:
let
cfg = config.sisyphus.hardware.nvidia;
nvidia-offload = 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 "$@"
'';
in {
options.sisyphus.hardware.nvidia = {
enable = lib.mkEnableOption "NVIDIA GPU support";
model = lib.mkOption {
type = lib.types.enum [ "" "T2000" "RTX 2060" ];
default = "";
example = "T2000";
description = lib.mdDoc "The model of NVIDIA GPU card";
};
};
config = lib.mkIf cfg.enable {
services.xserver.videoDrivers = [ "nvidia" ];
hardware = {
opengl.enable = true;
nvidia = {
open = true;
package = config.boot.kernelPackages.nvidiaPackages.stable;
modesetting.enable = true;
prime = lib.mkIf (cfg.model == "T2000") {
offload.enable = true;
intelBusId = "PCI::00:02:0";
nvidiaBusId = "PCI:01:00:0";
};
};
};
environment.systemPackages = lib.mkIf (cfg.model != "") [
nvidia-offload
];
};
}

View file

@ -60,10 +60,8 @@ in {
libreoffice-fresh libreoffice-fresh
nextcloud-client nextcloud-client
nsxiv # Lightweight image viewer nsxiv # Lightweight image viewer
obsidian
oh-my-zsh oh-my-zsh
qalculate-gtk # Calculator qalculate-gtk # Calculator
spotify
tea # Gitea CLI tea # Gitea CLI
unzip unzip
vifm # File manager vifm # File manager
@ -74,6 +72,8 @@ in {
zsh-syntax-highlighting zsh-syntax-highlighting
]) ++ (with pkgs-unstable; [ ]) ++ (with pkgs-unstable; [
mpv mpv
obsidian
spotify
]) ++ (with pkgs.vimPlugins; [ ]) ++ (with pkgs.vimPlugins; [
statix statix
vim-plug vim-plug