diff --git a/schema/mise.json b/schema/mise.json index 1c7c6cb6e1..e347b5beae 100644 --- a/schema/mise.json +++ b/schema/mise.json @@ -682,6 +682,10 @@ "gpg_verify": { "description": "Use gpg to verify swift tool signatures.", "type": "boolean" + }, + "platform": { + "description": "Override the platform to use for precompiled binaries.", + "type": "string" } } }, diff --git a/settings.toml b/settings.toml index 829f528b68..2f1e20f2a6 100644 --- a/settings.toml +++ b/settings.toml @@ -889,6 +889,13 @@ type = "Bool" optional = true description = "Use gpg to verify swift tool signatures." +[swift.platform] +env = "MISE_SWIFT_PLATFORM" +type = "String" +optional = true +description = "Override the platform to use for precompiled binaries." +default_docs = '"osx" | "windows10" | "ubuntu20.04" | "ubuntu22.04" | "ubuntu24.04" | "amazonlinux2" | "ubi9" | "fedora39"' + [system_config_file] env = "MISE_SYSTEM_CONFIG_FILE" type = "Path" diff --git a/src/plugins/core/swift.rs b/src/plugins/core/swift.rs index 9faf43c487..e63a808171 100644 --- a/src/plugins/core/swift.rs +++ b/src/plugins/core/swift.rs @@ -203,6 +203,9 @@ fn platform_directory() -> String { } fn platform() -> String { + if let Some(platform) = &SETTINGS.swift.platform { + return platform.clone(); + } if cfg!(macos) { "osx".to_string() } else if cfg!(windows) { @@ -210,11 +213,15 @@ fn platform() -> String { } else if let Ok(os_release) = &*os_release::OS_RELEASE { if os_release.id == "amzn" { format!("amazonlinux{}", os_release.version_id) + } else if os_release.id == "ubi" { + "ubi9".to_string() // only 9 is available + } else if os_release.id == "fedora" { + "fedora39".to_string() // only 39 is available } else { format!("{}{}", os_release.id, os_release.version_id) } } else { - "ubi".to_string() + "ubi9".to_string() } }