-{ config, lib, pkgs, hostName, ... }:
+{ pkgs, hostName, ... }:
{
-hardware.cpu.intel.updateMicrocode = true;
-powerManagement.cpuFreqGovernor = lib.mkDefault "ondemand";
-services.thinkfan = {
- enable = true;
- levels = ''
- (0, 0, 57)
- (1, 56, 62)
- (2, 61, 65)
- (3, 64, 66)
- (4, 65, 68)
- (5, 67, 71)
- (6, 70, 76)
- (7, 75, 81)
- (127, 80, 32767)
- '';
-};
-hardware.acpilight.enable = true;
-services.acpid = {
- enable = true;
- handlers = {
- brightnessDown = {
- event = "video/brightnessdown.*";
- action = "${pkgs.acpilight}/bin/xbacklight -dec 5";
- };
- brightnessUp = {
- event = "video/brightnessup.*";
- action = "${pkgs.acpilight}/bin/xbacklight -inc 5";
- };
- acAdapter = {
- event = "ac_adapter/*";
- action = ''
- vals=($1)
- case ''${vals[3]} in
- 00000000) # unplugged
- ${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g powersave;;
- 00000001) # plugged in
- ${pkgs.linuxPackages.cpupower}/bin/cpupower frequency-set -g ondemand;;
- esac
- '';
- };
- };
-};
+ imports = [
+ ../../nixos/profiles/hardware/X201.nix
+ ../../nixos/profiles/zfs.nix
+ ../../nixos/profiles/zramSwap.nix
+ ];
+
+ # Setting the machine-id avoids to reencrypt all credentials
+ # when reinstalling NixOS on a new drive.
+ # Manually generated with : uuidgen | tr -d -
+ environment.etc.machine-id.source = ./machine-id.clear;
+
+ # The 32-bit host id of the host, formatted as 8 hexadecimal characters.
+ # You should try to make this id unique among your hosts.
+ # Manually generated with : uuidgen | head -c8
+ networking.hostId = "ce53d0c3";
-# https://bugzilla.kernel.org/show_bug.cgi?id=110941
-boot.kernelParams = [ "intel_pstate=no_hwp" ];
-boot.kernelModules = [ "kvm-intel" ];
-boot.cleanTmpDir = true;
-boot.tmpOnTmpfs = true;
-boot.extraModulePackages = [
- config.boot.kernelPackages.exfat-nofuse
-];
-boot.loader.grub = {
- enable = true;
- version = 2;
- device = "/dev/disk/by-id/ata-Samsung_SSD_850_PRO_128GB_S1SMNSAFC36436X";
- configurationLimit = 3;
- #zfsSupport = true;
/*
- efiSupport = true;
- efi = {
- canTouchEfiVariables = false;
+ boot.loader.efi = {
+ canTouchEfiVariables = true;
efiSysMountPoint = "/boot/efi";
- };
+ };
*/
- #enableCryptodisk = true;
-};
+ boot.loader.grub = {
+ enable = true;
+ memtest86.enable = true;
+ devices = [
+ "/dev/disk/by-id/ata-Samsung_SSD_850_PRO_128GB_S1SMNSAFC36436X"
+ ];
+ configurationLimit = 16;
-fileSystems."/boot" =
- { device = "/dev/disk/by-partlabel/${hostName}_ssd_boot";
- fsType = "ext2";
- };
-fileSystems."/boot/efi" =
- { device = "/dev/disk/by-partlabel/${hostName}_ssd_efi";
- fsType = "vfat";
+ #zfsSupport = true;
+ #efiSupport = true;
+ #enableCryptodisk = true;
};
-swapDevices = [
- { device = "/dev/disk/by-partlabel/${hostName}_ssd_swap";
- randomEncryption = {
- enable = true;
- cipher = "aes-xts-plain64";
- source = "/dev/urandom";
- };
- }
-];
-zramSwap = {
- enable = true;
- algorithm = lib.mkDefault "zstd";
- # There is little point creating a zram of greater
- # than twice the size of memory
- # since we expect a 2:1 compression ratio.
- # Note that zram uses about 0.1% of the size of the disk
- # when not in use so a huge zram is wasteful.
- memoryPercent = lib.mkDefault 150;
- # Linux supports multithreaded compression for 1 device since 3.15.
- # See https://lkml.org/lkml/2014/2/28/404 for details.
- swapDevices = lib.mkDefault 1;
-};
-boot.kernel.sysctl = {
- # Increase cache pressure, which increases the tendency of the kernel to
- # reclaim memory used for caching of directory and inode objects. You will use
- # less memory over a longer period of time. The performance hit is negated by
- # the downside of swapping sooner.
- "vm.vfs_cache_pressure" = lib.mkDefault 500;
-
- # Increasing how aggressively the kernel will swap memory pages since we are
- # using ZRAM first.
- "vm.swappiness" = lib.mkDefault 100;
+ boot.zfs.requestEncryptionCredentials = [ hostName ];
- # Background processes will start writing right away when it hits the 1% limit
- "vm.dirty_background_ratio" = lib.mkDefault 1;
+ hardware.enableRedistributableFirmware = true;
- # The system won’t force synchronous I/O until it gets to 50% dirty_ratio.
- "vm.dirty_ratio" = lib.mkDefault 50;
-};
+ # Note that gobi_loader -2000 has to be rerun if the SIM is hot swapped
+ services.udev.extraRules = ''
+ ACTION=="add", SUBSYSTEM=="tty", KERNEL=="ttyUSB*", ATTRS{idVendor}=="05c6", ATTRS{idProduct}=="9204", RUN+="${pkgs.gobi_loader}/lib/udev/gobi_loader -2000 $env{DEVNAME} /home/julm/files/thinkpad-x201/gobi"
+ '';
-# The 32-bit host id of the host, formatted as 8 hexadecimal characters.
-# You should try to make this id unique among your hosts.
-# Manually generated with : head -c4 /dev/urandom | od -A none -t x4 | cut -d ' ' -f 2
-networking.hostId = "ce53d0c3";
+ fileSystems."/boot" =
+ {
+ device = "/dev/disk/by-partlabel/${hostName}_ssd_boot";
+ fsType = "ext2";
+ };
+ fileSystems."/boot/efi" =
+ {
+ device = "/dev/disk/by-partlabel/${hostName}_ssd_efi";
+ fsType = "vfat";
+ };
+ swapDevices = [
+ {
+ device = "/dev/disk/by-partlabel/${hostName}_ssd_swap";
+ randomEncryption = {
+ enable = true;
+ cipher = "aes-xts-plain64";
+ source = "/dev/urandom";
+ };
+ }
+ ];
-# none is the recommended elevator with ZFS (which has its own I/O scheduler)
-# and/or for SSD, whereas HDD could use mq-deadline.
-services.udev.extraRules = ''
- # set none scheduler for non-rotating disks
- ACTION=="add|change", KERNEL=="sd[a-z]", ATTR{queue/rotational}=="0", ATTR{queue/scheduler}="none"
-'';
+ boot.supportedFilesystems = [ "ntfs" "vfat" ];
-boot.supportedFilesystems = [ "zfs" ];
-boot.initrd.supportedFilesystems = [ "zfs" ];
-boot.initrd.availableKernelModules = [
- "ahci"
- "drbg"
- "ehci_pci"
- "gf128mul"
- "hmac"
- "sd_mod"
-];
+ fileSystems."/" =
+ {
+ device = "${hostName}/root";
+ fsType = "zfs";
+ };
+ fileSystems."/nix" =
+ {
+ device = "${hostName}/nix";
+ fsType = "zfs";
+ };
+ fileSystems."/var" =
+ {
+ device = "${hostName}/var";
+ fsType = "zfs";
+ };
-boot.zfs.forceImportAll = false;
-boot.zfs.forceImportRoot = false;
-boot.zfs.enableUnstable = false;
-boot.zfs.requestEncryptionCredentials = [ hostName ];
-services.zfs.autoScrub.enable = true;
-environment.systemPackages = [ pkgs.zfs ];
+ services.pipewire.jack.enable = true;
-fileSystems."/" =
- { device = "${hostName}/root";
- fsType = "zfs";
- };
-fileSystems."/nix" =
- { device = "${hostName}/nix";
- fsType = "zfs";
- };
-fileSystems."/var" =
- { device = "${hostName}/var";
- fsType = "zfs";
+ services.acpid = {
+ # Suspending not work well on this old computer.
+ lidEventCommands = "";
};
}