mirror of
https://github.com/nix-community/home-manager
synced 2024-06-01 04:23:34 +02:00
nnn: Add extraSessionVariables and extraArgs
This commit is contained in:
parent
8bde7a651b
commit
548f0ccf41
|
@ -5,10 +5,16 @@ with lib;
|
|||
let
|
||||
cfg = config.programs.nnn;
|
||||
|
||||
renderSetting = key: value: "${key}:${value}";
|
||||
renderAttrs = sep: renderer: attrs:
|
||||
concatStringsSep sep (mapAttrsToList renderer attrs);
|
||||
|
||||
renderSettings = settings:
|
||||
concatStringsSep ";" (mapAttrsToList renderSetting settings);
|
||||
renderSettings = renderAttrs ";" (key: value: "${key}:${value}");
|
||||
|
||||
renderVariables =
|
||||
renderAttrs " " (key: value: ''--prefix ${key} : "${value}"'');
|
||||
|
||||
renderArgs =
|
||||
concatMapStringsSep " " (arg: "--add-flags ${escapeShellArg arg}");
|
||||
|
||||
pluginModule = types.submodule ({ ... }: {
|
||||
options = {
|
||||
|
@ -104,6 +110,34 @@ in {
|
|||
'';
|
||||
default = { };
|
||||
};
|
||||
|
||||
extraArgs = mkOption {
|
||||
type = with types; listOf str;
|
||||
example = literalExpression ''
|
||||
[
|
||||
"-b d" # Start in bookmark assigned to d key
|
||||
"-P c" # Run plugin assigned to c key on opening
|
||||
]
|
||||
'';
|
||||
description = ''
|
||||
Extra arguments to pass to nnn independently of a shell.
|
||||
'';
|
||||
default = [ ];
|
||||
};
|
||||
|
||||
extraSessionVariables = mkOption {
|
||||
type = with types; attrsOf str;
|
||||
example = literalExpression ''
|
||||
{
|
||||
NNN_OPTS = "cEnrx";
|
||||
NNN_COLORS = "#0a1b2c3d";
|
||||
};
|
||||
'';
|
||||
description = ''
|
||||
Extra environment variables to set for nnn independently of a shell.
|
||||
'';
|
||||
default = { };
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
|
@ -117,7 +151,9 @@ in {
|
|||
wrapProgram $out/bin/nnn \
|
||||
--prefix PATH : "${makeBinPath cfg.extraPackages}" \
|
||||
--prefix NNN_BMS : "${renderSettings cfg.bookmarks}" \
|
||||
--prefix NNN_PLUG : "${renderSettings cfg.plugins.mappings}"
|
||||
--prefix NNN_PLUG : "${renderSettings cfg.plugins.mappings}" \
|
||||
${renderArgs cfg.extraArgs} \
|
||||
${renderVariables cfg.extraSessionVariables}
|
||||
'';
|
||||
});
|
||||
in mkIf cfg.enable {
|
||||
|
|
|
@ -19,6 +19,11 @@
|
|||
v = "imgview";
|
||||
};
|
||||
};
|
||||
extraArgs = [ "-b d" "-P c" ];
|
||||
extraSessionVariables = {
|
||||
NNN_OPTS = "cEnrx";
|
||||
NNN_COLORS = "#0a1b2c3d";
|
||||
};
|
||||
};
|
||||
|
||||
test.stubs = {
|
||||
|
@ -48,6 +53,15 @@
|
|||
for plugin in 'export NNN_PLUG' 'fzcd' 'finder' 'imgview'; do
|
||||
assertFileRegex home-path/bin/nnn "$plugin"
|
||||
done
|
||||
|
||||
for argument in '\-b d' '\-P c'; do
|
||||
assertFileRegex home-path/bin/nnn "$argument"
|
||||
done
|
||||
|
||||
for variable in 'export NNN_OPTS' 'cEnrx' 'export NNN_COLORS' '#0a1b2c3d'; do
|
||||
assertFileRegex home-path/bin/nnn "$variable"
|
||||
done
|
||||
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user