-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Gitea fetcher for flake inputs #11467
base: master
Are you sure you want to change the base?
Conversation
2294074
to
7b3f824
Compare
Actually one can just download a gitea tarball without git. You just need a new enough gitea version that implements the lockable tarball protocol. Than you can do things like this: https://github.com/Mic92/dotfiles/blob/9544bdacad1c8c46289fbcf0b2973df5ff2a3a03/flake.nix#L19
|
I am not sure if this allows header authentication, probably not, so gitea inputs would still be nice to have. |
* `gitea:redict/redict` | ||
* `gitea:redict/redict/main` | ||
* `gitea:redict/redict/a4c81102327bc2c74d229784a1d1dd680c708918` | ||
* `gitea:lix-project/lix?host=git.lix.systems` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we actually should default to codeberg and not just make the host part of the url? This doesn't look much more complex and promotes self-hosting (which is in the spirit of gitea):
* `gitea:lix-project/lix?host=git.lix.systems` | |
* `gitea:git.lix.systems/lix-project/lix` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we should also support this?
gitea:git.lix.systems/some-subdirectory/lix-project/lix
Also some-subdirectory could become a url parameter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that we should support sub-directory. Though, I'd like to keep the host
argument, so the URL doesn't feel to far off compared to the existing github:
and sourcehut:
URL types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* `gitea:git.lix.systems/some-subdirectory/lix-project/lix`
Also some-subdirectory could become a url parameter
What do you mean by subdirectories?
Subdirectories in the gitea repository are already supported with the dir
url parameter.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if we actually should default to codeberg and not just make the host part of the url? This doesn't look much more complex and promotes self-hosting (which is in the spirit of gitea):
I don't think we should actually default to codeberg becuase. I just use codeberg and wanted to quickly simplify my flakes.
I currently have an implementation which requires the specification of the host in the url in the gitea-fetcher-explicit-url branch
of my fork.
But currently it makes the host
parameter useless since it requires it in the scheme.
adding a gitea type to the flake inputs usable with inputs.input.url = "gitea:repo/owner" the default host is codeberg.org, because it the most popular and most used gitea/forgejo based code forge. host can be changed with ?host=gitea.instance advantage over git+https: git+https://gitea.instance/repo/owner requires git while this new fetcher allows downloading the tarball from gitea. Closes: NixOS#11135 Signed-off-by: Tilman Andre Mix <[email protected]>
Signed-off-by: Tilman Andre Mix <[email protected]>
7b3f824
to
aad7eea
Compare
Can you add a release note? Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this produce an impure git archive
"export" tarball, or a pure translation of Git objects into a tarball, like you get when requesting a tarball for a tree hash from GitHub instead of a commit?
I believe it has the former impure behavior, which we should avoid, because it creates discrepancies between Git-based fetching and tarball-based fetching, which is highly unexpected for users, because they think locking to a commit hash is good enough - a reasonable expectation when you're not thinking of the nastiness in git archive
.
Litmus test: if you could implement this with the git protocol instead of a tarball and get the exact same result, even when using export-ignore
, export-subst
, submodules, smudge filters, etc, then we're good.
Last time I checked the code tarballs in gitea were implemented using |
Are git archives not reproducible or what does make them impure? |
This issue has an example EDIT: the problem is probably with |
So the issue is closed now, are submodules still an issue? |
That issue was reported for the git fetcher, but this new gitea fetcher is tarball based, and gitea returns such broken tarballs if you pass the commit hash.
I've confused the default value for the submodules flag in the git fetcher. We had discussed enabling it by default, but we haven't so this may not be a concern.
|
Ah. Right. I mixed things up here. |
Maybe this should be then doing a shallow git clone. Afaik the gitea token can be also used via http. |
RefInfo getRevFromRef(nix::ref<Store> store, const Input & input) const override | ||
{ | ||
auto host = getHost(input); | ||
auto url = fmt("https://%s/api/v1/repos/%s/%s/commits?sha=%s", host, getOwner(input), getRepo(input), *input.getRef()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about http with the s? Might be used for testing.
So gitea does internally just do a |
Git over HTTP with token sounds like a good future proof solution. |
Motivation
The current way of fetching repos from Gitea/Forgejo requires the git exectable,
this fetcher for flake inputs works like the github one by downloading the tarball
adding a gitea type to the flake inputs
usable with inputs.input.url = "gitea:repo/owner"
the default host is codeberg.org, because it the most popular
and most used gitea/forgejo based code forge.
host can be changed with ?host=gitea.instance
advantage over git+https:
git+https://gitea.instance/repo/owner requires git
while this new fetcher allows downloading the tarball
from gitea.
Context
Closes: #11135
This work is based on the already existing github fetcher