diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index 11786550630d7..6fdd8e8ffc7e3 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -577,6 +577,7 @@
   ./services/matrix/pantalaimon.nix
   ./services/matrix/synapse.nix
   ./services/misc/airsonic.nix
+  ./services/misc/adaptivemm.nix
   ./services/misc/ananicy.nix
   ./services/misc/ankisyncd.nix
   ./services/misc/apache-kafka.nix
diff --git a/nixos/modules/services/misc/adaptivemm.nix b/nixos/modules/services/misc/adaptivemm.nix
new file mode 100644
index 0000000000000..dfaa3daf36621
--- /dev/null
+++ b/nixos/modules/services/misc/adaptivemm.nix
@@ -0,0 +1,86 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+  cfg = config.services.adaptivemm;
+in {
+  options = {
+    services.adaptivemm = {
+      enable = mkEnableOption (lib.mdDoc "Proactively tune kernel free memory configuration");
+
+      package = mkOption {
+        type = types.package;
+        default = pkgs.adaptivemm;
+        defaultText = literalExpression "pkgs.adaptivemm";
+        description = lib.mdDoc ''
+          Which adaptivemm package to use.
+        '';
+      };
+
+      verbosity = mkOption {
+        type = types.int;
+        default = 0;
+        defaultText = literalExpression "0";
+        description = lib.mdDoc ''
+          Verbosity, from 0 to 5.
+        '';
+      };
+
+      maxWatermarkGap = mkOption {
+        type = types.int;
+        default = 5;
+        defaultText = literalExpression "5";
+        description = lib.mdDoc ''
+          Maximum allowed gap between high and low watermarks in GB.
+        '';
+      };
+
+      aggressiveness = mkOption {
+        type = types.int;
+        default = 2;
+        defaultText = literalExpression "2";
+        description = lib.mdDoc ''
+          Aggressiveness level (1=high, 2=normal, 3=low).
+        '';
+      };
+    };
+  };
+
+  config = mkIf cfg.enable {
+    environment = {
+      systemPackages = [ cfg.package ];
+      etc."sysconfig/adaptivemmd".source = "${cfg.package}/etc/sysconfig/adaptivemmd";
+    };
+
+    systemd.services.adaptivemmd = {
+      serviceConfig = {
+        Type = "forking";
+        EnvironmentFile = "/etc/sysconfig/adaptivemmd";
+        ExecStart = let
+          verboseFlag = assert (cfg.verbosity >= 0 && cfg.verbosity <= 5);
+            if cfg.verbosity == 0 then ""
+            else lib.concatStrings (["-"] ++ (lib.replicate cfg.verbosity "v"));
+          aggressivenessFlag = assert (cfg.aggressiveness >= 1 && cfg.aggressiveness <= 3);
+            "-a ${builtins.toString cfg.aggressiveness}";
+          gapFlag = "-m ${builtins.toString cfg.maxWatermarkGap}";
+        in "${cfg.package}/bin/adaptivemmd ${verboseFlag} ${aggressivenessFlag} ${gapFlag}";
+        KillMode = "control-group";
+        Restart = "on-failure";
+        RestartSec = "10s";
+      };
+
+      unitConfig = {
+        Description = "Adaptive free memory optimizer daemon";
+        Documentation = "man:adaptivemmd(8)";
+        After = [ "systemd-sysctl.service" "local-fs.target" ];
+      };
+
+      wantedBy = [ "multi-user.target" ];
+    };
+  };
+
+  meta = {
+    maintainers = with maintainers; [ cmm ];
+  };
+}
diff --git a/pkgs/os-specific/linux/adaptivemm/default.nix b/pkgs/os-specific/linux/adaptivemm/default.nix
new file mode 100644
index 0000000000000..ecc9a80336e05
--- /dev/null
+++ b/pkgs/os-specific/linux/adaptivemm/default.nix
@@ -0,0 +1,31 @@
+{ lib, stdenv, fetchFromGitHub }:
+
+let
+  pname = "adaptivemm";
+in stdenv.mkDerivation {
+  inherit pname;
+  version = "unstable-2023-01-16";
+
+  src = fetchFromGitHub {
+    owner = "oracle";
+    repo = pname;
+    rev = "92f7d6e9155e153db884ebb7da25c0a9cbcb29fe";
+    hash = "sha256-3aRfHn0HV9CfcLulDimHsMJPs8/VAWRVDxPijKVhtDM=";
+  };
+
+  CFLAGS = "-I. -Wall -O2";
+
+  installPhase = ''
+    mkdir -p $out/bin $out/etc/sysconfig $out/share/man/man8
+    cp adaptivemmd $out/bin/
+    cp $src/adaptivemmd.cfg $out/etc/sysconfig/adaptivemmd
+    cp $src/adaptivemmd.8 $out/share/man/man8/
+  '';
+
+  meta = with lib; {
+    description = "A userspace daemon for proactive free memory management";
+    license = licenses.gpl2;
+    platforms = platforms.linux;
+    maintainers = with maintainers; [ cmm ];
+  };
+}
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index 87d8c2f24e449..88a45fc36b626 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -26125,6 +26125,8 @@ with pkgs;
 
   acpitool = callPackage ../os-specific/linux/acpitool { };
 
+  adaptivemm = callPackage ../os-specific/linux/adaptivemm { };
+
   alfred = callPackage ../os-specific/linux/batman-adv/alfred.nix { };
 
   alertmanager-bot = callPackage ../servers/monitoring/alertmanager-bot { };