Skip to content

Feature/vgpu #21

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion system/configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
{
config,
pkgs,
lib,
...
}: {
imports = map (n: "${./modules}/${n}") (builtins.attrNames (builtins.readDir ./modules));
Expand Down Expand Up @@ -44,7 +45,7 @@

boot.supportedFilesystems = ["ntfs"];
boot.initrd.systemd.enable = true;
boot.kernelPackages = pkgs.linuxPackages_latest;
boot.kernelPackages = lib.mkDefault pkgs.linuxPackages_latest;

services.udisks2.enable = true;

Expand Down
24 changes: 20 additions & 4 deletions system/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion system/flake.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
# inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
inputs.nixpkgs-master.url = "github:nixos/nixpkgs/master";
inputs.disko.url = "github:nix-community/disko";
inputs.disko.inputs.nixpkgs.follows = "nixpkgs";
inputs.impermanence.url = "github:nix-community/impermanence";
inputs.sops-nix.url = "github:Mic92/sops-nix";
inputs.sops-nix.inputs.nixpkgs.follows = "nixpkgs";
inputs.nvidia-vgpu.url = "github:danielfullmer/nixos-nvidia-vgpu";

outputs = {
self,
Expand All @@ -14,6 +16,7 @@
disko,
impermanence,
sops-nix,
nvidia-vgpu,
}: let
#machinedir = ./machines
lib = nixpkgs.lib;
Expand All @@ -24,6 +27,7 @@
disko.nixosModules.disko
impermanence.nixosModules.impermanence
sops-nix.nixosModules.sops
nvidia-vgpu.nixosModules.nvidia-vgpu
{
options.booq.audio = lib.mkOption {
default = "pulseaudio";
Expand Down
2 changes: 1 addition & 1 deletion system/machines/leilasus/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
./services.nix
./users.nix
./cinnamon.nix
./gaming.nix
./amd.nix
];
booq.sops.enable = false;
booq.gaming.enable = true;
}
19 changes: 0 additions & 19 deletions system/machines/leilasus/gaming.nix

This file was deleted.

4 changes: 4 additions & 0 deletions system/machines/silvio-pc/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@
...
}: {
booq.audio = "pipewire";
booq.gaming.enable = true;

boot.kernelPackages = pkgs.linuxPackages_5_4;
# TODO: luks+yubikey+secureboot https://www.reddit.com/r/NixOS/comments/xrgszw/comment/iqf1gps/?utm_source=share&utm_medium=web3x&utm_name=web3xcss&utm_term=1&utm_content=share_button
imports = [
./hardware-configuration.nix
Expand All @@ -14,6 +17,7 @@
./bootloader.nix
./services.nix
./virtualisation.nix
./nvidia.nix
./impermanence.nix
./sops.nix
];
Expand Down
76 changes: 76 additions & 0 deletions system/machines/silvio-pc/nvidia.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
lib,
pkgs,
config,
...
}: {
nixpkgs.allowUnfreePackages = [
"nvidia-.*"
];

nixpkgs.config.cudaSupport = true;

# Enable OpenGL
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
};

services.xserver.videoDrivers = ["nvidia"];

hardware.nvidia = {
# Modesetting is required.
modesetting.enable = true;

# Nvidia power management. Experimental, and can cause sleep/suspend to fail.
powerManagement.enable = false;
# Fine-grained power management. Turns off GPU when not in use.
# Experimental and only works on modern Nvidia GPUs (Turing or newer).
powerManagement.finegrained = false;

# 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;

prime = {
sync.enable = true;

intelBusId = "PCI:0:2:0";
nvidiaBusId = "PCI:2:0:0";
};

vgpu = {
enable = true; # Enable NVIDIA KVM vGPU + GRID driver
unlock.enable = true; # Unlock vGPU functionality on consumer cards using DualCoder/vgpu_unlock project.
};
};

# CUDA
# boot.kernelModules = [ "nvidia-uvm" ];
# boot.blacklistedKernelModules = [ "nouveau" ];

nix = {
settings = {
substituters = [
"https://cuda-maintainers.cachix.org"
];
trusted-public-keys = [
"cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
];
};
};
# TODO: check out https://github.com/guibou/nixGL
}
2 changes: 1 addition & 1 deletion system/machines/silvio-pc/virtualisation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@

# Blacklist nvidia because it's annoying.
# TODO: pcie passthrough using ie. https://github.com/CRTified/nur-packages
boot.blacklistedKernelModules = ["nvidia" "nouveau"];
# boot.blacklistedKernelModules = ["nvidia" "nouveau"];
}
21 changes: 21 additions & 0 deletions system/modules/gaming.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
lib,
config,
...
}: {
options.booq.gaming.enable = lib.mkOption {
default = false;
type = lib.types.bool;
};
config = lib.mkIf config.booq.gaming.enable {
nixpkgs.allowUnfreePackages = [
"steam(-.*)?"
];

programs.steam = {
enable = true;
remotePlay.openFirewall = true;
dedicatedServer.openFirewall = true;
};
};
}
25 changes: 25 additions & 0 deletions system/modules/unfree.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
config,
lib,
...
}: let
inherit (lib) mkOption types;
cfg = config.nixpkgs.allowUnfreePackages;
in {
options = {
nixpkgs.allowUnfreePackages = mkOption {
default = [];
type = types.listOf types.str;
description = "List of unfree packages allowed to be installed";
example = lib.literalExpression ''[ "slack" "discord" steam-.*" ]'';
};
};

config = {
nixpkgs.config.allowUnfreePredicate = pkg: let
pkgName = lib.getName pkg;
matchPkgs = reg: ! builtins.isNull (builtins.match reg pkgName);
in
builtins.any matchPkgs cfg;
};
}
2 changes: 1 addition & 1 deletion system/modules/users/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
extraGroups = ["wheel" "networkmanager"];
shell = pkgs.nushell;
openssh.authorizedKeys.keys = [
"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDoHum4oCBnA8D9EXORuM6I8ARALZ6uEDF0zIBu1+V7RW1zNBlhlC8m+ZZ23NxridfVkUat6Nh6EfsJXTzzsKwERayrTULCp7YWm5ALO8vFUKM5qRyCoiLR5E9WpVYeNVLkYXjiIl4ctcotVJ65zxLAdeIi6QYJHd4Ze8lhzO5bqOQSNYVzMj+ASmY6/886IRwCYVM+dJ7sMSMN6suk4mgVSRR3+L5D2+zrYRkhfT/cD6aCdkHOZLV+mW3W79D7v+6Vba2zxZiH2UlAfTuQbkEKSQbB4Sy9uruKfv4gFOx+mxrK1rdWE0peMzCcEFeEEN5Fkh3Riy91xNRK2gnvsLqRYE7wLxaH7+X9zTMJYZDuGGgMU+3E1IfowOqA7w10YmSHIpCNEFkUb/FPaGCpEtLBgRwq/kYmCwghWmcp6MOQ83p6hwTqZ8fvgkdvtd7UIbha87WlEAhy0fHS6dLdPc0H66OlBDscsJkM4qmntiBnzFxInvZfyVnAWjNcNxSDmTpv1FdAPfquItY1PNhZSea1elFC3k6ivYUwe8n83dgJKb1ODU0D//ScsLiQiSvD4yjqx3cLj2NLEJ7QA+LQpT6APLDAJQM/AHmbqpi+m95aprtSRR1FH6LB8aX7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