1 { config, lib, pkgs, ... }:
3 cfg = config.services.zram-generator;
4 settingsFormat = pkgs.formats.ini { };
8 maintainers = with lib.maintainers; [ nickcao ];
11 options.services.zram-generator = {
12 enable = lib.mkEnableOption "Systemd unit generator for zram devices";
14 package = lib.mkPackageOption pkgs "zram-generator" { };
16 settings = lib.mkOption {
17 type = lib.types.submodule {
18 freeformType = settingsFormat.type;
22 Configuration for zram-generator,
23 see https://github.com/systemd/zram-generator for documentation.
28 config = lib.mkIf cfg.enable {
29 system.requiredKernelConfig = with config.lib.kernelConfig; [
33 systemd.packages = [ cfg.package ];
34 systemd.services."systemd-zram-setup@".path = [ pkgs.util-linux ]; # for mkswap
36 environment.etc."systemd/zram-generator.conf".source = settingsFormat.generate "zram-generator.conf" cfg.settings;