switch from sqlite to json
This commit is contained in:
parent
17967da43e
commit
f2d0a42fd7
5 changed files with 191 additions and 226 deletions
|
|
@ -1,11 +1,12 @@
|
|||
# NixOS module: automatic nushell completion generation
|
||||
# NixOS module: automatic nushell completion indexing
|
||||
#
|
||||
# Generates completions using three strategies in priority order:
|
||||
# Indexes completions using three strategies in priority order:
|
||||
# 1. Native completion generators (e.g. CMD completions nushell)
|
||||
# 2. Manpage parsing
|
||||
# 3. --help output parsing
|
||||
#
|
||||
# Runs as a single pass during the system profile build.
|
||||
# Produces a directory of .json/.nu files at build time.
|
||||
# The `complete` command reads from this directory as a system overlay.
|
||||
#
|
||||
# Usage:
|
||||
# { pkgs, ... }: {
|
||||
|
|
@ -25,20 +26,19 @@ let
|
|||
in
|
||||
{
|
||||
options.programs.inshellah = {
|
||||
enable = lib.mkEnableOption "nushell completion generation via inshellah";
|
||||
enable = lib.mkEnableOption "nushell completion indexing via inshellah";
|
||||
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
description = "The inshellah package to use for generating completions.";
|
||||
description = "The inshellah package to use for indexing completions.";
|
||||
};
|
||||
|
||||
generatedCompletionsPath = lib.mkOption {
|
||||
completionsPath = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = "/share/nushell/vendor/autoload";
|
||||
default = "/share/inshellah";
|
||||
description = ''
|
||||
Subdirectory within the merged environment where completion files
|
||||
are placed. The default matches nushell's vendor autoload convention
|
||||
(discovered via XDG_DATA_DIRS).
|
||||
are placed. Used as the system-dir for the completer.
|
||||
'';
|
||||
};
|
||||
|
||||
|
|
@ -47,19 +47,19 @@ in
|
|||
default = [];
|
||||
example = [ "meat" "problematic-tool" ];
|
||||
description = ''
|
||||
List of command names to skip during completion generation.
|
||||
List of command names to skip during completion indexing.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
environment.pathsToLink = [ cfg.generatedCompletionsPath ];
|
||||
environment.pathsToLink = [ cfg.completionsPath ];
|
||||
|
||||
environment.extraSetup =
|
||||
let
|
||||
inshellah = "${cfg.package}/bin/inshellah";
|
||||
destDir = "$out${cfg.generatedCompletionsPath}";
|
||||
segments = lib.filter (s: s != "") (lib.splitString "/" cfg.generatedCompletionsPath);
|
||||
destDir = "$out${cfg.completionsPath}";
|
||||
segments = lib.filter (s: s != "") (lib.splitString "/" cfg.completionsPath);
|
||||
derefPath = lib.concatMapStringsSep "\n " (seg: ''
|
||||
_cur="$_cur/${seg}"
|
||||
if [ -L "$_cur" ]; then
|
||||
|
|
@ -79,10 +79,10 @@ in
|
|||
${derefPath}
|
||||
mkdir -p ${destDir}
|
||||
|
||||
# Generate all completions in one pass:
|
||||
# Index completions in one pass:
|
||||
# native generators > manpages > --help fallback
|
||||
if [ -d "$out/bin" ] && [ -d "$out/share/man" ]; then
|
||||
${inshellah} generate "$out/bin" "$out/share/man" -o ${destDir}${ignoreFlag} \
|
||||
${inshellah} index "$out" --dir ${destDir}${ignoreFlag} \
|
||||
2>/dev/null || true
|
||||
fi
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue