dotfiles/overlays/builders.nix

46 lines
1 KiB
Nix
Raw Normal View History

2023-07-04 11:44:55 +02:00
_:
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}
2023-08-26 11:45:58 +02:00
${optionalString (runtimeInputs != [ ]) ''export PATH="${makeBinPath runtimeInputs}:$PATH"''}
2023-07-04 11:44:55 +02:00
2023-08-26 11:45:58 +02:00
${content}
'';
2023-07-04 11:44:55 +02:00
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;
};
}