feat(nixos): lenovo hardware

This commit is contained in:
2025-10-16 12:22:19 +00:00
parent 3139fd1d9f
commit abdc808693
7 changed files with 155 additions and 25 deletions

38
flake.lock generated
View File

@@ -37,7 +37,7 @@
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"nixpkgs": [ "nixpkgs": [
"nixpkgs-25-05" "nixpkgs"
], ],
"utils": "utils" "utils": "utils"
}, },
@@ -58,7 +58,7 @@
"disko": { "disko": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"nixpkgs-25-05" "nixpkgs"
] ]
}, },
"locked": { "locked": {
@@ -171,7 +171,7 @@
"home-manager": { "home-manager": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"nixpkgs-25-05" "nixpkgs"
] ]
}, },
"locked": { "locked": {
@@ -258,7 +258,7 @@
"hyprutils": "hyprutils", "hyprutils": "hyprutils",
"hyprwayland-scanner": "hyprwayland-scanner", "hyprwayland-scanner": "hyprwayland-scanner",
"nixpkgs": [ "nixpkgs": [
"nixpkgs-25-05" "nixpkgs"
], ],
"pre-commit-hooks": "pre-commit-hooks", "pre-commit-hooks": "pre-commit-hooks",
"systems": "systems_2", "systems": "systems_2",
@@ -493,13 +493,28 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-25-05": { "nixos-hardware": {
"locked": { "locked": {
"lastModified": 1752436162, "lastModified": 1760106635,
"narHash": "sha256-Kt1UIPi7kZqkSc5HVj6UY5YLHHEzPBkgpNUByuyxtlw=", "narHash": "sha256-2GoxVaKWTHBxRoeUYSjv0AfSOx4qw5CWSFz2b+VolKU=",
"owner": "NixOS",
"repo": "nixos-hardware",
"rev": "9ed85f8afebf2b7478f25db0a98d0e782c0ed903",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixos-hardware",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1760423683,
"narHash": "sha256-Tb+NYuJhWZieDZUxN6PgglB16yuqBYQeMJyYBGCXlt8=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "dfcd5b901dbab46c9c6e80b265648481aafb01f8", "rev": "a493e93b4a259cd9fea8073f89a7ed9b1c5a1da2",
"type": "github" "type": "github"
}, },
"original": { "original": {
@@ -513,7 +528,7 @@
"inputs": { "inputs": {
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"nixpkgs": [ "nixpkgs": [
"nixpkgs-25-05" "nixpkgs"
], ],
"nuschtosSearch": "nuschtosSearch", "nuschtosSearch": "nuschtosSearch",
"systems": "systems_4" "systems": "systems_4"
@@ -586,7 +601,8 @@
"home-manager": "home-manager", "home-manager": "home-manager",
"hyprland": "hyprland", "hyprland": "hyprland",
"impermanence": "impermanence", "impermanence": "impermanence",
"nixpkgs-25-05": "nixpkgs-25-05", "nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs",
"nixvim": "nixvim", "nixvim": "nixvim",
"rust-overlay": "rust-overlay" "rust-overlay": "rust-overlay"
} }
@@ -594,7 +610,7 @@
"rust-overlay": { "rust-overlay": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
"nixpkgs-25-05" "nixpkgs"
] ]
}, },
"locked": { "locked": {

View File

@@ -1,47 +1,50 @@
{ {
description = "yukkop's nix utilities"; description = "yukkop's nix utilities";
inputs = { inputs = {
nixpkgs-25-05.url = "github:NixOS/nixpkgs/nixos-25.05"; nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";
rust-overlay = { rust-overlay = {
url = "github:oxalica/rust-overlay"; url = "github:oxalica/rust-overlay";
inputs = { inputs = {
nixpkgs.follows = "nixpkgs-25-05"; nixpkgs.follows = "nixpkgs";
}; };
}; };
deploy-rs = { deploy-rs = {
url = "github:serokell/deploy-rs"; url = "github:serokell/deploy-rs";
inputs.nixpkgs.follows = "nixpkgs-25-05"; inputs.nixpkgs.follows = "nixpkgs";
}; };
hyprland = { hyprland = {
url = "github:hyprwm/Hyprland"; url = "github:hyprwm/Hyprland";
inputs.nixpkgs.follows = "nixpkgs-25-05"; inputs.nixpkgs.follows = "nixpkgs";
}; };
nixvim = { nixvim = {
url = "github:nix-community/nixvim/nixos-25.05"; url = "github:nix-community/nixvim/nixos-25.05";
inputs.nixpkgs.follows = "nixpkgs-25-05"; inputs.nixpkgs.follows = "nixpkgs";
}; };
disko = { disko = {
url = "github:nix-community/disko"; url = "github:nix-community/disko";
inputs.nixpkgs.follows = "nixpkgs-25-05"; inputs.nixpkgs.follows = "nixpkgs";
}; };
impermanence = { impermanence = {
url = "github:nix-community/impermanence"; url = "github:nix-community/impermanence";
inputs.nixpkgs.follows = "nixpkgs-25-05"; inputs.nixpkgs.follows = "nixpkgs";
}; };
home-manager = { home-manager = {
url = "github:nix-community/home-manager/release-25.05"; url = "github:nix-community/home-manager/release-25.05";
inputs.nixpkgs.follows = "nixpkgs-25-05"; inputs.nixpkgs.follows = "nixpkgs";
};
nixos-hardware = {
url = "github:NixOS/nixos-hardware";
inputs.nixpkgs.follows = "nixpkgs";
}; };
}; };
outputs = { outputs = {
self, self,
nixpkgs-25-05, nixpkgs,
rust-overlay, rust-overlay,
... ...
}@inputs: let }@inputs: let
flake = ./.; flake = ./.;
nixpkgs = nixpkgs-25-05;
self-lib = import ./lib { inherit flake self inputs; }; self-lib = import ./lib { inherit flake self inputs; };
# Create overlay that includes legacy packages # Create overlay that includes legacy packages

View File

@@ -1,5 +1,5 @@
{ flake, inputs, self }: let { flake, inputs, self }: let
nixpkgs = inputs.nixpkgs-25-05; nixpkgs = inputs.nixpkgs;
lib = nixpkgs.lib; lib = nixpkgs.lib;
recursiveUpdate = nixpkgs.lib.recursiveUpdate; recursiveUpdate = nixpkgs.lib.recursiveUpdate;

View File

@@ -5,6 +5,7 @@
inputs, inputs,
lib, lib,
config, config,
modulesPath,
... ...
}: let }: let
cfg = config.hectic.hardware.lenovo-legion; cfg = config.hectic.hardware.lenovo-legion;
@@ -33,5 +34,115 @@ in {
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
imports = [
(modulesPath + "/installer/scan/not-detected.nix")
"${inputs.nixos-hardware}/common/cpu/amd"
"${inputs.nixos-hardware}../../../common/cpu/amd/pstate.nix"
"${inputs.nixos-hardware}../../../common/gpu/amd"
"${inputs.nixos-hardware}../../../common/gpu/nvidia/prime-sync.nix"
"${inputs.nixos-hardware}../../../common/pc/laptop"
"${inputs.nixos-hardware}../../../common/pc/laptop/ssd"
];
hardware.nvidia = {
modesetting.enable = true;
prime = {
amdgpuBusId = "PCI:5:0:0";
nvidiaBusId = "PCI:1:0:0";
};
};
environment.systemPackages = with pkgs; [
vulkan-tools
];
/* boot */
boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "usb_storage" "usbhid" "sd_mod" ];
boot.initrd.kernelModules = [ "dm-snapshot" "amdgpu" ];
boot.kernelModules = [ "kvm-amd" ];
boot.extraModulePackages = [ ];
/* */
networking.useDHCP = lib.mkDefault true;
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
/* cpu */
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
/* nvidia */
services.xserver.videoDrivers = [
"nvidia"
#"amdgpu" # NOTE: probably useles with nvidia optimus prime
#"nouveau" # NOTE: open source nvidia
];
hardware.opengl = {
enable = true;
driSupport = true;
driSupport32Bit = true;
extraPackages = with pkgs; [
vulkan-loader
vulkan-validation-layers
vulkan-extension-layer
amdvlk
];
extraPackages32 = with pkgs; [
pkgsi686Linux.vulkan-loader
pkgsi686Linux.vulkan-validation-layers
pkgsi686Linux.vulkan-extension-layer
driversi686Linux.amdvlk
];
};
#environment.variables.VK_DRIVER_FILES=/run/opengl-driver/share/vulkan/icd.d/nvidia_icd.x86_64.json;
#environment.sessionVariables.VK_DRIVER_FILES = "/run/opengl-driver/share/vulkan/icd.d/nvidia_icd.x86_64.json";
#environment.sessionVariables = rec {
# VK_ICD_FILENAMES =
# "${config.hardware.nvidia.package}/share/vulkan/icd.d/nvidia_icd.x86_64.json";
# #:${config.environment.variables.VK_ICD_FILENAMES or ""}";
#};
hardware.nvidia = {
# Modesetting is required.
modesetting.enable = true;
# 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 = 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;
# nvidia package overwrive
package = config.boot.kernelPackages.nvidiaPackages.stable;
};
/* sound */
hardware.pulseaudio.enable = true;
hardware.pulseaudio.support32Bit = true;
}; };
} }

View File

@@ -9,7 +9,7 @@
name = builtins.baseNameOf ./.; name = builtins.baseNameOf ./.;
in self.lib.nixpkgs-lib.nixosSystem { in self.lib.nixpkgs-lib.nixosSystem {
pkgs = import inputs.nixpkgs-25-05 { pkgs = import inputs.nixpkgs {
inherit system; inherit system;
overlays = [ self.overlays.default ]; overlays = [ self.overlays.default ];
}; };

View File

@@ -9,7 +9,7 @@
name = builtins.baseNameOf ./.; name = builtins.baseNameOf ./.;
in self.lib.nixpkgs-lib.nixosSystem { in self.lib.nixpkgs-lib.nixosSystem {
pkgs = import inputs.nixpkgs-25-05 { pkgs = import inputs.nixpkgs {
inherit system; inherit system;
overlays = [ self.overlays.default ]; overlays = [ self.overlays.default ];
}; };

View File

@@ -9,7 +9,7 @@
name = builtins.baseNameOf ./.; name = builtins.baseNameOf ./.;
in self.lib.nixpkgs-lib.nixosSystem { in self.lib.nixpkgs-lib.nixosSystem {
pkgs = import inputs.nixpkgs-25-05 { pkgs = import inputs.nixpkgs {
inherit system; inherit system;
overlays = [ self.overlays.default ]; overlays = [ self.overlays.default ];
}; };