buildGo{Module,Package}: respect nix hardening flags when setting buildmode

This commit is contained in:
zowoq
2023-01-30 10:25:06 +10:00
parent 4abe923106
commit 421acf1022
2 changed files with 12 additions and 0 deletions

View File

@@ -188,6 +188,12 @@ let
''}
'' + ''
# currently pie is only enabled by default in pkgsMusl
# this will respect the `hardening{Disable,Enable}` flags if set
if [[ $NIX_HARDENING_ENABLE =~ "pie" ]]; then
export GOFLAGS="-buildmode=pie $GOFLAGS"
fi
runHook postConfigure
'';

View File

@@ -134,6 +134,12 @@ let
export GOPATH=$NIX_BUILD_TOP/go:$GOPATH
export GOCACHE=$TMPDIR/go-cache
# currently pie is only enabled by default in pkgsMusl
# this will respect the `hardening{Disable,Enable}` flags if set
if [[ $NIX_HARDENING_ENABLE =~ "pie" ]]; then
export GOFLAGS="-buildmode=pie $GOFLAGS"
fi
runHook postConfigure
'';