mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-12-29 06:45:54 +03:00
nixos/zram: use nixos/zram-generator as backing implementation
This commit is contained in:
parent
a7e095d9fd
commit
0814089e05
@ -105,36 +105,25 @@ in
|
||||
}
|
||||
];
|
||||
|
||||
services.zram-generator.enable = true;
|
||||
|
||||
system.requiredKernelConfig = with config.lib.kernelConfig; [
|
||||
(isModule "ZRAM")
|
||||
];
|
||||
|
||||
# Disabling this for the moment, as it would create and mkswap devices twice,
|
||||
# once in stage 2 boot, and again when the zram-reloader service starts.
|
||||
# boot.kernelModules = [ "zram" ];
|
||||
|
||||
systemd.packages = [ pkgs.zram-generator ];
|
||||
systemd.services."systemd-zram-setup@".path = [ pkgs.util-linux ]; # for mkswap
|
||||
|
||||
environment.etc."systemd/zram-generator.conf".source =
|
||||
(pkgs.formats.ini { }).generate "zram-generator.conf" (lib.listToAttrs
|
||||
(builtins.map
|
||||
(dev: {
|
||||
name = dev;
|
||||
value =
|
||||
let
|
||||
size = "${toString cfg.memoryPercent} / 100 * ram";
|
||||
in
|
||||
{
|
||||
zram-size = if cfg.memoryMax != null then "min(${size}, ${toString cfg.memoryMax} / 1024 / 1024)" else size;
|
||||
compression-algorithm = cfg.algorithm;
|
||||
swap-priority = cfg.priority;
|
||||
} // lib.optionalAttrs (cfg.writebackDevice != null) {
|
||||
writeback-device = cfg.writebackDevice;
|
||||
};
|
||||
})
|
||||
devices));
|
||||
services.zram-generator.settings = lib.listToAttrs
|
||||
(builtins.map
|
||||
(dev: {
|
||||
name = dev;
|
||||
value =
|
||||
let
|
||||
size = "${toString cfg.memoryPercent} / 100 * ram";
|
||||
in
|
||||
{
|
||||
zram-size = if cfg.memoryMax != null then "min(${size}, ${toString cfg.memoryMax} / 1024 / 1024)" else size;
|
||||
compression-algorithm = cfg.algorithm;
|
||||
swap-priority = cfg.priority;
|
||||
} // lib.optionalAttrs (cfg.writebackDevice != null) {
|
||||
writeback-device = cfg.writebackDevice;
|
||||
};
|
||||
})
|
||||
devices);
|
||||
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user