Files
nixos/hosts/nb/modules/suspend-fixes.nix

25 lines
981 B
Nix

{ config, pkgs, lib, ... }:
{
# Add i2c_hid_acpi kernel module for proper input device support
boot.kernelModules = [ "i2c_hid_acpi" ];
# Commands to run after resume from suspend/hibernate
# This is the NixOS-native way to ensure proper execution timing
powerManagement.resumeCommands = ''
# Reload i2c_hid_acpi module to fix keyboard/touchpad after suspend
${pkgs.kmod}/bin/rmmod i2c_hid_acpi || true
${pkgs.kmod}/bin/modprobe i2c_hid_acpi
# Sync filesystem to ensure all pending writes are committed
${pkgs.util-linux}/bin/sync
# Remount all btrfs subvolumes read-write if they became read-only
# This fixes the issue where LUKS + btrfs can remount read-only after suspend
${pkgs.util-linux}/bin/mount -o remount,rw /nix || true
${pkgs.util-linux}/bin/mount -o remount,rw /nix/store || true
${pkgs.util-linux}/bin/mount -o remount,rw /nix/persist || true
${pkgs.util-linux}/bin/mount -o remount,rw /swap || true
'';
}