From 209d2c5314293fe779f5aa0b31ed91931c4e9496 Mon Sep 17 00:00:00 2001 From: Thiago Kenji Okada Date: Tue, 19 Jan 2021 22:38:57 -0300 Subject: [PATCH] nnn: add withIcon/withNerdIcon options This allows nnn to be build with either Terminal icons or Nerd Fonts icons support. --- pkgs/applications/misc/nnn/default.nix | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/pkgs/applications/misc/nnn/default.nix b/pkgs/applications/misc/nnn/default.nix index 4c36b3d930f1..4a72eecf9b37 100644 --- a/pkgs/applications/misc/nnn/default.nix +++ b/pkgs/applications/misc/nnn/default.nix @@ -1,6 +1,9 @@ -{ lib, stdenv, fetchFromGitHub, pkg-config, ncurses, readline, conf ? null }: +{ lib, stdenv, fetchFromGitHub, pkg-config, ncurses, readline +, conf ? null, withIcons ? false, withNerdIcons ? false }: -with lib; +# Mutually exclusive options +assert withIcons -> withNerdIcons == false; +assert withNerdIcons -> withIcons == false; stdenv.mkDerivation rec { pname = "nnn"; @@ -13,13 +16,17 @@ stdenv.mkDerivation rec { sha256 = "1fa7cmwrzn6kx87kms8i98p9azdlwyh2gnif29l340syl9hkr5qy"; }; - configFile = optionalString (conf != null) (builtins.toFile "nnn.h" conf); - preBuild = optionalString (conf != null) "cp ${configFile} src/nnn.h"; + configFile = lib.optionalString (conf != null) (builtins.toFile "nnn.h" conf); + preBuild = lib.optionalString (conf != null) "cp ${configFile} src/nnn.h"; nativeBuildInputs = [ pkg-config ]; buildInputs = [ readline ncurses ]; - makeFlags = [ "DESTDIR=${placeholder "out"}" "PREFIX=" ]; + makeFlags = [ + "DESTDIR=${placeholder "out"}" + "PREFIX=" + ] ++ lib.optional withIcons [ "O_ICONS=1" ] + ++ lib.optional withNerdIcons [ "O_NERD=1" ]; # shell completions postInstall = '' @@ -28,7 +35,7 @@ stdenv.mkDerivation rec { install -Dm555 misc/auto-completion/fish/nnn.fish -t $out/share/fish/vendor_completions.d ''; - meta = { + meta = with lib; { description = "Small ncurses-based file browser forked from noice"; homepage = "https://github.com/jarun/nnn"; license = licenses.bsd2;