@@ -117,21 +117,6 @@ else
117117 die "Couldn't figure out where out where to patch in new version in '$attr'!"
118118fi
119119
120−# Replace new version
121−sed -i.bak "$nixFile" -re "$pattern"
122−if cmp -s "$nixFile" "$nixFile.bak"; then
123− die "Failed to replace version '$oldVersion' to '$newVersion' in '$attr'!"
124−fi
125−
126−# Replace new URL
127−if [[ -n "$newUrl" ]]; then
128− sed -i "$nixFile" -re "s|\"$oldUrlEscaped\"|\"$newUrl\"|"
129−
130− if cmp -s "$nixFile" "$nixFile.bak"; then
131− die "Failed to replace source URL '$oldUrl' to '$newUrl' in '$attr'!"
132− fi
133−fi
134−
135120if [[ "$oldHash" =~ ^(sha256|sha512)[:-] ]]; then
136121 # Handle the possible SRI-style hash attribute (in the form ${type}${separator}${hash})
137122 # True SRI uses dash as a separator and only supports base64, whereas Nix’s SRI-style format uses a colon and supports all the same encodings like regular hashes (16/32/64).
@@ -159,6 +144,21 @@ if [[ -n "$sri" ]]; then
159144 tempHash="$(nix to-sri --type "$oldHashAlgo" "$tempHash")"
160145fi
161146
147+# Replace new version
148+sed -i.bak "$nixFile" -re "$pattern"
149+if cmp -s "$nixFile" "$nixFile.bak"; then
150+ die "Failed to replace version '$oldVersion' to '$newVersion' in '$attr'!"
151+fi
152+
153+# Replace new URL
154+if [[ -n "$newUrl" ]]; then
155+ sed -i "$nixFile" -re "s|\"$oldUrlEscaped\"|\"$newUrl\"|"
156+
157+ if cmp -s "$nixFile" "$nixFile.bak"; then
158+ die "Failed to replace source URL '$oldUrl' to '$newUrl' in '$attr'!"
159+ fi
160+fi
161+
162162sed -i "$nixFile" -re "s|\"$oldHash\"|\"$tempHash\"|"
163163if cmp -s "$nixFile" "$nixFile.bak"; then
164164 die "Failed to replace source hash of '$attr' to a temporary hash!"