From 5f34ca8c64760f71e534a74746d8b62205915129 Mon Sep 17 00:00:00 2001 From: a-kenji Date: Fri, 22 Sep 2023 10:06:03 +0200 Subject: [PATCH] fish: query pname and version for completions Query the `pname` and `version` attributes for completion generation, if the `name` attribute is not available. Fixes #2813 --- modules/programs/fish.nix | 41 ++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix index b32384692..ebcf14d67 100644 --- a/modules/programs/fish.nix +++ b/modules/programs/fish.nix @@ -320,24 +320,29 @@ in { ${postBuild} ''; - generateCompletions = package: - pkgs.runCommand "${package.name}-fish-completions" { - srcs = [ package ] ++ filter (p: p != null) - (builtins.map (outName: package.${outName} or null) - config.home.extraOutputsToInstall); - nativeBuildInputs = [ pkgs.python3 ]; - buildInputs = [ cfg.package ]; - preferLocalBuild = true; - } '' - mkdir -p $out - for src in $srcs; do - if [ -d $src/share/man ]; then - find -L $src/share/man -type f \ - | xargs python ${cfg.package}/share/fish/tools/create_manpage_completions.py --directory $out \ - > /dev/null - fi - done - ''; + generateCompletions = let + getName = attrs: + attrs.name or "${attrs.pname or "«pname-missing»"}-${ + attrs.version or "«version-missing»" + }"; + in package: + pkgs.runCommand "${getName package}-fish-completions" { + srcs = [ package ] ++ filter (p: p != null) + (builtins.map (outName: package.${outName} or null) + config.home.extraOutputsToInstall); + nativeBuildInputs = [ pkgs.python3 ]; + buildInputs = [ cfg.package ]; + preferLocalBuild = true; + } '' + mkdir -p $out + for src in $srcs; do + if [ -d $src/share/man ]; then + find -L $src/share/man -type f \ + | xargs python ${cfg.package}/share/fish/tools/create_manpage_completions.py --directory $out \ + > /dev/null + fi + done + ''; in destructiveSymlinkJoin { name = "${config.home.username}-fish-completions"; paths =