From 89604624c927aa914069f650f823fad3cb9c1800 Mon Sep 17 00:00:00 2001 From: Rouven Seifert Date: Tue, 28 Feb 2023 20:48:06 +0100 Subject: [PATCH] set up hibernate --- README.md | 17 ++++++++++------- hosts/thinkpad/default.nix | 9 +++++++++ hosts/thinkpad/hardware-configuration.nix | 7 ++++++- 3 files changed, 25 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index b7b46da..93870d6 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,16 @@ A ThinkPad L15 that I use for almost everything that one needs a monitor to. NAME MOUNTPOINT COMMENT nvme0n1 ├─nvme0n1p1 /boot -└─nvme0n1p2 # LUKS-encrypted partition - └─luksroot # btrfs with some subvolumes - └─root / - └─home /home - └─lib /var/lib - └─log /var/log - └─store /nix/store +├─nvme0n1p2 # LUKS-encrypted partition +│ └─luksroot # btrfs with some subvolumes +│ └─root / +│ └─home /home +│ └─lib /var/lib +│ └─log /var/log +│ └─store /nix/store +└─nvme0n1p + └─luksswap # encrypted swap partition + ``` ### nuc diff --git a/hosts/thinkpad/default.nix b/hosts/thinkpad/default.nix index de15180..123a46e 100755 --- a/hosts/thinkpad/default.nix +++ b/hosts/thinkpad/default.nix @@ -108,6 +108,15 @@ user = "libvirtd"; }; }; + + services.logind = { + lidSwitch = "suspend-then-hibernate"; + lidSwitchDocked = "hybrid-sleep"; + lidSwitchExternalPower = "suspend"; + }; + systemd.sleep.extraConfig = '' + HibernateDelaySec=1h + ''; environment.systemPackages = with pkgs; [ wget diff --git a/hosts/thinkpad/hardware-configuration.nix b/hosts/thinkpad/hardware-configuration.nix index 023b8be..97c0efa 100644 --- a/hosts/thinkpad/hardware-configuration.nix +++ b/hosts/thinkpad/hardware-configuration.nix @@ -18,6 +18,9 @@ device = "/dev/disk/by-uuid/6b89181c-71e0-4e84-8523-2456d3e28400"; allowDiscards = true; }; + boot.initrd.luks.devices."luksswap" = { + device = "/dev/disk/by-uuid/4a5fd2d9-1b37-4895-a24b-835a9cd4063e"; + }; fileSystems."/" = { @@ -61,7 +64,9 @@ fsType = "vfat"; }; - swapDevices = [ ]; + swapDevices = + [{ device = "/dev/disk/by-uuid/1dd20f07-877c-4ee5-bef5-5e8c6ebe7927"; }]; + boot.resumeDevice = "/dev/disk/by-uuid/1dd20f07-877c-4ee5-bef5-5e8c6ebe7927"; # 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