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
|
|
|
|
2022-11-27 09:42:12 +00:00
|
|
|
stdenv.mkDerivation (finalAttrs: {
|
2020-04-24 23:36:52 +00:00
|
|
|
pname = "nnn";
|
2022-11-27 09:42:12 +00:00
|
|
|
version = "4.7";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "jarun";
|
2022-11-27 09:42:12 +00:00
|
|
|
repo = "nnn";
|
|
|
|
rev = "v${finalAttrs.version}";
|
|
|
|
hash = "sha256-ttG0aEqMlNyJaMhcVfrxbxlrhr1GSydrV58CYSq4CTM=";
|
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);
|
2022-11-27 09:42:12 +00:00
|
|
|
preBuild = lib.optionalString (conf != null) "cp ${finalAttrs.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;
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isMusl "-I${musl-fts}/include";
|
2022-09-09 14:08:57 +00:00
|
|
|
NIX_LDFLAGS = lib.optionalString stdenv.hostPlatform.isMusl "-lfts";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2022-11-27 09:42:12 +00:00
|
|
|
makeFlags = [ "PREFIX=$(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
|
|
|
};
|
2022-11-27 09:42:12 +00:00
|
|
|
})
|