buildGoPackage: Remove references to the go compiler to reduce closure size for binaries
This commit is contained in:
parent
2856d4701e
commit
c1338b3b06
@ -22,6 +22,12 @@ if disabled then throw "${name} not supported for go ${go.meta.branch}" else
|
|||||||
|
|
||||||
let
|
let
|
||||||
args = lib.filterAttrs (name: _: name != "extraSrcs") args';
|
args = lib.filterAttrs (name: _: name != "extraSrcs") args';
|
||||||
|
|
||||||
|
removeReferences = [ go ];
|
||||||
|
|
||||||
|
removeExpr = refs: lib.flip lib.concatMapStrings refs (ref: ''
|
||||||
|
| sed "s,${ref},$(echo "${ref}" | sed "s,$NIX_STORE/[^-]*,$NIX_STORE/eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee,"),g" \
|
||||||
|
'');
|
||||||
in
|
in
|
||||||
|
|
||||||
go.stdenv.mkDerivation (
|
go.stdenv.mkDerivation (
|
||||||
@ -146,10 +152,17 @@ go.stdenv.mkDerivation (
|
|||||||
|
|
||||||
dir="$NIX_BUILD_TOP/go/bin"
|
dir="$NIX_BUILD_TOP/go/bin"
|
||||||
[ -e "$dir" ] && cp -r $dir $out
|
[ -e "$dir" ] && cp -r $dir $out
|
||||||
|
while read file; do
|
||||||
|
cat $file ${removeExpr removeReferences} > $file.tmp
|
||||||
|
mv $file.tmp $file
|
||||||
|
chmod +x $file
|
||||||
|
done < <(find $out/bin -type f 2>/dev/null)
|
||||||
|
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
disallowedReferences = [ go ] ++ lib.optional (!dontRenameImports) govers;
|
||||||
|
|
||||||
passthru = passthru // lib.optionalAttrs (goPackageAliases != []) { inherit goPackageAliases; };
|
passthru = passthru // lib.optionalAttrs (goPackageAliases != []) { inherit goPackageAliases; };
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
|
Loading…
Reference in New Issue
Block a user