Skip to content

Add "simple" hosting style - #2285

Merged
Gankra merged 8 commits into
mainfrom
gankra/custom
Feb 20, 2026
Merged

Gankra merged 8 commits into
mainfrom
gankra/custom

Conversation

@Gankra

@Gankra Gankra commented Feb 12, 2026 •

Copy link
Copy Markdown
Contributor

This is an alternative to #2250 that more thoroughly applies the URL by treating it like a hosting style. This makes the config... much more gross, but ensures the proper value is propagated, and lays groundwork for a potential mirror-upload-url (right now astral plans to do this via a custom job).

It does this primarily by introducing a simple-download-url = "https://static.mysite.com/{tag}" value. Priority between the sources can be specified by using hosting = ["simple", "github"] vs hosting = ["github", "simple"]. One can also specify to only use the mirror with hosting = ["simple"]. If no ordering is specified, both are used and the mirror is preferred.

This PR intends to implement only support for this in the shell and powershell installers, so notably it punts on:

  • npm installer (just uses the highest priority one)
  • brew installer (just uses the highest priority one)

I'm still testing the shell/powershell changes.

@Gankra

Gankra commented Feb 12, 2026

Copy link
Copy Markdown
Contributor Author

let the record show that writing powershell and bash scripts you Really don't want to run locally, while also sick, is "hard"

@Gankra
Gankra marked this pull request as ready for review February 12, 2026 18:42
@Gankra

Gankra commented Feb 12, 2026

Copy link
Copy Markdown
Contributor Author

Alright I need to tidy up the commits and add some docs but this seems to be working well now.

Some testing of the fallback behaviour is merited, in particular I saw some mysterious behaviour in CI where the download would fail but in a way that the download command considered a success. Not sure if that was a transient effect of my work or a legit issue (wouldn't reproduce locally -- not that surprising with how complex that curl/wget selection stuff is).

Comment on lines 325 to +334
} = mac_pkg_config?;
Some(PkgInstallerLayer {
common: CommonInstallerLayer::default(),
identifier,
install_location,
})
if install_location.is_some() || identifier.is_some() {
Some(PkgInstallerLayer {
common: CommonInstallerLayer::default(),
identifier,
install_location,
})
} else {
None
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a completely drive-by fix I ended up doing while debugging some apparent bitrot in the tests (as written it would always enable the pkg installer)

Comment on lines -30 to -32
.PARAMETER ArtifactDownloadUrl
The URL of the directory where artifacts can be fetched from

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This parameter was always shadowed by the subsequent code, so I removed it as useless (other env-vars do the same thing).

Comment on lines 46 to +60
$app_version = '{{ app_version }}'
if ($env:{{ env_vars.ghe_base_url_env_var }}) {
if ($env:{{ env_vars.download_url_env_var }}) {
$ArtifactDownloadUrls = @($env:{{ env_vars.download_url_env_var }})
} elseif ($env:INSTALLER_DOWNLOAD_URL) {
$ArtifactDownloadUrls = @($env:INSTALLER_DOWNLOAD_URL)
} elseif ($env:{{ env_vars.ghe_base_url_env_var }}) {
$installer_base_url = $env:{{ env_vars.ghe_base_url_env_var }}
$ArtifactDownloadUrls = @("$installer_base_url{{ hosting.github.artifact_download_path }}")
} elseif ($env:{{ env_vars.github_base_url_env_var }}) {
$installer_base_url = $env:{{ env_vars.github_base_url_env_var }}
$ArtifactDownloadUrls = @("$installer_base_url{{ hosting.github.artifact_download_path }}")
} else {
$installer_base_url = "{{ hosting.github.artifact_base_url }}"
}
if ($env:{{ env_vars.download_url_env_var }}) {
$ArtifactDownloadUrl = $env:{{ env_vars.download_url_env_var }}
} elseif ($env:INSTALLER_DOWNLOAD_URL) {
$ArtifactDownloadUrl = $env:INSTALLER_DOWNLOAD_URL
} else {
$ArtifactDownloadUrl = "$installer_base_url{{ hosting.github.artifact_download_path }}"
$ArtifactDownloadUrls = @({% for url in base_urls -%}
"{{ url }}"{{ ", " if not loop.last else "" }}
{%- endfor %})

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code concerned me for a bit, because it turns out the shell installers don't actually use base_url anymore after various features. However I was able to rearrange the conditions the preserve the same defacto behaviour for overridden env-vars, while still defaulting to the new cascading list of options.

@Gankra

Gankra commented Feb 12, 2026

Copy link
Copy Markdown
Contributor Author

Not convinced I actually fixed the pkg thing, it seems to hauntedly come and go on my machine which is... distressing.

@mistydemeo

Copy link
Copy Markdown
Contributor

The pkg issue sounds... mystifying. I can see if I can repro?

@mistydemeo mistydemeo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The implementation makes sense to me, but I wonder if we want to be labelling this as a "mirror". Maybe we just want to promote a static host to a first-class non-mirror hosting source, like GitHub releases? I can imagine something like this being used to host primary artifacts, or the only artifacts without GH releases.

@Gankra

Gankra commented Feb 17, 2026

Copy link
Copy Markdown
Contributor Author

Yeah I was trying to find a good term for "static file server", and mirror felt the best, but I agree it's weird when it's the primary (which is the expected/intended case).

@Gankra Gankra changed the title Add "mirror" hosting style Add "simple" hosting style Feb 17, 2026
@mistydemeo

Copy link
Copy Markdown
Contributor

Arg, sorry about introducing a merge conflict with the npm-shrinkwrap branch.

@mistydemeo mistydemeo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, though I haven't had a chance to test yet.

Comment thread cargo-dist-schema/src/lib.rs Outdated
pub repo: String,
}

/// Github Hosting

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong comment?

{%- if cond is defined %}
if {{ cond }}
url "{{ inner.base_url }}/{{ frag.id }}"
{#- FIXME: implement support for fallback URLs #}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm happy to do this in a followup PR.

@Gankra
Gankra merged commit a7e1743 into main Feb 20, 2026
18 checks passed
@Gankra
Gankra deleted the gankra/custom branch February 20, 2026 15:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants