Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/systemd: Add suspend-then-hibernate #58404

Closed

Conversation

Semptic
Copy link

@Semptic Semptic commented Mar 26, 2019

This is a duplicate of #53025, but also adds the according settings of sleep.conf.

Motivation for this change

This pr enables nixos to use suspend-then-hibernate.
This adds suspend-then-hibernate systemd service/target and
also adds the according settings for sleep.conf.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

Sorry, something went wrong.

@Semptic Semptic requested a review from infinisil as a code owner March 26, 2019 20:49
@GrahamcOfBorg GrahamcOfBorg added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 labels Mar 26, 2019
@flokli
Copy link
Contributor

flokli commented Mar 26, 2019

@Semptic out of interest, does hibernation work with encrypted swap devices?

@@ -673,6 +675,28 @@ in
'';
};

services.sleep.hibernateDelaySec = mkOption {
default = 3600;
type = types.int;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
type = types.int;
type = with types; nullOr int;

and default = null, and appropriate config to NOT enable hibernate when hibernateDelaySec == null . It is a bad idea to enable suspend-then-hibernate for all, because not everyone has enough swap to manage hibernate.

Copy link
Author

@Semptic Semptic Mar 27, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if we really need this. As I understand the docs you must call systemctl suspend-then-hibernate explicitly to get the hibernation. Suspend will still just supend and never got to hibernate.

@danbst
Copy link
Contributor

danbst commented Mar 26, 2019

My another objection is that services.sleep.hibernateDelaySec seems to be in wrong place, and has wrong namespace. Maybe something like powerManagement.suspendHibernateDelaySec (how to shorten this name?)

  services.sleep.extraConfig = mkIf (config,powerManagement.suspendHibernateDelaySec != null) ''
    HibernateDelaySec=${toString config.powerManagement.suspendHibernateDelaySec}
  '';

The services.sleep.extraConfig seems to be in correct place.

I look forward for this PR, as I was once interested in this feature!

This commit enables nixos to use suspend-then-hibernate.
This adds suspend-then-hibernate systemd service/target and
also adds the according settings for sleep.conf.
@Semptic Semptic force-pushed the systemd-add-suspend-then-hibernate branch from 1774fc6 to 3cd3c26 Compare March 29, 2019 09:47
@Semptic Semptic closed this Oct 2, 2019
@flokli
Copy link
Contributor

flokli commented Oct 12, 2019

Is there a reason this PR was closed?

@Janik-Haag Janik-Haag added the 12. first-time contribution This PR is the author's first one; please be gentle! label Jun 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin 10.rebuild-linux: 1-10 12. first-time contribution This PR is the author's first one; please be gentle!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants