From 99b4d41ddaac3bd70540cfc2ab907f1f13d8292a Mon Sep 17 00:00:00 2001 From: iFargle Date: Sat, 1 Jul 2023 17:23:32 +0900 Subject: [PATCH] More modulatiry --- configuration.nix | 32 +------------------------ flake.nix | 10 ++++---- hardware/lenovo-p1/configuration.nix | 33 ++++++++++++++++++++++++++ hardware/{ => lenovo-p1}/lenovo-p1.nix | 0 4 files changed, 39 insertions(+), 36 deletions(-) create mode 100644 hardware/lenovo-p1/configuration.nix rename hardware/{ => lenovo-p1}/lenovo-p1.nix (100%) diff --git a/configuration.nix b/configuration.nix index f6e11f0e..9345da1d 100644 --- a/configuration.nix +++ b/configuration.nix @@ -10,7 +10,7 @@ # Other things to consider: # Telegraf -{ lib, config, pkgs, hostname, ... }: { +{ lib, config, pkgs, ... }: { imports = [ # Gnome configuration file. @@ -31,8 +31,6 @@ # Bootloader boot.loader.efi.canTouchEfiVariables = true; boot.tmp.cleanOnBoot = true; - # Hibernation resume device: - boot.resumeDevice = "/dev/disk/by-uuid/67600fc1-6d26-4d2f-b2d3-a99174654058"; # Plymouth splash screen boot.plymouth.enable = true; boot.initrd.systemd.enable = true; @@ -43,15 +41,6 @@ boot.lanzaboote.enable = true; boot.lanzaboote.pkiBundle = "/etc/secureboot"; - # Setup keyfile - boot.initrd.secrets = { - "/crypto_keyfile.bin" = null; - }; - - # Enable swap on luks - boot.initrd.luks.devices."luks-9704447e-6bd0-4a35-9c24-20cbab81c431".device = "/dev/disk/by-uuid/9704447e-6bd0-4a35-9c24-20cbab81c431"; - boot.initrd.luks.devices."luks-9704447e-6bd0-4a35-9c24-20cbab81c431".keyFile = "/crypto_keyfile.bin"; - # Enable networking networking = { hostName = "${hostname}"; @@ -84,13 +73,6 @@ LC_TIME = "en_US.UTF-8"; }; - # Configure the fingerprint reader - services.fprintd = { - enable = true; - tod.enable = true; - tod.driver = pkgs.libfprint-2-tod1-vfs0090; - }; - # Configure keymap in X11 services.xserver = { enable = true; @@ -104,15 +86,6 @@ videoDrivers = [ "nvidia" ]; autorun = true; }; - - # Enable nVidia PRIME Render Offload - # https://github.com/NixOS/nixos-hardware/blob/master/lenovo/thinkpad/p1/3th-gen/nvidia.nix - hardware.nvidia.prime = { - # Bus ID of the Intel GPU. - intelBusId = lib.mkDefault "PCI:0:2:0"; - # Bus ID of the NVIDIA GPU. - nvidiaBusId = lib.mkDefault "PCI:1:0:0"; - }; # Enable sound with pipewire. sound.enable = true; @@ -151,9 +124,6 @@ # Secureboot sbctl - # Fingerprint Reader - fprintd - # General packages # https://github.com/gvolpe/dconf2nix dconf2nix diff --git a/flake.nix b/flake.nix index 4707d293..090cfe8b 100644 --- a/flake.nix +++ b/flake.nix @@ -52,15 +52,15 @@ nixosConfigurations = { # Declare the configuration for my laptop nixos-p1 = lib.nixosSystem { - inherit system hostname; + inherit system; modules = [ # Hardware Configuration - ./hardware/lenovo-p1.nix - + ./hardware/lenovo-p1/hardware-configuration.nix + ./hardware/lenovo-p1/configuration.nix # SecureBoot Configuration lanzaboote.nixosModules.lanzaboote - # NixOS Configuration file + # Common NixOS Configuration file ./configuration.nix # Tell home-manager to use both global and user packages: @@ -73,7 +73,7 @@ # Declare the configuration for my desktop nixos-desktop = lib.nixosSystem { - inherit system hostname; + inherit system; modules = [ # Hardware Configuration ./hardware/desktop.nix diff --git a/hardware/lenovo-p1/configuration.nix b/hardware/lenovo-p1/configuration.nix new file mode 100644 index 00000000..8694a4c6 --- /dev/null +++ b/hardware/lenovo-p1/configuration.nix @@ -0,0 +1,33 @@ +{ lib, config, pkgs, ... }: { + + # Enable swap on luks + boot.initrd.luks.devices."luks-9704447e-6bd0-4a35-9c24-20cbab81c431".device = "/dev/disk/by-uuid/9704447e-6bd0-4a35-9c24-20cbab81c431"; + boot.initrd.luks.devices."luks-9704447e-6bd0-4a35-9c24-20cbab81c431".keyFile = "/crypto_keyfile.bin"; + + # Setup keyfile + boot.initrd.secrets = { + "/crypto_keyfile.bin" = null; + }; + + # Hibernation resume device: + boot.resumeDevice = "/dev/disk/by-uuid/67600fc1-6d26-4d2f-b2d3-a99174654058"; + + # Configure the fingerprint reader + services.fprintd = { + enable = true; + tod.enable = true; + tod.driver = pkgs.libfprint-2-tod1-vfs0090; + }; + + # Enable nVidia PRIME Render Offload + # https://github.com/NixOS/nixos-hardware/blob/master/lenovo/thinkpad/p1/3th-gen/nvidia.nix + hardware.nvidia.prime = { + # Bus ID of the Intel GPU. + intelBusId = lib.mkDefault "PCI:0:2:0"; + # Bus ID of the NVIDIA GPU. + nvidiaBusId = lib.mkDefault "PCI:1:0:0"; + }; + + # Fingerprint software + environment.systemPackages = with pkgs; [ fprintd ]; +} \ No newline at end of file diff --git a/hardware/lenovo-p1.nix b/hardware/lenovo-p1/lenovo-p1.nix similarity index 100% rename from hardware/lenovo-p1.nix rename to hardware/lenovo-p1/lenovo-p1.nix