From 4dbc3df3a7494b7e0256a91cb34aa3e7ceac897d Mon Sep 17 00:00:00 2001 From: Andrea Ciceri Date: Fri, 5 Aug 2022 21:02:53 +0200 Subject: [PATCH] Finally on thinkpad --- hosts/thinkpad/default.nix | 58 ++++-------------- hosts/thinkpad/hardware-configuration.nix | 73 +++++++++++++++++++++++ hosts/thinkpad/zfs.nix | 37 ++++++++++++ utils/default.nix | 4 +- 4 files changed, 125 insertions(+), 47 deletions(-) create mode 100644 hosts/thinkpad/hardware-configuration.nix create mode 100644 hosts/thinkpad/zfs.nix diff --git a/hosts/thinkpad/default.nix b/hosts/thinkpad/default.nix index 1d0f5d8..ae16cea 100644 --- a/hosts/thinkpad/default.nix +++ b/hosts/thinkpad/default.nix @@ -5,47 +5,23 @@ fleetModules, ... }: { - imports = fleetModules [ - "common" - "audio" - "ccr" - "exwm" - ]; - - hardware.cpu.intel.updateMicrocode = true; - hardware.enableRedistributableFirmware = true; + imports = + [ + ./zfs.nix + ./hardware-configuration.nix + ] + ++ fleetModules [ + "common" + "audio" + "ccr" + "exwm" + ]; boot.initrd.availableKernelModules = ["xhci_pci" "nvme" "usb_storage" "sd_mod"]; boot.initrd.kernelModules = []; boot.kernelModules = ["kvm-intel"]; boot.extraModulePackages = []; - fileSystems."/" = { - device = "rpool/system/root"; - fsType = "zfs"; - }; - - fileSystems."/nix" = { - device = "rpool/system/nix"; - fsType = "zfs"; - }; - - fileSystems."/home" = { - device = "rpool/user/home"; - fsType = "zfs"; - }; - - fileSystems."/boot" = { - device = "/dev/disk/by-label/boot"; - fsType = "vfat"; - }; - - swapDevices = [ - {device = "/dev/disk/by-uuid/3cab8a5d-602c-4e3d-b436-c0e5595aeb94";} - ]; - - networking.hostId = "8ef630a9"; - # 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 @@ -53,16 +29,6 @@ #networking.interfaces.enp0s31f6.useDHCP = lib.mkDefault true; #networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true; - powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; - - boot.loader.grub = { - enable = true; - copyKernels = true; - efiSupport = true; - devices = ["nodev"]; - efiInstallAsRemovable = true; - }; - networking.hostName = "thinkpad"; # Define your hostname. # Pick only one of the below networking options. #networking.wireless.enable = true; # Enables wireless support via wpa_supplicant. @@ -117,6 +83,8 @@ wget ]; + programs.light.enable = true; + # Some programs need SUID wrappers, can be configured further or are # started in user sessions. # programs.mtr.enable = true; diff --git a/hosts/thinkpad/hardware-configuration.nix b/hosts/thinkpad/hardware-configuration.nix new file mode 100644 index 0000000..d2fa703 --- /dev/null +++ b/hosts/thinkpad/hardware-configuration.nix @@ -0,0 +1,73 @@ +# 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 = ["xhci_pci" "nvme" "usb_storage" "sd_mod"]; + boot.initrd.kernelModules = []; + boot.kernelModules = []; + boot.extraModulePackages = []; + + fileSystems."/" = { + device = "rpool/nixos/root"; + fsType = "zfs"; + options = ["zfsutil" "X-mount.mkdir"]; + }; + + fileSystems."/home" = { + device = "rpool/nixos/home"; + fsType = "zfs"; + options = ["zfsutil" "X-mount.mkdir"]; + }; + + fileSystems."/var/lib" = { + device = "rpool/nixos/var/lib"; + fsType = "zfs"; + options = ["zfsutil" "X-mount.mkdir"]; + }; + + fileSystems."/var/log" = { + device = "rpool/nixos/var/log"; + fsType = "zfs"; + options = ["zfsutil" "X-mount.mkdir"]; + }; + + fileSystems."/boot" = { + device = "bpool/nixos/root"; + fsType = "zfs"; + options = ["zfsutil" "X-mount.mkdir"]; + }; + + fileSystems."/boot/efis/nvme-INTEL_SSDPEKKF010T8L_PHHP938405741P0D-part1" = { + device = "/dev/disk/by-uuid/5C39-390F"; + fsType = "vfat"; + }; + + fileSystems."/boot/efi" = { + device = "/boot/efis/nvme-INTEL_SSDPEKKF010T8L_PHHP938405741P0D-part1"; + fsType = "none"; + options = ["bind"]; + }; + + swapDevices = []; + + # 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.enp0s31f6.useDHCP = lib.mkDefault true; + # networking.interfaces.wlp0s20f3.useDHCP = lib.mkDefault true; + + powerManagement.cpuFreqGovernor = lib.mkDefault "powersave"; + hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware; +} diff --git a/hosts/thinkpad/zfs.nix b/hosts/thinkpad/zfs.nix new file mode 100644 index 0000000..6c9832c --- /dev/null +++ b/hosts/thinkpad/zfs.nix @@ -0,0 +1,37 @@ +{ + config, + pkgs, + ... +}: { + boot.supportedFilesystems = ["zfs"]; + networking.hostId = "adf0b5e7"; + boot.kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages; + boot.loader.efi.efiSysMountPoint = "/boot/efi"; + boot.loader.efi.canTouchEfiVariables = false; + boot.loader.generationsDir.copyKernels = true; + boot.loader.grub.efiInstallAsRemovable = true; + boot.loader.grub.enable = true; + boot.loader.grub.version = 2; + boot.loader.grub.copyKernels = true; + boot.loader.grub.efiSupport = true; + boot.loader.grub.zfsSupport = true; + boot.loader.grub.extraPrepareConfig = '' + mkdir -p /boot/efis + for i in /boot/efis/*; do mount $i ; done + + mkdir -p /boot/efi + mount /boot/efi + ''; + boot.loader.grub.extraInstallCommands = '' + ESP_MIRROR=$(mktemp -d) + cp -r /boot/efi/EFI $ESP_MIRROR + for i in /boot/efis/*; do + cp -r $ESP_MIRROR/EFI $i + done + rm -rf $ESP_MIRROR + ''; + boot.loader.grub.devices = [ + "/dev/disk/by-id/nvme-INTEL_SSDPEKKF010T8L_PHHP938405741P0D" + ]; + users.users.root.initialHashedPassword = "$6$EqXfyFLxUZfpmJ8F$UH3pLcHwgLpOZwiSDhdq/iR/p.uyZZYlk6G4Q0S8BtYr3Qt2xKU56Fwv3Mgco.J0i3cx1Nm8XMfvythSuv8gh/"; +} diff --git a/utils/default.nix b/utils/default.nix index 0896799..4306ef7 100644 --- a/utils/default.nix +++ b/utils/default.nix @@ -45,8 +45,8 @@ }; mkConfigurations = { - pc = mkConfiguration { - name = "pc"; + thinkpad = mkConfiguration { + name = "thinkpad"; system = supportedSystems.x86_64-linux; modules = []; };