Skip to content

Commit

Permalink
feat(system/pkgs): add mesa,intel related pkgs (#157)
Browse files Browse the repository at this point in the history
* feat(system/pkgs): add mesa,intel related pkgs

* feat(system/security): apply security tweaks to intel_gpu_top

* chore(flake): chaotics.follows = nixpkgs

* patch(flake): rename nixpkgs-unstable -> nixpkgs-small

* patch(profiles/workstation): add mesa support
  • Loading branch information
piyoki authored Mar 16, 2024
1 parent 95c5ca9 commit c10c70d
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 116 deletions.
164 changes: 76 additions & 88 deletions flake.lock

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
];
# function to generate specialArgs
genSpecialArgs = system: {
pkgs-unstable = (import nixpkgs-unstable) { inherit system; config.allowUnfree = lib.mkDefault true; };
pkgs-small = (import nixpkgs-small) { inherit system; config.allowUnfree = lib.mkDefault true; };
inherit (import ./shared/lib { inherit lib; }) sharedLib;
inherit inputs pkgs system user;
};
Expand Down Expand Up @@ -121,8 +121,8 @@
inputs = {
# public source
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable-small";
chaotic.url = "github:chaotic-cx/nyx/nyxpkgs-unstable";
nixpkgs-small.url = "github:nixos/nixpkgs/nixos-unstable-small";
chaotic = { url = "github:chaotic-cx/nyx/nyxpkgs-unstable"; inputs.nixpkgs.follows = "nixpkgs-small"; };
home-manager = { url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; };
sops-nix.url = "github:Mic92/sops-nix";
nixpkgs-wayland = { url = "github:nix-community/nixpkgs-wayland"; inputs.nixpkgs.follows = "nixpkgs"; };
Expand Down
4 changes: 2 additions & 2 deletions profiles/server/felix/hardware-configuration.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{ lib, pkgs-unstable, system, ... }:
{ lib, pkgs-small, system, ... }:

{
# settings specific to this VM setup
# <WARN> enable after installation!

boot = {
# use latest kernel
kernelPackages = pkgs-unstable.linuxPackages_latest;
kernelPackages = pkgs-small.linuxPackages_latest;
supportedFilesystems = [ "ext4" "btrfs" "xfs" "fat" "vfat" "cifs" "nfs" ];
growPartition = true;
kernelModules = [ "kvm-amd" ];
Expand Down
4 changes: 2 additions & 2 deletions profiles/server/mars/hardware-configuration.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 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, pkgs-unstable, modulesPath, system, ... }:
{ config, lib, pkgs-small, modulesPath, system, ... }:

{
imports =
Expand All @@ -10,7 +10,7 @@


boot = {
kernelPackages = pkgs-unstable.linuxPackages_latest;
kernelPackages = pkgs-small.linuxPackages_latest;
supportedFilesystems = [ "ext4" "btrfs" "xfs" "fat" "vfat" "cifs" "nfs" ];
# after resize the disk, it will grow partition automatically.
growPartition = true;
Expand Down
4 changes: 2 additions & 2 deletions profiles/server/sdwan-gateway/hardware-configuration.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{ lib, system, pkgs-unstable, ... }:
{ lib, system, pkgs-small, ... }:

{
# settings specific to this VM setup
# <WARN> enable after installation!

boot = {
# use latest kernel
kernelPackages = pkgs-unstable.linuxPackages_latest;
kernelPackages = pkgs-small.linuxPackages_latest;
supportedFilesystems = [ "ext4" "btrfs" "xfs" "fat" "vfat" "cifs" "nfs" ];
growPartition = true;
kernelModules = [ "kvm-amd" ];
Expand Down
4 changes: 2 additions & 2 deletions profiles/server/tailscale-gateway/hardware-configuration.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{ lib, system, pkgs-unstable, ... }:
{ lib, system, pkgs-small, ... }:

{
# settings specific to this VM setup
# <WARN> enable after installation!

boot = {
# use latest kernel
kernelPackages = pkgs-unstable.linuxPackages_latest;
kernelPackages = pkgs-small.linuxPackages_latest;
supportedFilesystems = [ "ext4" "btrfs" "xfs" "fat" "vfat" "cifs" "nfs" ];
growPartition = true;
kernelModules = [ "kvm-amd" ];
Expand Down
21 changes: 15 additions & 6 deletions profiles/workstation/nuc-12/hardware-configuration.nix
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# 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.
{ inputs, config, lib, pkgs, modulesPath, system, ... }:
{ inputs, config, lib, pkgs, pkgs-small, modulesPath, system, ... }:

# References:
# https://nixos.wiki/wiki/Intel_Graphics
Expand All @@ -14,7 +14,7 @@
boot = {
# Use the systemd-boot EFI boot loader.
# kernelPackages = pkgs.linuxPackages_latest;
# kernelPackages = pkgs-unstable.linuxPackages_testing;
# kernelPackages = pkgs-small.linuxPackages_testing;
kernelPackages = inputs.chaotic.packages.${system}.linuxPackages_cachyos;
supportedFilesystems = [ "ext4" "btrfs" "xfs" "fat" "vfat" "cifs" "nfs" ];

Expand Down Expand Up @@ -106,18 +106,21 @@

# GPU (Accelerate Video Playback)
# ref: https://nixos.wiki/wiki/Accelerated_Video_Playback
nixpkgs.config.packageOverrides = pkgs: {
vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; };
nixpkgs.config.packageOverrides = pkgs-small: {
vaapiIntel = pkgs-small.vaapiIntel.override { enableHybridCodec = true; };
};

hardware = {
# linux-firmware
enableAllFirmware = true;

# GPU
# GPU (OpenGL)
opengl = {
enable = true;
extraPackages = with pkgs; [
driSupport = true;
driSupport32Bit = true;
extraPackages = with pkgs-small; [
intel-compute-runtime # Intel Graphics Compute Runtime for OpenCL. Replaces Beignet for Gen8 (Broadwell) and beyond
intel-media-driver # Intel Media Driver for VAAPI
intel-vaapi-driver # VAAPI user mode driver for Intel Gen Graphics family
# vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
Expand All @@ -130,6 +133,12 @@
cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
};

# Mesa
# chaotic.mesa-git = {
# enable = true;
# fallbackSpecialisation = false;
# };

# High-DPI console
console.font = lib.mkDefault "${pkgs.terminus_font}/share/consolefonts/ter-u28n.psf.gz";

Expand Down
19 changes: 14 additions & 5 deletions profiles/workstation/thinkpad-x1-carbon/hardware-configuration.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# https://wiki.archlinux.org/title/Lenovo_ThinkPad_X1_Carbon_(Gen_10)
# https://wiki.archlinux.org/title/Lenovo_ThinkPad_X1_Carbon_(Gen_9)
# https://nixos.wiki/wiki/Intel_Graphics
{ inputs, config, lib, pkgs, modulesPath, system, ... }:
{ inputs, config, lib, pkgs, pkgs-small, modulesPath, system, ... }:

{
imports =
Expand All @@ -18,7 +18,7 @@
boot = {
# Use the systemd-boot EFI boot loader.
# kernelPackages = pkgs.linuxPackages_latest;
# kernelPackages = pkgs-unstable.linuxPackages_testing;
# kernelPackages = pkgs-small.linuxPackages_testing;
kernelPackages = inputs.chaotic.packages.${system}.linuxPackages_cachyos;
supportedFilesystems = [ "ext4" "btrfs" "xfs" "fat" "vfat" "cifs" "nfs" ];

Expand Down Expand Up @@ -105,18 +105,21 @@

# GPU (Accelerate Video Playback)
# ref: https://nixos.wiki/wiki/Accelerated_Video_Playback
nixpkgs.config.packageOverrides = pkgs: {
nixpkgs.config.packageOverrides = _pkgs-small: {
vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; };
};

hardware = {
# linux-firmware
enableAllFirmware = true;

# GPU
# GPU (OpenGL)
opengl = {
enable = true;
extraPackages = with pkgs; [
driSupport = true;
driSupport32Bit = true;
extraPackages = with pkgs-small; [
intel-compute-runtime # Intel Graphics Compute Runtime for OpenCL. Replaces Beignet for Gen8 (Broadwell) and beyond
intel-media-driver # Intel Media Driver for VAAPI
intel-vaapi-driver # VAAPI user mode driver for Intel Gen Graphics family
# vaapiIntel # LIBVA_DRIVER_NAME=i965 (older but works better for Firefox/Chromium)
Expand All @@ -129,6 +132,12 @@
cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
};

# Mesa
# chaotic.mesa-git = {
# enable = true;
# fallbackSpecialisation = false;
# };

# High-DPI console
console.font = lib.mkDefault "${pkgs.terminus_font}/share/consolefonts/ter-u28n.psf.gz";

Expand Down
4 changes: 2 additions & 2 deletions shared/modules/microvm/firecracker.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ lib, pkgs-unstable, system, ... }:
{ lib, pkgs-small, system, ... }:

{
networking.hostName = "firecracker-microvm";
Expand All @@ -7,7 +7,7 @@
inherit (import ../../vars) stateVersion;
};
nixpkgs.hostPlatform = lib.mkDefault system;
boot.kernelPackages = pkgs-unstable.linuxPackages_latest;
boot.kernelPackages = pkgs-small.linuxPackages_latest;
microvm = {
hypervisor = "firecracker";
socket = "control.socket";
Expand Down
11 changes: 7 additions & 4 deletions system/packages/misc.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@
{
environment.systemPackages = with pkgs; [
# misc
brightnessctl
cifs-utils
dmidecode
libnotify
brightnessctl # This program allows you read and control device brightness
cifs-utils # Tools for managing Linux CIFS client filesystems
dmidecode # A tool that reads information about your system's hardware from the BIOS according to the SMBIOS/DMI standard
libnotify # A library that sends desktop notifications to a notification daemon
libva-utils # A collection of utilities and examples for VA-API
cpufetch # Simplistic yet fancy CPU architecture fetching tool
vulkan-tools # Khronos official Vulkan Tools and Utilities
intel-gpu-tools # Tools for development and testing of the Intel DRM driver
];
}
8 changes: 8 additions & 0 deletions system/security/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,14 @@ in
login.enableGnomeKeyring = true;
};

# intel_gpu_top
wrappers.intel_gpu_top = {
source = "${pkgs.intel-gpu-tools}/bin/intel_gpu_top";
owner = "root";
group = "wheel";
permissions = "0750";
capabilities = "cap_perfmon=ep";
};

# sudo
# Reference: https://nixos.wiki/wiki/Sudo
Expand Down

0 comments on commit c10c70d

Please sign in to comment.