From 1675f40ec382e2e3042d877b616da51c146bd969 Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Tue, 21 Nov 2023 10:14:58 -0600 Subject: [PATCH] Enable hibernation on thinker --- modules/home-manager/foxtrot.nix | 8 +++++--- modules/home-manager/thinker.nix | 1 + nixos/foxtrot/default.nix | 15 +++++++++++++-- nixos/thinker/default.nix | 32 ++++++++++++++++++++++++++------ 4 files changed, 45 insertions(+), 11 deletions(-) diff --git a/modules/home-manager/foxtrot.nix b/modules/home-manager/foxtrot.nix index 1827cb6..f25264a 100644 --- a/modules/home-manager/foxtrot.nix +++ b/modules/home-manager/foxtrot.nix @@ -1,4 +1,6 @@ -{outputs, ...}: { +{outputs, ...}: let + scale = 1.5; +in { imports = with outputs.homeManagerModules; [ sway sway-laptop @@ -9,7 +11,7 @@ settings = { # See https://wiki.hyprland.org/Configuring/Keywords/ for more monitor = [ - "eDP-1,2256x1504@60,0x0,1.5" + "eDP-1,2256x1504@60,0x0,${toString scale}" ]; }; }; @@ -19,7 +21,7 @@ output = { "BOE 0x0BCA Unknown" = { mode = "2256x1504@60Hz"; - scale = "1.25"; + scale = toString scale; }; }; }; diff --git a/modules/home-manager/thinker.nix b/modules/home-manager/thinker.nix index e32aa73..0d4ac30 100644 --- a/modules/home-manager/thinker.nix +++ b/modules/home-manager/thinker.nix @@ -2,5 +2,6 @@ imports = with outputs.homeManagerModules; [ sway sway-laptop + hyprland ]; } diff --git a/nixos/foxtrot/default.nix b/nixos/foxtrot/default.nix index 4b47e44..9d6dc9d 100644 --- a/nixos/foxtrot/default.nix +++ b/nixos/foxtrot/default.nix @@ -26,6 +26,17 @@ # TODO: hibernation? does sleep suffice? + services.fwupd.enable = true; + services.fwupd.extraRemotes = ["lvfs-testing"]; + + hardware.opengl.extraPackages = [ + pkgs.rocmPackages.clr.icd + pkgs.amdvlk + # encoding/decoding acceleration + pkgs.libvdpau-va-gl + pkgs.vaapiVdpau + ]; + hardware.wirelessRegulatoryDatabase = true; boot = { @@ -38,8 +49,8 @@ kernelParams = [ "amdgpu.sg_display=0" "acpi_osi=\"!Windows 2020\"" - # "nvme.noacpi=1" # maybe causing crashes? - "rtc_cmos.use_acpi_alarm=1" + # "nvme.noacpi=1" # maybe causing crashes upon waking? + # "rtc_cmos.use_acpi_alarm=1" # maybe causing excessive battery drain while sleeping -- perhaps due to waking? ]; initrd.availableKernelModules = ["xhci_pci" "nvme" "thunderbolt"]; kernelModules = ["kvm-amd"]; diff --git a/nixos/thinker/default.nix b/nixos/thinker/default.nix index e452dbc..8acf751 100644 --- a/nixos/thinker/default.nix +++ b/nixos/thinker/default.nix @@ -9,6 +9,27 @@ }: { networking.hostName = "thinker"; + swapDevices = [ + # TODO: move this to disko? + # sudo btrfs subvolume create /swap + # sudo btrfs filesystem mkswapfile --size 32g --uuid clear /swap/swapfile + # sudo swapon /swap/swapfile + {device = "/swap/swapfile";} + ]; + + # findmnt -no UUID -T /swap/swapfile + boot.resumeDevice = "/dev/disk/by-uuid/aacd6814-a5a2-457a-bf65-8d970cb1f03d"; + + services.logind = { + lidSwitch = "suspend-then-hibernate"; + extraConfig = '' + HandlePowerKey=suspend-then-hibernate + IdleAction=suspend-then-hibernate + IdleActionSec=1m + ''; + }; + systemd.sleep.extraConfig = "HibernateDelaySec=30m"; + imports = [ inputs.disko.nixosModules.disko @@ -26,17 +47,16 @@ # ./relative-module.nix ]; - # TODO: hibernation? I've been using [deep] in /sys/power/mem_sleep alright - # with this machine so it may not be necessary? - # need to measure percentage lost per day, but I think it's around 10%/day - # it looks like I may have had hibernation working -- see ../old/third.nix - boot = { loader = { efi.canTouchEfiVariables = true; systemd-boot.enable = true; }; - kernelParams = ["boot.shell_on_fail"]; + # sudo filefrag -v /swap/swapfile | awk '$1=="0:" {print substr($4, 1, length($4)-2)}' + # the above won't work for btrfs, instead you need + # btrfs inspect-internal map-swapfile -r /swap/swapfile + # https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Hibernation_into_swap_file + kernelParams = ["boot.shell_on_fail" "resume_offset=22816000"]; initrd.availableKernelModules = ["xhci_pci" "nvme" "ahci"]; }; hardware.bluetooth.enable = true;