earlyoom: refactor and adopt

- rewrite input argset
- finalAttrs
- split outputs
- runHooks everywhere
- get rid of nested with
- meta.longDescription

+39 -13
pkgs/by-name/ea/earlyoom/fix-dbus-path.patch pkgs/by-name/ea/earlyoom/0000-fix-dbus-path.patch
+39 -13
pkgs/by-name/ea/earlyoom/package.nix
··· 1 - { lib, stdenv, fetchFromGitHub, pandoc, installShellFiles, withManpage ? false, nixosTests }: 2 3 - stdenv.mkDerivation rec { 4 pname = "earlyoom"; 5 version = "1.7"; 6 7 src = fetchFromGitHub { 8 owner = "rfjakob"; 9 repo = "earlyoom"; 10 - rev = "v${version}"; 11 - sha256 = "sha256-8YcT1TTlAet7F1U9Ginda4IApNqkudegOXqm8rnRGfc="; 12 }; 13 14 - nativeBuildInputs = lib.optionals withManpage [ pandoc installShellFiles ]; 15 16 - patches = [ ./fix-dbus-path.patch ]; 17 18 - makeFlags = [ "VERSION=${version}" ]; 19 20 installPhase = '' 21 install -D earlyoom $out/bin/earlyoom 22 '' + lib.optionalString withManpage '' 23 installManPage earlyoom.1 24 ''; 25 26 passthru.tests = { 27 inherit (nixosTests) earlyoom; 28 }; 29 30 - meta = with lib; { 31 description = "Early OOM Daemon for Linux"; 32 mainProgram = "earlyoom"; 33 - homepage = "https://github.com/rfjakob/earlyoom"; 34 - license = licenses.mit; 35 - platforms = platforms.linux; 36 - maintainers = with maintainers; []; 37 }; 38 - }
··· 1 + { 2 + lib, 3 + fetchFromGitHub, 4 + installShellFiles, 5 + pandoc, 6 + stdenv, 7 + nixosTests, 8 + # Boolean flags 9 + withManpage ? true, 10 + }: 11 12 + stdenv.mkDerivation (finalAttrs: { 13 pname = "earlyoom"; 14 version = "1.7"; 15 16 src = fetchFromGitHub { 17 owner = "rfjakob"; 18 repo = "earlyoom"; 19 + rev = "v${finalAttrs.version}"; 20 + hash = "sha256-8YcT1TTlAet7F1U9Ginda4IApNqkudegOXqm8rnRGfc="; 21 }; 22 23 + outputs = [ "out" ] ++ lib.optionals withManpage [ "man" ]; 24 25 + patches = [ ./0000-fix-dbus-path.patch ]; 26 27 + nativeBuildInputs = lib.optionals withManpage [ 28 + installShellFiles 29 + pandoc 30 + ]; 31 + 32 + makeFlags = [ 33 + "VERSION=${finalAttrs.version}" 34 + ]; 35 36 installPhase = '' 37 + runHook preInstall 38 install -D earlyoom $out/bin/earlyoom 39 '' + lib.optionalString withManpage '' 40 installManPage earlyoom.1 41 + '' + '' 42 + runHook postInstall 43 ''; 44 45 passthru.tests = { 46 inherit (nixosTests) earlyoom; 47 }; 48 49 + meta = { 50 + homepage = "https://github.com/rfjakob/earlyoom"; 51 description = "Early OOM Daemon for Linux"; 52 + longDescription = '' 53 + earlyoom checks the amount of available memory and free swap up to 10 54 + times a second (less often if there is a lot of free memory). By default 55 + if both are below 10%, it will kill the largest process (highest 56 + oom_score). The percentage value is configurable via command line 57 + arguments. 58 + ''; 59 + license = lib.licenses.mit; 60 mainProgram = "earlyoom"; 61 + maintainers = with lib.maintainers; [ AndersonTorres ]; 62 + platforms = lib.platforms.linux; 63 }; 64 + })