mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos/fish: allow disabling completion generation
(cherry picked from commit 3045cecacf
)
This commit is contained in:
parent
89e94ea7a7
commit
c567580239
1 changed files with 24 additions and 16 deletions
|
@ -72,6 +72,11 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
generateCompletions = lib.mkEnableOption "generating completion files from man pages" // {
|
||||||
|
default = true;
|
||||||
|
example = false;
|
||||||
|
};
|
||||||
|
|
||||||
vendor.config.enable = lib.mkOption {
|
vendor.config.enable = lib.mkOption {
|
||||||
type = lib.types.bool;
|
type = lib.types.bool;
|
||||||
default = true;
|
default = true;
|
||||||
|
@ -247,7 +252,7 @@ in
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
{
|
(lib.mkIf cfg.generateCompletions {
|
||||||
etc."fish/generated_completions".source =
|
etc."fish/generated_completions".source =
|
||||||
let
|
let
|
||||||
patchedGenerator = pkgs.stdenv.mkDerivation {
|
patchedGenerator = pkgs.stdenv.mkDerivation {
|
||||||
|
@ -297,7 +302,7 @@ in
|
||||||
ignoreCollisions = true;
|
ignoreCollisions = true;
|
||||||
paths = builtins.map generateCompletions config.environment.systemPackages;
|
paths = builtins.map generateCompletions config.environment.systemPackages;
|
||||||
};
|
};
|
||||||
}
|
})
|
||||||
|
|
||||||
# include programs that bring their own completions
|
# include programs that bring their own completions
|
||||||
{
|
{
|
||||||
|
@ -318,20 +323,23 @@ in
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
programs.fish.interactiveShellInit = ''
|
programs.fish.interactiveShellInit =
|
||||||
# add completions generated by NixOS to $fish_complete_path
|
lib.optionalString cfg.generateCompletions ''
|
||||||
begin
|
# add completions generated by NixOS to $fish_complete_path
|
||||||
# joins with null byte to accommodate all characters in paths, then respectively gets all paths before (exclusive) / after (inclusive) the first one including "generated_completions",
|
begin
|
||||||
# splits by null byte, and then removes all empty lines produced by using 'string'
|
# joins with null byte to accommodate all characters in paths, then respectively gets all paths before (exclusive) / after (inclusive) the first one including "generated_completions",
|
||||||
set -l prev (string join0 $fish_complete_path | string match --regex "^.*?(?=\x00[^\x00]*generated_completions.*)" | string split0 | string match -er ".")
|
# splits by null byte, and then removes all empty lines produced by using 'string'
|
||||||
set -l post (string join0 $fish_complete_path | string match --regex "[^\x00]*generated_completions.*" | string split0 | string match -er ".")
|
set -l prev (string join0 $fish_complete_path | string match --regex "^.*?(?=\x00[^\x00]*generated_completions.*)" | string split0 | string match -er ".")
|
||||||
set fish_complete_path $prev "/etc/fish/generated_completions" $post
|
set -l post (string join0 $fish_complete_path | string match --regex "[^\x00]*generated_completions.*" | string split0 | string match -er ".")
|
||||||
end
|
set fish_complete_path $prev "/etc/fish/generated_completions" $post
|
||||||
# prevent fish from generating completions on first run
|
end
|
||||||
if not test -d $__fish_user_data_dir/generated_completions
|
''
|
||||||
${pkgs.coreutils}/bin/mkdir $__fish_user_data_dir/generated_completions
|
+ ''
|
||||||
end
|
# prevent fish from generating completions on first run
|
||||||
'';
|
if not test -d $__fish_user_data_dir/generated_completions
|
||||||
|
${pkgs.coreutils}/bin/mkdir $__fish_user_data_dir/generated_completions
|
||||||
|
end
|
||||||
|
'';
|
||||||
|
|
||||||
};
|
};
|
||||||
meta.maintainers = with lib.maintainers; [ sigmasquadron ];
|
meta.maintainers = with lib.maintainers; [ sigmasquadron ];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue