2021-04-22 02:08:21 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
|
|
|
, installShellFiles
|
|
|
|
, makeWrapper
|
|
|
|
, pkg-config
|
|
|
|
, file
|
|
|
|
, ncurses
|
|
|
|
, readline
|
|
|
|
, which
|
2022-09-09 14:08:57 +00:00
|
|
|
, musl-fts
|
2021-04-22 02:08:21 +00:00
|
|
|
# options
|
|
|
|
, conf ? null
|
|
|
|
, withIcons ? false
|
|
|
|
, withNerdIcons ? false
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
# Mutually exclusive options
|
|
|
|
assert withIcons -> withNerdIcons == false;
|
|
|
|
assert withNerdIcons -> withIcons == false;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "nnn";
|
2022-08-12 12:06:08 +00:00
|
|
|
version = "4.6";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "jarun";
|
|
|
|
repo = pname;
|
|
|
|
rev = "v${version}";
|
2022-08-12 12:06:08 +00:00
|
|
|
sha256 = "sha256-+EAKOXZp1kxA2X3e16ItjPT7Sa3WZuP2oxOdXkceTIY=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
configFile = lib.optionalString (conf != null) (builtins.toFile "nnn.h" conf);
|
|
|
|
preBuild = lib.optionalString (conf != null) "cp ${configFile} src/nnn.h";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-04-22 02:08:21 +00:00
|
|
|
nativeBuildInputs = [ installShellFiles makeWrapper pkg-config ];
|
2022-09-09 14:08:57 +00:00
|
|
|
buildInputs = [ readline ncurses ] ++ lib.optional stdenv.hostPlatform.isMusl musl-fts;
|
|
|
|
|
|
|
|
NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isMusl "-I${musl-fts}/include";
|
|
|
|
NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isMusl "-lfts";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-04-22 02:08:21 +00:00
|
|
|
makeFlags = [ "PREFIX=${placeholder "out"}" ]
|
2022-10-30 15:09:59 +00:00
|
|
|
++ lib.optionals withIcons [ "O_ICONS=1" ]
|
|
|
|
++ lib.optionals withNerdIcons [ "O_NERD=1" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-04-22 02:08:21 +00:00
|
|
|
binPath = lib.makeBinPath [ file which ];
|
|
|
|
|
2020-04-24 23:36:52 +00:00
|
|
|
postInstall = ''
|
2021-04-22 02:08:21 +00:00
|
|
|
installShellCompletion --bash --name nnn.bash misc/auto-completion/bash/nnn-completion.bash
|
|
|
|
installShellCompletion --fish misc/auto-completion/fish/nnn.fish
|
|
|
|
installShellCompletion --zsh misc/auto-completion/zsh/_nnn
|
2021-04-17 00:35:05 +00:00
|
|
|
|
2021-04-22 02:08:21 +00:00
|
|
|
wrapProgram $out/bin/nnn --prefix PATH : "$binPath"
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Small ncurses-based file browser forked from noice";
|
|
|
|
homepage = "https://github.com/jarun/nnn";
|
2021-03-19 17:17:44 +00:00
|
|
|
changelog = "https://github.com/jarun/nnn/blob/v${version}/CHANGELOG";
|
2020-04-24 23:36:52 +00:00
|
|
|
license = licenses.bsd2;
|
|
|
|
platforms = platforms.all;
|
2020-11-19 00:13:47 +00:00
|
|
|
maintainers = with maintainers; [ jfrankenau Br1ght0ne ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
}
|