nixos/fish: fix completion generation for non-derivation packages

environment.systemPackages can include any package, which means it can
be a top-level store path that is not a derivation and thus will not
have a name attribute - their name is extracted from the path instead.
This commit is contained in:
hyperfekt 2022-06-08 13:50:36 +02:00
parent 67ff218c7c
commit 3fd98e7fcb

View file

@ -258,16 +258,13 @@ in
preferLocalBuild = true; preferLocalBuild = true;
allowSubstitutes = false; allowSubstitutes = false;
}; };
generateCompletions = package: pkgs.runCommand generateCompletions = package: pkgs.runCommandLocal
"${package.name}_fish-completions" ( with lib.strings; let
( storeLength = stringLength storeDir + 34; # Nix' StorePath::HashLen + 2 for the separating slash and dash
{ pathName = substring storeLength (stringLength package - storeLength) package;
inherit package; in (package.name or pathName) + "_fish-completions")
preferLocalBuild = true; ( { inherit package; } //
allowSubstitutes = false; optionalAttrs (package ? meta.priority) { meta.priority = package.meta.priority; })
}
// optionalAttrs (package ? meta.priority) { meta.priority = package.meta.priority; }
)
'' ''
mkdir -p $out mkdir -p $out
if [ -d $package/share/man ]; then if [ -d $package/share/man ]; then