0
0
mirror of https://github.com/go-gitea/gitea.git synced 2024-12-18 21:50:01 +01:00
gitea/routers/web/repo
Giteabot c6189cfcb9
Add an immutable tarball link to archive download headers for Nix (#31139) (#31145)
Backport #31139 by @Mic92

This allows `nix flake metadata` and nix in general to lock a *branch*
tarball link in a manner that causes it to fetch the correct commit even
if the branch is updated with a newer version.

For further context, Nix flakes are a feature that, among other things,
allows for "inputs" that are "github:someuser/somerepo",
"https://some-tarball-service/some-tarball.tar.gz",
"sourcehut:~meow/nya" or similar. This feature allows our users to fetch
tarballs of git-based inputs to their builds rather than using git to
fetch them, saving significant download time.

There is presently no gitea or forgejo specific fetcher in Nix, and we
don't particularly wish to have one. Ideally (as a developer on a Nix
implementation myself) we could just use the generic tarball fetcher and
not add specific forgejo support, but to do so, we need additional
metadata to know which commit a given *branch* tarball represents, which
is the purpose of the Link header added here.

The result of this patch is that a Nix user can specify
`inputs.something.url =
"https://forgejo-host/some/project/archive/main.tar.gz"` in flake.nix
and get a link to some concrete tarball for the actual commit in the
lock file, then when they run `nix flake update` in the future, they
will get the latest commit in that branch.

Example of it working locally:

» nix flake metadata --refresh
'http://localhost:3000/api/v1/repos/jade/cats/archive/main.tar.gz?dir=configs/nix'
Resolved URL:
http://localhost:3000/api/v1/repos/jade/cats/archive/main.tar.gz?dir=configs/nix
Locked URL:
804ede182b.tar.gz?dir=configs
/nix&narHash=sha256-yP7KkDVfuixZzs0fsqhSETXFC0y8m6nmPLw2GrAMxKQ%3D
Description:   Computers with the nixos
Path:          /nix/store/s856c6yqghyan4v0zy6jj19ksv0q22nx-source
Revision:      804ede182b6b66469b23ea4d21eece52766b7a06
Last modified: 2024-05-02 00:48:32

For details on the header value, see:

56763ff918/doc/manual/src/protocols/tarball-fetcher.md

Co-authored-by: Jörg Thalheim <Mic92@users.noreply.github.com>
Co-authored-by: Jade Lovelace <software@lfcode.ca>
Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
2024-05-29 01:34:14 +00:00
..
actions Fix possible ui 500 if workflow's job is nil (#31092) (#31098) 2024-05-27 14:13:15 +08:00
setting Fix wrong transfer hint (#30889) (#30900) 2024-05-08 15:12:37 +00:00
activity.go
attachment.go
blame.go Refactor file view & render (#30227) 2024-04-01 21:11:30 +08:00
branch.go
cherry_pick.go
code_frequency.go
commit.go Fix code search input for different views (#30678) 2024-04-26 11:21:04 +00:00
compare.go Refactor sha1 and time-limited code (#31023) (#31030) 2024-05-21 00:58:21 +08:00
contributors.go
download.go
editor_test.go
editor.go Add missed return after ctx.ServerError (#31130) (#31133) 2024-05-28 12:47:11 +02:00
find.go
fork.go
githttp_test.go
githttp.go Make sure git version&feature are always prepared (#30877) (#30879) 2024-05-07 02:07:33 +00:00
helper_test.go
helper.go
issue_content_history.go Migrate margin and padding helpers to tailwind (#30043) 2024-03-24 17:42:49 +01:00
issue_dependency.go
issue_label_test.go
issue_label.go
issue_lock.go
issue_pin.go
issue_stopwatch.go
issue_test.go
issue_timetrack.go
issue_watch.go
issue.go Fix issue label rendering in the issue popup (#30763) (#30773) 2024-04-30 09:40:47 +00:00
main_test.go
middlewares.go
migrate.go
milestone.go
packages.go
patch.go
projects_test.go
projects.go Fix various problems around projects board view (#30696) (#30902) 2024-05-08 15:46:21 +00:00
pull_review_test.go
pull_review.go Prevent allow/reject reviews on merged/closed PRs (#30686) 2024-04-27 11:55:03 +00:00
pull.go Fix View File button link if branch deleted on pull request files pages (#31063) (#31077) 2024-05-26 14:07:17 +00:00
recent_commits.go
release_test.go
release.go
render.go Refactor render (#30136) 2024-03-27 13:14:34 +00:00
repo.go Add an immutable tarball link to archive download headers for Nix (#31139) (#31145) 2024-05-29 01:34:14 +00:00
search_test.go Improve grep search (#30843) (#30850) 2024-05-03 17:59:33 +08:00
search.go Improve grep search (#30843) (#30850) 2024-05-03 17:59:33 +08:00
topic.go
treelist.go
view_test.go
view.go Fix wrong display of recently pushed notification (#25812) (#31043) 2024-05-23 04:14:26 +00:00
wiki_test.go Use raw Wiki links for non-renderable Wiki files (#30273) 2024-04-10 17:49:57 +00:00
wiki.go