2021-04-22 02:08:21 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
2023-05-24 13:37:59 +00:00
|
|
|
, fetchpatch
|
2021-04-22 02:08:21 +00:00
|
|
|
, installShellFiles
|
|
|
|
, makeWrapper
|
|
|
|
, pkg-config
|
|
|
|
, file
|
|
|
|
, ncurses
|
|
|
|
, readline
|
|
|
|
, which
|
2022-09-09 14:08:57 +00:00
|
|
|
, musl-fts
|
2023-10-09 19:29:22 +00:00
|
|
|
, pcre
|
2023-05-24 13:37:59 +00:00
|
|
|
# options
|
2021-04-22 02:08:21 +00:00
|
|
|
, conf ? null
|
|
|
|
, withIcons ? false
|
|
|
|
, withNerdIcons ? false
|
2023-05-24 13:37:59 +00:00
|
|
|
, withEmojis ? false
|
2023-10-09 19:29:22 +00:00
|
|
|
, withPcre ? false
|
|
|
|
, extraMakeFlags ? [ ]
|
2021-04-22 02:08:21 +00:00
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-02-05 17:12:51 +00:00
|
|
|
# Mutually exclusive options
|
2023-05-24 13:37:59 +00:00
|
|
|
assert withIcons -> (withNerdIcons == false && withEmojis == false);
|
|
|
|
assert withNerdIcons -> (withIcons == false && withEmojis == false);
|
|
|
|
assert withEmojis -> (withIcons == false && withNerdIcons == 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";
|
2023-10-09 19:29:22 +00:00
|
|
|
version = "4.9";
|
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}";
|
2023-10-09 19:29:22 +00:00
|
|
|
hash = "sha256-g19uI36HyzTF2YUQKFP4DE2ZBsArGryVHhX79Y0XzhU=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
patches = [
|
2023-08-04 22:07:22 +00:00
|
|
|
# Nix-specific: ensure nnn passes correct arguments to the Nix file command on Darwin.
|
|
|
|
# By default, nnn expects the macOS default file command, not the one provided by Nix.
|
|
|
|
# However, both commands use different arguments to obtain the MIME type.
|
|
|
|
./darwin-fix-file-mime-opts.patch
|
2023-05-24 13:37:59 +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 ];
|
2023-10-09 19:29:22 +00:00
|
|
|
buildInputs = [ readline ncurses ]
|
|
|
|
++ lib.optional stdenv.hostPlatform.isMusl musl-fts
|
|
|
|
++ lib.optional withPcre pcre;
|
2022-09-09 14:08:57 +00:00
|
|
|
|
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" ]
|
2023-05-24 13:37:59 +00:00
|
|
|
++ lib.optionals withNerdIcons [ "O_NERD=1" ]
|
2023-10-09 19:29:22 +00:00
|
|
|
++ lib.optionals withEmojis [ "O_EMOJI=1" ]
|
|
|
|
++ lib.optionals withPcre [ "O_PCRE=1" ]
|
|
|
|
++ extraMakeFlags;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-04-22 02:08:21 +00:00
|
|
|
binPath = lib.makeBinPath [ file which ];
|
|
|
|
|
2023-05-24 13:37:59 +00:00
|
|
|
installTargets = [ "install" "install-desktop" ];
|
|
|
|
|
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
|
|
|
|
2023-10-09 19:29:22 +00:00
|
|
|
cp -r plugins $out/share
|
|
|
|
cp -r misc/quitcd $out/share/quitcd
|
|
|
|
|
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;
|
2024-01-02 11:29:13 +00:00
|
|
|
maintainers = with maintainers; [ Br1ght0ne ];
|
2023-08-04 22:07:22 +00:00
|
|
|
mainProgram = "nnn";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2022-11-27 09:42:12 +00:00
|
|
|
})
|