2021-10-06 01:14:52 +02:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
with lib;
|
|
|
|
|
|
|
|
let
|
|
|
|
cfg = config.programs.nnn;
|
|
|
|
|
|
|
|
renderSetting = key: value: "${key}:${value}";
|
|
|
|
|
|
|
|
renderSettings = settings:
|
|
|
|
concatStringsSep ";" (mapAttrsToList renderSetting settings);
|
|
|
|
|
|
|
|
pluginModule = types.submodule ({ ... }: {
|
|
|
|
options = {
|
|
|
|
src = mkOption {
|
|
|
|
type = with types; nullOr path;
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2021-10-06 01:14:52 +02:00
|
|
|
(pkgs.fetchFromGitHub {
|
|
|
|
owner = "jarun";
|
|
|
|
repo = "nnn";
|
|
|
|
rev = "v4.0";
|
|
|
|
sha256 = "sha256-Hpc8YaJeAzJoEi7aJ6DntH2VLkoR6ToP6tPYn3llR7k=";
|
|
|
|
}) + "/plugins";
|
|
|
|
'';
|
|
|
|
default = null;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-10-06 01:14:52 +02:00
|
|
|
Path to the plugin folder.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
mappings = mkOption {
|
|
|
|
type = with types; attrsOf str;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-10-06 01:14:52 +02:00
|
|
|
Key mappings to the plugins.
|
|
|
|
'';
|
|
|
|
default = { };
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2021-10-06 01:14:52 +02:00
|
|
|
{
|
|
|
|
c = "fzcd";
|
|
|
|
f = "finder";
|
|
|
|
v = "imgview";
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
in {
|
|
|
|
meta.maintainers = with maintainers; [ thiagokokada ];
|
|
|
|
|
|
|
|
options = {
|
|
|
|
programs.nnn = {
|
2023-07-02 01:45:18 +02:00
|
|
|
enable = mkEnableOption "nnn";
|
2021-10-06 01:14:52 +02:00
|
|
|
|
|
|
|
package = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
default = pkgs.nnn;
|
2021-10-09 11:14:08 +02:00
|
|
|
defaultText = literalExpression "pkgs.nnn";
|
2021-10-06 01:14:52 +02:00
|
|
|
example =
|
2021-10-09 11:14:08 +02:00
|
|
|
literalExpression "pkgs.nnn.override ({ withNerdIcons = true; });";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2023-07-01 01:30:13 +02:00
|
|
|
Package containing the {command}`nnn` program.
|
2021-10-06 01:14:52 +02:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
finalPackage = mkOption {
|
|
|
|
type = types.package;
|
|
|
|
readOnly = true;
|
|
|
|
visible = false;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-10-06 01:14:52 +02:00
|
|
|
Resulting nnn package.
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
bookmarks = mkOption {
|
|
|
|
type = with types; attrsOf str;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-10-06 01:14:52 +02:00
|
|
|
Directory bookmarks.
|
|
|
|
'';
|
2021-10-09 11:14:08 +02:00
|
|
|
example = literalExpression ''
|
2021-10-06 01:14:52 +02:00
|
|
|
{
|
|
|
|
d = "~/Documents";
|
|
|
|
D = "~/Downloads";
|
|
|
|
p = "~/Pictures";
|
|
|
|
v = "~/Videos";
|
|
|
|
};
|
|
|
|
'';
|
|
|
|
default = { };
|
|
|
|
};
|
|
|
|
|
|
|
|
extraPackages = mkOption {
|
|
|
|
type = with types; listOf package;
|
|
|
|
example =
|
2021-10-09 11:14:08 +02:00
|
|
|
literalExpression "with pkgs; [ ffmpegthumbnailer mediainfo sxiv ]";
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-10-06 01:14:52 +02:00
|
|
|
Extra packages available to nnn.
|
|
|
|
'';
|
|
|
|
default = [ ];
|
|
|
|
};
|
|
|
|
|
|
|
|
plugins = mkOption {
|
|
|
|
type = pluginModule;
|
2023-07-02 01:45:18 +02:00
|
|
|
description = ''
|
2021-10-06 01:14:52 +02:00
|
|
|
Manage nnn plugins.
|
|
|
|
'';
|
|
|
|
default = { };
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
config = let
|
|
|
|
nnnPackage = cfg.package.overrideAttrs (oldAttrs: {
|
|
|
|
nativeBuildInputs = (oldAttrs.nativeBuildInputs or [ ])
|
|
|
|
++ [ pkgs.makeWrapper ];
|
|
|
|
postInstall = ''
|
|
|
|
${oldAttrs.postInstall or ""}
|
|
|
|
|
|
|
|
wrapProgram $out/bin/nnn \
|
|
|
|
--prefix PATH : "${makeBinPath cfg.extraPackages}" \
|
|
|
|
--prefix NNN_BMS : "${renderSettings cfg.bookmarks}" \
|
|
|
|
--prefix NNN_PLUG : "${renderSettings cfg.plugins.mappings}"
|
|
|
|
'';
|
|
|
|
});
|
|
|
|
in mkIf cfg.enable {
|
|
|
|
programs.nnn.finalPackage = nnnPackage;
|
|
|
|
home.packages = [ nnnPackage ];
|
|
|
|
xdg.configFile."nnn/plugins" =
|
|
|
|
mkIf (cfg.plugins.src != null) { source = cfg.plugins.src; };
|
|
|
|
};
|
|
|
|
}
|