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 }: 1 + { 2 + lib, 3 + fetchFromGitHub, 4 + installShellFiles, 5 + pandoc, 6 + stdenv, 7 + nixosTests, 8 + # Boolean flags 9 + withManpage ? true, 10 + }: 2 11 3 - stdenv.mkDerivation rec { 12 + stdenv.mkDerivation (finalAttrs: { 4 13 pname = "earlyoom"; 5 14 version = "1.7"; 6 15 7 16 src = fetchFromGitHub { 8 17 owner = "rfjakob"; 9 18 repo = "earlyoom"; 10 - rev = "v${version}"; 11 - sha256 = "sha256-8YcT1TTlAet7F1U9Ginda4IApNqkudegOXqm8rnRGfc="; 19 + rev = "v${finalAttrs.version}"; 20 + hash = "sha256-8YcT1TTlAet7F1U9Ginda4IApNqkudegOXqm8rnRGfc="; 12 21 }; 13 22 14 - nativeBuildInputs = lib.optionals withManpage [ pandoc installShellFiles ]; 23 + outputs = [ "out" ] ++ lib.optionals withManpage [ "man" ]; 15 24 16 - patches = [ ./fix-dbus-path.patch ]; 25 + patches = [ ./0000-fix-dbus-path.patch ]; 17 26 18 - makeFlags = [ "VERSION=${version}" ]; 27 + nativeBuildInputs = lib.optionals withManpage [ 28 + installShellFiles 29 + pandoc 30 + ]; 31 + 32 + makeFlags = [ 33 + "VERSION=${finalAttrs.version}" 34 + ]; 19 35 20 36 installPhase = '' 37 + runHook preInstall 21 38 install -D earlyoom $out/bin/earlyoom 22 39 '' + lib.optionalString withManpage '' 23 40 installManPage earlyoom.1 41 + '' + '' 42 + runHook postInstall 24 43 ''; 25 44 26 45 passthru.tests = { 27 46 inherit (nixosTests) earlyoom; 28 47 }; 29 48 30 - meta = with lib; { 49 + meta = { 50 + homepage = "https://github.com/rfjakob/earlyoom"; 31 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; 32 60 mainProgram = "earlyoom"; 33 - homepage = "https://github.com/rfjakob/earlyoom"; 34 - license = licenses.mit; 35 - platforms = platforms.linux; 36 - maintainers = with maintainers; []; 61 + maintainers = with lib.maintainers; [ AndersonTorres ]; 62 + platforms = lib.platforms.linux; 37 63 }; 38 - } 64 + })