Merge pull request #6411 from NixOS/passAsFile

writeTextFile: Use passAsFile if available
This commit is contained in:
Wout Mertens 2015-05-14 13:57:24 +02:00
commit 1f400ea463

View file

@ -20,13 +20,18 @@ rec {
}:
runCommand name
{ inherit text executable;
passAsFile = [ "text" ];
# Pointless to do this on a remote machine.
preferLocalBuild = true;
}
''
n=$out${destination}
mkdir -p "$(dirname "$n")"
echo -n "$text" > "$n"
if [ -e "$textPath" ]; then
mv "$textPath" "$n"
else
echo -n "$text" > "$n"
fi
(test -n "$executable" && chmod +x "$n") || true
'';