mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-22 15:03:28 +00:00
Merge pull request #304527 from atorres1985-contrib/earlyoom
earlyoom: 1.7 -> 1.8
This commit is contained in:
commit
20e0c45c7a
@ -4,15 +4,29 @@ let
|
||||
cfg = config.services.earlyoom;
|
||||
|
||||
inherit (lib)
|
||||
mkDefault mkEnableOption mkIf mkOption types
|
||||
mkRemovedOptionModule literalExpression
|
||||
escapeShellArg concatStringsSep optional optionalString;
|
||||
|
||||
concatStringsSep
|
||||
escapeShellArg
|
||||
literalExpression
|
||||
mkDefault
|
||||
mkEnableOption
|
||||
mkIf
|
||||
mkOption
|
||||
mkPackageOption
|
||||
mkRemovedOptionModule
|
||||
optionalString
|
||||
optionals
|
||||
types;
|
||||
in
|
||||
{
|
||||
meta = {
|
||||
maintainers = with lib.maintainers; [ AndersonTorres ];
|
||||
};
|
||||
|
||||
options.services.earlyoom = {
|
||||
enable = mkEnableOption "early out of memory killing";
|
||||
|
||||
package = mkPackageOption pkgs "earlyoom" { };
|
||||
|
||||
freeMemThreshold = mkOption {
|
||||
type = types.ints.between 1 100;
|
||||
default = 10;
|
||||
@ -138,22 +152,21 @@ in
|
||||
systemd.services.earlyoom = {
|
||||
description = "Early OOM Daemon for Linux";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
path = optional cfg.enableNotifications pkgs.dbus;
|
||||
path = optionals cfg.enableNotifications [ pkgs.dbus ];
|
||||
serviceConfig = {
|
||||
StandardError = "journal";
|
||||
ExecStart = concatStringsSep " " ([
|
||||
"${pkgs.earlyoom}/bin/earlyoom"
|
||||
"${lib.getExe cfg.package}"
|
||||
("-m ${toString cfg.freeMemThreshold}"
|
||||
+ optionalString (cfg.freeMemKillThreshold != null) ",${toString cfg.freeMemKillThreshold}")
|
||||
+ optionalString (cfg.freeMemKillThreshold != null) ",${toString cfg.freeMemKillThreshold}")
|
||||
("-s ${toString cfg.freeSwapThreshold}"
|
||||
+ optionalString (cfg.freeSwapKillThreshold != null) ",${toString cfg.freeSwapKillThreshold}")
|
||||
+ optionalString (cfg.freeSwapKillThreshold != null) ",${toString cfg.freeSwapKillThreshold}")
|
||||
"-r ${toString cfg.reportInterval}"
|
||||
]
|
||||
++ optional cfg.enableDebugInfo "-d"
|
||||
++ optional cfg.enableNotifications "-n"
|
||||
++ optional (cfg.killHook != null) "-N ${escapeShellArg cfg.killHook}"
|
||||
++ cfg.extraArgs
|
||||
);
|
||||
++ optionals cfg.enableDebugInfo [ "-d" ]
|
||||
++ optionals cfg.enableNotifications [ "-n" ]
|
||||
++ optionals (cfg.killHook != null) [ "-N ${escapeShellArg cfg.killHook}" ]
|
||||
++ cfg.extraArgs);
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -1,7 +1,7 @@
|
||||
import ./make-test-python.nix ({ lib, ... }: {
|
||||
name = "earlyoom";
|
||||
meta = {
|
||||
maintainers = with lib.maintainers; [ ncfavier ];
|
||||
maintainers = with lib.maintainers; [ ncfavier AndersonTorres ];
|
||||
};
|
||||
|
||||
machine = {
|
||||
|
64
pkgs/by-name/ea/earlyoom/package.nix
Normal file
64
pkgs/by-name/ea/earlyoom/package.nix
Normal file
@ -0,0 +1,64 @@
|
||||
{
|
||||
lib,
|
||||
fetchFromGitHub,
|
||||
installShellFiles,
|
||||
pandoc,
|
||||
stdenv,
|
||||
nixosTests,
|
||||
# Boolean flags
|
||||
withManpage ? true,
|
||||
}:
|
||||
|
||||
stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "earlyoom";
|
||||
version = "1.8";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "rfjakob";
|
||||
repo = "earlyoom";
|
||||
rev = "v${finalAttrs.version}";
|
||||
hash = "sha256-jgNoYOGor2i3ngDuU3It238n5ky+AppzlRKdkwXb2AI=";
|
||||
};
|
||||
|
||||
outputs = [ "out" ] ++ lib.optionals withManpage [ "man" ];
|
||||
|
||||
patches = [ ./0000-fix-dbus-path.patch ];
|
||||
|
||||
nativeBuildInputs = lib.optionals withManpage [
|
||||
installShellFiles
|
||||
pandoc
|
||||
];
|
||||
|
||||
makeFlags = [
|
||||
"VERSION=${finalAttrs.version}"
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
install -D earlyoom $out/bin/earlyoom
|
||||
'' + lib.optionalString withManpage ''
|
||||
installManPage earlyoom.1
|
||||
'' + ''
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru.tests = {
|
||||
inherit (nixosTests) earlyoom;
|
||||
};
|
||||
|
||||
meta = {
|
||||
homepage = "https://github.com/rfjakob/earlyoom";
|
||||
description = "Early OOM Daemon for Linux";
|
||||
longDescription = ''
|
||||
earlyoom checks the amount of available memory and free swap up to 10
|
||||
times a second (less often if there is a lot of free memory). By default
|
||||
if both are below 10%, it will kill the largest process (highest
|
||||
oom_score). The percentage value is configurable via command line
|
||||
arguments.
|
||||
'';
|
||||
license = lib.licenses.mit;
|
||||
mainProgram = "earlyoom";
|
||||
maintainers = with lib.maintainers; [ AndersonTorres ];
|
||||
platforms = lib.platforms.linux;
|
||||
};
|
||||
})
|
@ -1,38 +0,0 @@
|
||||
{ lib, stdenv, fetchFromGitHub, pandoc, installShellFiles, withManpage ? false, nixosTests }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "earlyoom";
|
||||
version = "1.7";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "rfjakob";
|
||||
repo = "earlyoom";
|
||||
rev = "v${version}";
|
||||
sha256 = "sha256-8YcT1TTlAet7F1U9Ginda4IApNqkudegOXqm8rnRGfc=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = lib.optionals withManpage [ pandoc installShellFiles ];
|
||||
|
||||
patches = [ ./fix-dbus-path.patch ];
|
||||
|
||||
makeFlags = [ "VERSION=${version}" ];
|
||||
|
||||
installPhase = ''
|
||||
install -D earlyoom $out/bin/earlyoom
|
||||
'' + lib.optionalString withManpage ''
|
||||
installManPage earlyoom.1
|
||||
'';
|
||||
|
||||
passthru.tests = {
|
||||
inherit (nixosTests) earlyoom;
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
description = "Early OOM Daemon for Linux";
|
||||
mainProgram = "earlyoom";
|
||||
homepage = "https://github.com/rfjakob/earlyoom";
|
||||
license = licenses.mit;
|
||||
platforms = platforms.linux;
|
||||
maintainers = with maintainers; [];
|
||||
};
|
||||
}
|
@ -5130,8 +5130,6 @@ with pkgs;
|
||||
|
||||
earlybird = callPackage ../tools/security/earlybird { };
|
||||
|
||||
earlyoom = callPackage ../os-specific/linux/earlyoom { };
|
||||
|
||||
easyabc = callPackage ../applications/audio/easyabc { };
|
||||
|
||||
easycrypt = callPackage ../applications/science/logic/easycrypt {
|
||||
|
Loading…
Reference in New Issue
Block a user