@@ -231,7 +231,13 @@ let
231231 # Remove the non nix files ".project" ".cabal" "package.yaml" files
232232 # as they should not be in the output hash (they may change slightly
233233 # without affecting the nix).
234− find $out -type f ! -name '*.nix' -exec rm "{}" \;
234+ if [ -d $out/.source-repository-packages ]; then
235+ chmod +w -R $out/.source-repository-packages
236+ rm -rf $out/.source-repository-packages
237+ fi
238+ find $out -type f ! -name '*.nix' -delete
239+ # Remove empty dirs
240+ find $out -type d -empty -delete
235241
236242 # move pkgs.nix to default.nix ensure we can just nix `import` the result.
237243 mv $out/pkgs.nix $out/default.nix