diff --git a/builder/default.nix b/builder/default.nix index 731b415..ac06757 100644 --- a/builder/default.nix +++ b/builder/default.nix @@ -261,13 +261,20 @@ let buildPhase = attrs.buildPhase or '' runHook preBuild + exclude='\(/_\|examples\|Godeps\|testdata' + if [[ -n "$excludedPackages" ]]; then + IFS=' ' read -r -a excludedArr <<<$excludedPackages + printf -v excludedAlternates '%s\\|' "''${excludedArr[@]}" + excludedAlternates=''${excludedAlternates%\\|} # drop final \| added by printf + exclude+='\\|'"$excludedAlternates" + fi + exclude+='\)' + buildGoDir() { local d; local cmd; cmd="$1" d="$2" . $TMPDIR/buildFlagsArray - echo "$d" | grep -q "\(/_\|examples\|Godeps\|testdata\)" && return 0 - [ -n "$excludedPackages" ] && echo "$d" | grep -q "$excludedPackages" && return 0 local OUT if ! OUT="$(go $cmd $buildFlags "''${buildFlagsArray[@]}" ''${tags:+-tags=${lib.concatStringsSep "," tags}} ''${ldflags:+-ldflags="$ldflags"} -v -p $NIX_BUILD_CORES $d 2>&1)"; then if echo "$OUT" | grep -qE 'imports .*?: no Go files in'; then @@ -308,6 +315,7 @@ let export NIX_BUILD_CORES=1 fi for pkg in $(getGoDirs ""); do + grep -q "$exclude" <<<$pkg && continue echo "Building subPackage $pkg" buildGoDir install "$pkg" done