refactor: small changes
This commit is contained in:
parent
749e2cf67d
commit
372ee5985a
4 changed files with 86 additions and 54 deletions
|
|
@ -2,7 +2,33 @@ _:
|
|||
|
||||
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
|
||||
|
|
@ -11,30 +37,21 @@ with final.lib;
|
|||
, checkPhase ? null
|
||||
}:
|
||||
let
|
||||
fishFile = destination: content: final.writeTextFile {
|
||||
inherit name destination;
|
||||
executable = true;
|
||||
allowSubstitutes = true;
|
||||
preferLocalBuild = false;
|
||||
text = ''
|
||||
#!${getExe final.fish}
|
||||
runtimeHeader = optionalString (runtimeInputs != [ ])
|
||||
''export PATH="${makeBinPath runtimeInputs}:$PATH"'';
|
||||
|
||||
${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 {
|
||||
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 ];
|
||||
};
|
||||
|
||||
script = fishFile "/bin/${name}" text;
|
||||
completions_file = fishFile "/share/fish/vendor_completions.d/${name}.fish" completions;
|
||||
in
|
||||
final.symlinkJoin {
|
||||
inherit name;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue