From 20f87b132b4ddb54ae032c14b6f466598e45f6a5 Mon Sep 17 00:00:00 2001 From: tomoron Date: Wed, 16 Oct 2024 20:54:07 +0200 Subject: [PATCH] add drivers for battery gestion and nvidia gpu --- configuration.nix | 2 ++ flake.lock | 17 +++++++++++++++ flake.nix | 4 +++- hardware-configuration.nix | 40 ++++++++++++++++++++++++++++++++++ hosts/laptop/configuration.nix | 15 ++++++++++++- 5 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 hardware-configuration.nix diff --git a/configuration.nix b/configuration.nix index 4034f00..1870bdb 100644 --- a/configuration.nix +++ b/configuration.nix @@ -7,6 +7,7 @@ # imports = []; nix.settings.experimental-features = ["nix-command" "flakes"]; + nixpkgs.config.allowUnfree = true; boot.loader = { systemd-boot.enable = true; @@ -44,6 +45,7 @@ home-manager killall vim + pciutils ]; #Open ports in the firewall. diff --git a/flake.lock b/flake.lock index 7ede4a7..a5780eb 100644 --- a/flake.lock +++ b/flake.lock @@ -20,6 +20,22 @@ "type": "github" } }, + "nixos-hardware": { + "locked": { + "lastModified": 1728729581, + "narHash": "sha256-oazkQ/z7r43YkDLLQdMg8oIB3CwWNb+2ZrYOxtLEWTQ=", + "owner": "NixOS", + "repo": "nixos-hardware", + "rev": "a8dd1b21995964b115b1e3ec639dd6ce24ab9806", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "master", + "repo": "nixos-hardware", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1728018373, @@ -39,6 +55,7 @@ "root": { "inputs": { "home-manager": "home-manager", + "nixos-hardware": "nixos-hardware", "nixpkgs": "nixpkgs" } } diff --git a/flake.nix b/flake.nix index d99226e..f018f8f 100644 --- a/flake.nix +++ b/flake.nix @@ -7,9 +7,10 @@ url = "github:nix-community/home-manager"; inputs.nixpkgs.follows = "nixpkgs"; }; + nixos-hardware.url = "github:NixOS/nixos-hardware/master"; }; - outputs = { self, nixpkgs, home-manager, ... }@inputs: + outputs = { self, nixpkgs, home-manager, nixos-hardware, ... }@inputs: let pkgs = nixpkgs.legacyPackages."x86_64-linux"; username="tom"; @@ -38,6 +39,7 @@ ./hardware-configuration.nix ./configuration.nix ./hosts/laptop/configuration.nix + nixos-hardware.nixosModules.asus-zephyrus-ga401 ]; }; }; diff --git a/hardware-configuration.nix b/hardware-configuration.nix new file mode 100644 index 0000000..7510088 --- /dev/null +++ b/hardware-configuration.nix @@ -0,0 +1,40 @@ +# 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, modulesPath, ... }: + +{ + imports = + [ (modulesPath + "/installer/scan/not-detected.nix") + ]; + + boot.initrd.availableKernelModules = [ "nvme" "xhci_pci" "usb_storage" "usbhid" "sd_mod" ]; + boot.initrd.kernelModules = [ ]; + boot.kernelModules = [ "kvm-amd" ]; + boot.extraModulePackages = [ ]; + + fileSystems."/" = + { device = "/dev/disk/by-uuid/af670eba-263f-4800-a8d5-e1134e89a5c5"; + fsType = "ext4"; + }; + + fileSystems."/boot" = + { device = "/dev/disk/by-uuid/7DE9-B826"; + fsType = "vfat"; + options = [ "fmask=0022" "dmask=0022" ]; + }; + + swapDevices = + [ { device = "/dev/disk/by-uuid/019d9cf2-92f7-404c-af75-0cbc0f985aa7"; } + ]; + + # Enables DHCP on each ethernet and wireless interface. In case of scripted networking + # (the default) this is the recommended approach. When using systemd-networkd it's + # still possible to use this option, but it's recommended to use it in conjunction + # with explicit per-interface declarations with `networking.interfaces..useDHCP`. + networking.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp2s0.useDHCP = lib.mkDefault true; + + nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux"; + hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/laptop/configuration.nix b/hosts/laptop/configuration.nix index cfeb8fd..8c47f7e 100644 --- a/hosts/laptop/configuration.nix +++ b/hosts/laptop/configuration.nix @@ -8,5 +8,18 @@ environment.systemPackages = with pkgs; [ acpi - ] + tlp + ]; + + hardware.opengl = { + enable = true; + driSupport32Bit = true; + }; + + services.xserver.videoDrivers = ["nvidia"]; + + hardware.nvidia.prime.offload = { + enable = true; + enableOffloadCmd = true; + }; }