diff --git a/ghcup b/ghcup
index 4f8277346cf0607508817ee0f5fa5f4265cc3ab8..93acf814f3ebd3d68caa4598b292bae491f4b9f7 100755
--- a/ghcup
+++ b/ghcup
@@ -1603,11 +1603,57 @@ upgrade() {
     status_message "Updating ${SCRIPT}"
 
     (
+        _plat="$(uname -s)"
+        _arch=$(uname -m)
+
+        case "${_plat}" in
+            "linux"|"Linux")
+                case "${_arch}" in
+                    x86_64|amd64)
+                        _url=https://downloads.haskell.org/~ghcup/x86_64-linux-ghcup
+                        ;;
+                    i*86)
+                        _url=https://downloads.haskell.org/~ghcup/i386-linux-ghcup
+                        ;;
+                    *) die "Unknown architecture: ${_arch}"
+                        ;;
+                esac
+                ;;
+            "FreeBSD"|"freebsd")
+                case "${_arch}" in
+                    x86_64|amd64)
+                        ;;
+                    i*86)
+                        die "i386 currently not supported!"
+                        ;;
+                    *) die "Unknown architecture: ${_arch}"
+                        ;;
+                esac
+                _url=https://downloads.haskell.org/~ghcup/x86_64-portbld-freebsd-ghcup
+                ;;
+            "Darwin"|"darwin")
+                case "${_arch}" in
+                    x86_64|amd64)
+                        ;;
+                    i*86)
+                        die "i386 currently not supported!"
+                        ;;
+                    *) die "Unknown architecture: ${_arch}"
+                        ;;
+                esac
+                _url=https://downloads.haskell.org/~ghcup/x86_64-apple-darwin-ghcup ;;
+            *) die "Unknown platform: ${_plat}"
+                ;;
+        esac
+
+
         edo cd "$(mktempdir)"
-        download "${SCRIPT_UPDATE_URL}"
+        download_to_stdout "${_url}" > ghcup
         edo chmod +x ghcup
         edo mv -f ghcup "${target_location}"/ghcup
 
+        unset _plat _arch _url
+
     ) || die "failed to install"
 
     status_message "Done"
@@ -2091,6 +2137,10 @@ fi
 
 
 
+>&2 warning_message "ghcup has been rewritten in haskell. Please upgrade again via 'ghcup upgrade'"
+
+
+
 
     ##############################################
     #--[ Command line parsing and entry point ]--#