Skip to content

Conversation

@pigsinablanket
Copy link

@pigsinablanket pigsinablanket commented Apr 24, 2025

Provides a NixOS module for enabling and configuring zswap, a compressed cache for swap pages within the kernel.

Closes #119244.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 25.05 Release Notes (or backporting 24.11 and 25.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: changelog This PR adds or changes release notes 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` 8.has: documentation This PR adds or changes documentation 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Apr 24, 2025
@NixOSInfra NixOSInfra added the 12.first-time contribution This PR is the author's first one; please be gentle! label Apr 24, 2025
Copy link
Contributor

@acid-bong acid-bong left a comment

Choose a reason for hiding this comment

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

And in the end: why making this a systemd script instead of kernel parameters (to start on boot) + activation scripts (to start and stop on rebuild)?

@acid-bong
Copy link
Contributor

Also change addresses to solves/fixes to automatically close the issue (github only recognizes certain words)

@h7x4 h7x4 added 8.has: module (new) This PR adds a module in `nixos/` 8.has: tests This PR has tests labels Apr 24, 2025
@ShamrockLee
Copy link
Contributor

Thank you for addressing #119244.

Considering that we already have boot.kernel.sysctl that provide mapping for each kernel parameters, is it worth the effort to add another module implemented in a similar manner?

@ShamrockLee
Copy link
Contributor

Thank you for addressing #119244.

Considering that we already have boot.kernel.sysctl that provide mapping for each kernel parameters, is it worth the effort to add another module implemented in a similar manner?

I took back what I said about boot.kernel.sysctl. It might not work for zswap. See #119244 (comment) for detail.

@pigsinablanket
Copy link
Author

Thank you for addressing #119244.
Considering that we already have boot.kernel.sysctl that provide mapping for each kernel parameters, is it worth the effort to add another module implemented in a similar manner?

I took back what I said about boot.kernel.sysctl. It might not work for zswap. See #119244 (comment) for detail.

What do you think the path forward is? I see a couple options:

  • Get zswap enabled by default as other linux distros have done.
  • Create a zswap module wrapper around the parameters, which this PR does. This might imply that everything in /sys/module should have a wrapper around it.
  • Do nothing and document it on the wiki on how to configure it via boot.kernelParams https://wiki.nixos.org/wiki/Swap#Zswap_swap_cache.
  • Somehow make a boot.kernel.sysmodule option to set parameters in /sys/module.

@ShamrockLee
Copy link
Contributor

  • Somehow make a boot.kernel.sysmodule option to set parameters in /sys/module.

I second this. Here's a draft PR that implements said module: #402455

@pigsinablanket
Copy link
Author

Closing this PR in favor of a sysmodule config option. See any further discussion here #119244

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: changelog This PR adds or changes release notes 8.has: documentation This PR adds or changes documentation 8.has: maintainer-list (update) This PR changes `maintainers/maintainer-list.nix` 8.has: module (new) This PR adds a module in `nixos/` 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: tests This PR has tests 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 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.

Module request: config.zswap

5 participants