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