update raceless

This commit is contained in:
2025-10-28 17:01:12 +00:00
parent 9fe0bbaefe
commit e22fe24f3a

View File

@@ -1,36 +1,33 @@
{ pkgs, go }: { pkgs, go }:
let let
go-wrapper = pkgs.writeShellApplication { go-script = pkgs.writeShellScript "go-raceless" ''
name = "go"; args=("$@")
text = '' new_args=()
args=("$@") has_test=false
new_args=() found_race=false
has_test=false
found_race=false
for arg in "''${args[@]}"; do for arg in "''${args[@]}"; do
if [[ "$arg" == "test" ]]; then if [[ "$arg" == "test" ]]; then
has_test=true has_test=true
fi fi
done done
if [[ "$has_test" == "true" ]]; then if [[ "$has_test" == "true" ]]; then
for arg in "''${args[@]}"; do for arg in "''${args[@]}"; do
if [[ "$arg" != "-race" ]]; then if [[ "$arg" != "-race" ]]; then
new_args+=("$arg") new_args+=("$arg")
else else
found_race=true found_race=true
fi fi
done done
if [[ "$found_race" == "true" ]]; then
exec "$REAL_GO" "''${new_args[@]}"
fi
fi
exec "$REAL_GO" "$@" if [[ "$found_race" == "true" ]]; then
''; exec ${go}/bin/go "''${new_args[@]}"
}; fi
fi
exec ${go}/bin/go "$@"
'';
preservedAttrs = pkgs.lib.attrsets.getAttrs [ preservedAttrs = pkgs.lib.attrsets.getAttrs [
"CGO_ENABLED" "CGO_ENABLED"
@@ -46,9 +43,8 @@ pkgs.symlinkJoin (
nativeBuildInputs = [ pkgs.makeWrapper ]; nativeBuildInputs = [ pkgs.makeWrapper ];
postBuild = '' postBuild = ''
rm $out/bin/go rm $out/bin/go
cp ${go-script} $out/bin/go
makeWrapper ${go-wrapper}/bin/go $out/bin/go \ chmod +x $out/bin/go
--set REAL_GO ${go}/bin/go
''; '';
} }
// preservedAttrs // preservedAttrs