diff --git a/third_party/nixpkgs/copy.bara.sky b/third_party/nixpkgs/copy.bara.sky index 28491a3158..5b74d8e769 100644 --- a/third_party/nixpkgs/copy.bara.sky +++ b/third_party/nixpkgs/copy.bara.sky @@ -15,7 +15,9 @@ core.workflow( ]), authoring = authoring.pass_thru("Default email "), transformations = [ - patch.apply(patches = []), + patch.apply(patches = [ + "patches/0002-zram-allow-memorymax.patch", + ]), core.move("", "third_party/nixpkgs"), ], ) diff --git a/third_party/nixpkgs/patches/0002-zram-allow-memorymax.patch b/third_party/nixpkgs/patches/0002-zram-allow-memorymax.patch new file mode 100644 index 0000000000..8a98a82994 --- /dev/null +++ b/third_party/nixpkgs/patches/0002-zram-allow-memorymax.patch @@ -0,0 +1,33 @@ +diff --git a/nixos/modules/config/zram.nix b/nixos/modules/config/zram.nix +--- a/nixos/modules/config/zram.nix ++++ b/nixos/modules/config/zram.nix +@@ -80,6 +80,15 @@ in + ''; + }; + ++ memoryMax = mkOption { ++ default = null; ++ type = with types; nullOr int; ++ description = '' ++ Maximum total amount of memory (in bytes) that can be used by the zram ++ swap devices. ++ ''; ++ }; ++ + priority = mkOption { + default = 5; + type = types.int; +@@ -146,7 +155,12 @@ in + + # Calculate memory to use for zram + mem=$(${pkgs.gawk}/bin/awk '/MemTotal: / { +- print int($2*${toString cfg.memoryPercent}/100.0/${toString devicesCount}*1024) ++ value=int($2*${toString cfg.memoryPercent}/100.0/${toString devicesCount}*1024); ++ ${if cfg.memoryMax != null then '' ++ memory_max=int(${toString cfg.memoryMax}/${toString devicesCount}); ++ if (value > memory_max) { value = memory_max } ++ '' else ""} ++ print value + }' /proc/meminfo) + + ${pkgs.utillinux}/sbin/zramctl --size $mem --algorithm ${cfg.algorithm} /dev/${dev}