_: final: _: with final.lib; { writeFishApplication = { name , text , completions ? null , runtimeInputs ? [ ] , checkPhase ? null }: let fishFile = destination: content: final.writeTextFile { inherit name destination; executable = true; allowSubstitutes = true; preferLocalBuild = false; text = '' #!${getExe final.fish} '' + optionalString (runtimeInputs != [ ]) '' export PATH="${makeBinPath runtimeInputs}:$PATH" '' + '' ${content} ''; checkPhase = if checkPhase == null then '' runHook preCheck ${getExe final.fish} -n "$target" runHook postCheck '' else checkPhase; }; script = fishFile "/bin/${name}" text; completions_file = fishFile "/share/fish/vendor_completions.d/${name}.fish" completions; in final.symlinkJoin { inherit name; paths = [ script ] ++ optional (completions != null) completions_file; }; }