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

View file

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

View file

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

View file

@ -1,15 +1,26 @@
{ inputs, lib, config, pkgs, ... }:
{
# Nix Flakes
nix.package = pkgs.nixFlakes;
nix.extraOptions = ''
experimental-features = nix-command flakes
keep-outputs = true
keep-derivations = true
'';
nix = {
# Allow Nix Flakes
# 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
keep-outputs = 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";
console = {
# 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 = [
./hardware
./programs
./services
./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
nextcloud-client
nsxiv # Lightweight image viewer
obsidian
oh-my-zsh
qalculate-gtk # Calculator
spotify
tea # Gitea CLI
unzip
vifm # File manager
@ -74,6 +72,8 @@ in {
zsh-syntax-highlighting
]) ++ (with pkgs-unstable; [
mpv
obsidian
spotify
]) ++ (with pkgs.vimPlugins; [
statix
vim-plug