fix: hibernate resume for nb

This commit is contained in:
2025-10-19 18:14:40 +02:00
parent 28ed3fcf74
commit 7d5294e7b9
3 changed files with 26 additions and 27 deletions

View File

@@ -4,29 +4,21 @@
# Add i2c_hid_acpi kernel module for proper input device support
boot.kernelModules = [ "i2c_hid_acpi" ];
# Systemd service to reload i2c_hid_acpi module after resume
# This fixes keyboard and touchpad not working after suspend
systemd.services.reload-i2c-hid-after-resume = {
description = "Reload i2c_hid_acpi module after resume to fix keyboard/touchpad";
after = [ "suspend.target" "hibernate.target" "hybrid-sleep.target" ];
wantedBy = [ "suspend.target" "hibernate.target" "hybrid-sleep.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.bash}/bin/bash -c '${pkgs.kmod}/bin/rmmod i2c_hid_acpi; ${pkgs.kmod}/bin/modprobe 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
# Systemd service to remount /nix/persist if it becomes read-only after resume
# This fixes the btrfs read-only issue that can occur with LUKS + btrfs on suspend/resume
systemd.services.remount-persist-after-resume = {
description = "Remount /nix/persist read-write if needed after resume";
after = [ "suspend.target" "hibernate.target" "hybrid-sleep.target" ];
wantedBy = [ "suspend.target" "hibernate.target" "hybrid-sleep.target" ];
serviceConfig = {
Type = "oneshot";
ExecStart = "${pkgs.util-linux}/bin/mount -o remount,rw /nix/persist";
# Don't fail if already mounted rw
SuccessExitStatus = [ 0 32 ];
};
};
# 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
'';
}