nixpkgs icon indicating copy to clipboard operation
nixpkgs copied to clipboard

nixos/zswap: init module

Open luochen1990 opened this issue 1 week ago • 3 comments

Add zswap support for NixOS!

Things done

  • Built on platform:
    • [x] x86_64-linux
    • [ ] aarch64-linux
    • [ ] x86_64-darwin
    • [ ] aarch64-darwin
  • Tested, as applicable:
  • [ ] Ran nixpkgs-review on this PR. See nixpkgs-review usage.
  • [ ] Tested basic functionality of all binary files, usually in ./result/bin/.
  • Nixpkgs Release Notes
    • [ ] Package update: when the change is major or breaking.
  • NixOS Release Notes
    • [x] Module addition: when adding a new NixOS module.
    • [ ] Module update: when the change is significant.
  • [ ] Fits CONTRIBUTING.md, pkgs/README.md, maintainers/README.md and other READMEs.

Add a :+1: reaction to pull requests you find important.

luochen1990 avatar Dec 13 '25 07:12 luochen1990

Maybe more flexible via sysfs interface? E.g.

https://github.com/merrkry/decalratia/blob/03a35e1330d62e3765aa02e51af64ec6b5af3e81/modules/nixos/zswap.nix#L67-L78

Edit: since we have now boot.kernel.sysfs, it is more preferred.

merrkry avatar Dec 13 '25 09:12 merrkry

Maybe more flexible via sysfs interface? E.g.

https://github.com/merrkry/decalratia/blob/03a35e1330d62e3765aa02e51af64ec6b5af3e81/modules/nixos/zswap.nix#L67-L78

Edit: since we have now boot.kernel.sysfs, it is more preferred.

Good suggestion. I will add a activationScripts (use sysfs) to support runtime switch.

luochen1990 avatar Dec 13 '25 12:12 luochen1990

Seems like the main functional benefits of this is making sure the correct compressor is initialized and a more user friendly, less error prone module interface even if it is essentially a wrapper around the sysfs module.

@luochen1990 if you want some inspiration for writing tests for this module, you can look at my defunct pr for adding zswap prior to deciding to create a sysfs module: https://github.com/NixOS/nixpkgs/pull/401335/files#diff-63fa3c8534f428c4303388194910376a071ff01ed7be6f2c057ae83f2f50f3f8

pigsinablanket avatar Dec 13 '25 18:12 pigsinablanket