Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fastly: implement "Lockable HTTP Tarball Protocol" (Flakes) for channels.nixos.org #562

Merged
merged 1 commit into from
Feb 24, 2025

Conversation

emilylange
Copy link
Member

This is part of another PR over in NixOS/nixos-channel-scripts that implements the precomputed x-amz-meta-link header. For the motivation behind this change look there (NixOS/nixos-channel-scripts#76).

Hydra executes mirror-nixos-branch.pl when a given channel advances. Thus, we need some sort of fallback to handle channels which have long been EOL. A fallback also allows this change to be deployed in any order and over the span of multiple days.

Our default mode of operation is simply renaming the precomputed "x-amz-meta-link" header created by the script to "link", if it exists. Note that we cannot use "link" directly because AWS S3 does not allow it.

As a fallback we take the "location" header (which always exists) and template it into "link".
This lacks additional flake attributes like "rev" or whatever additional metadata the script may precompute, but is perfectly compliant with the "Lockable HTTP Tarball Protocol".

When running into the fallback, the string returned by nixpkgs' lib.trivial.versionSuffix will contain "dirty" instead of "pre-git" or the proper 7-char substring of the rev.

While we could have Fastly do a sub-request to fetch the git-revision txt right next to the tarball, I don't think it's worth the effort and complexity.

Tested using https://fiddle.fastly.dev/.

Ref: https://github.com/NixOS/nix/blob/61f49de7ae0b3899abdcc102832523153dd40d35/doc/manual/source/protocols/tarball-fetcher.md

…els.nixos.org

This is part of another PR over in NixOS/nixos-channel-scripts that
implements the precomputed x-amz-meta-link header. For the motivation
behind this change look there.

Hydra executes mirror-nixos-branch.pl when a given channel advances.
Thus, we need some sort of fallback to handle channels which have long
been EOL. A fallback also allows this change to be deployed in any order
and over the span of multiple days.

Our default mode of operation is simply renaming the precomputed
"x-amz-meta-link" header created by the script to "link", if it exists.
Note that we cannot use "link" directly because AWS S3 does not allow it.

As a fallback we take the "location" header (which always exists) and
template it into "link".
This lacks additional flake attributes like "rev" or whatever additional
metadata the script may precompute, but is perfectly compliant with the
"Lockable HTTP Tarball Protocol".

When running into the fallback, the string returned by nixpkgs'
lib.trivial.versionSuffix will contain "dirty" instead of "pre-git" or
the proper 7-char substring of the rev.

While we could have Fastly do a sub-request to fetch the git-revision
txt right next to the tarball, I don't think it's worth the effort and
complexity.

Tested using <https://fiddle.fastly.dev/>.

Ref: https://github.com/NixOS/nix/blob/61f49de7ae0b3899abdcc102832523153dd40d35/doc/manual/source/protocols/tarball-fetcher.md
@Mic92 Mic92 force-pushed the lockable-tarball-flakes branch from 5fd01e9 to 9bf7440 Compare February 24, 2025 03:31
@Mic92
Copy link
Member

Mic92 commented Feb 24, 2025

@Mic92 Mic92 merged commit 4c8902e into NixOS:main Feb 24, 2025
8 checks passed
clan-infra-bot bot pushed a commit to clan-lol/clan-core that referenced this pull request Feb 24, 2025
@emilylange emilylange deleted the lockable-tarball-flakes branch February 25, 2025 16:25
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