From de40b08d067f88895ca0b89858e338f52d4a04f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20B=C3=A4dorf?= Date: Wed, 24 Aug 2022 18:43:11 +0200 Subject: [PATCH] Fix hibernation The resumeDevice and kernel `resume` parameter were being used wrong. Only `boot.resumeDevice` is necessary, and it should point at the _block device_ that holds the swapfile. If you are running on encrypted volumes, this means you will need to use the name of the *decrypted block device* on which the swapfile sits. --- modules/core/hibernation.nix | 9 +++------ modules/sway/config/config.d/mode_system.conf.nix | 2 +- modules/sway/default.nix | 2 +- 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/modules/core/hibernation.nix b/modules/core/hibernation.nix index c0e912f..0454d82 100644 --- a/modules/core/hibernation.nix +++ b/modules/core/hibernation.nix @@ -13,7 +13,7 @@ in resumeDevice = mkOption { type = types.str; - default = "/swapfile"; + default = "/dev/sda1"; description = "The location of the hibernation resume swap file."; }; @@ -27,12 +27,9 @@ in config = { boot = mkIf cfg.enable { resumeDevice = cfg.resumeDevice; - kernelParams = [ - "resume=${cfg.resumeDevice}" - ] ++ ( + kernelParams = if (cfg.resumeOffset == null && cfg.enable) then builtins.abort "config.pub-solar.resumeOffset has to be set if config.pub-solar.enable is true." - else [ "resume_offset=${cfg.resumeOffset}" ] - ); + else [ "resume_offset=${builtins.toString cfg.resumeOffset}" ]; }; }; } diff --git a/modules/sway/config/config.d/mode_system.conf.nix b/modules/sway/config/config.d/mode_system.conf.nix index c505a9f..f34ecc5 100644 --- a/modules/sway/config/config.d/mode_system.conf.nix +++ b/modules/sway/config/config.d/mode_system.conf.nix @@ -4,7 +4,7 @@ bindsym $mod+0 mode "$mode_system" mode "$mode_system" { bindsym e exec swaymsg exit, mode "default" -'' + (if !psCfg.core.hibernation.enable then '' +'' + (if psCfg.core.hibernation.enable then '' bindsym h exec systemctl hibernate, mode "default" '' else "") + (if !psCfg.paranoia.enable then '' diff --git a/modules/sway/default.nix b/modules/sway/default.nix index 7ef5560..b237c52 100644 --- a/modules/sway/default.nix +++ b/modules/sway/default.nix @@ -95,7 +95,7 @@ in systemd.user.services.waybar = import ./waybar.service.nix { inherit pkgs psCfg; }; systemd.user.targets.sway-session = import ./sway-session.target.nix { inherit pkgs psCfg; }; - systemd.user.services.wayvnc = mkIf cfg.vnc.enable (import ./wayvnc.service.nix pkgs); + systemd.user.services.wayvnc = mkIf psCfg.sway.vnc.enable (import ./wayvnc.service.nix pkgs); xdg.configFile."sway/config".text = import ./config/config.nix { inherit config pkgs; }; xdg.configFile."sway/config.d/colorscheme.conf".source = ./config/config.d/colorscheme.conf;