writeTextFile: set meta.mainProgram based on destination

This commit is contained in:
figsoda 2023-05-27 11:09:44 -04:00
parent 3580ac6c65
commit 4b94ae4bc6

View File

@ -135,9 +135,15 @@ rec {
, allowSubstitutes ? false
, preferLocalBuild ? true
}:
let
matches = builtins.match "/bin/([^/]+)" destination;
in
runCommand name
{ inherit text executable checkPhase meta allowSubstitutes preferLocalBuild;
{ inherit text executable checkPhase allowSubstitutes preferLocalBuild;
passAsFile = [ "text" ];
meta = lib.optionalAttrs (executable && matches != null) {
mainProgram = lib.head matches;
} // meta;
}
''
target=$out${lib.escapeShellArg destination}
@ -230,7 +236,7 @@ rec {
*/
writeScriptBin = name: text: writeTextFile {inherit name text; executable = true; destination = "/bin/${name}"; meta.mainProgram = name;};
writeScriptBin = name: text: writeTextFile {inherit name text; executable = true; destination = "/bin/${name}";};
/*
Similar to writeScript. Writes a Shell script and checks its syntax.
@ -288,7 +294,6 @@ rec {
checkPhase = ''
${stdenv.shellDryRun} "$target"
'';
meta.mainProgram = name;
};
/*
@ -351,8 +356,6 @@ rec {
runHook postCheck
''
else checkPhase;
meta.mainProgram = name;
};
# Create a C binary