~sircmpwn/sr.ht-discuss

7 4

Public API usage

Details
Message ID
<20211006040446.unarhltnmrohbfmy@atlas>
DKIM signature
missing
Download raw message
Hello, Drew!

First of all, i would like to congratulate you on this amazing service. 
It's been a huge joy trying sourcehut out for my personal and school 
projects, it's by far the best experience i've ever had with a software 
forge. I love the build system, and it's been overall great being in an 
ecossystem created by someone that strongly stands for what i believe in.


Here's a request/suggestion i have. And some background on it.
(TLDR At bottom)


I use Nix for most of my workflow, and the tooling allows us to refer to 
any nix flake[1]-enabled repository, for consuming nix libs and modules, 
accessing derivations/packages, etc. These can even require other 
nix-enabled repos and so on, building (usually small) dependency graphs.

While we can sure refer to any repo in an host agnostic way (something 
like "git+https://git.somehost.tld/user/path?ref=branch"), we also have 
shortcuts for gitlab and github (like gitlab:user/repo), these can 
automatically resolve revs, download tarballs, etc, without cloning down 
the repo, plus allows for service-specific authorization (OAuth) for 
accessing private repos.

I have a patch that enables such a shorthand for soucehut. And would like 
to upstream it.

For a quick example, i can refer to my personal website flake by using 
`git+https://git.sr.ht/~misterio/misterio.me?ref=main`, my patch allows 
me to do that with simply `sourcehut:~misterio/misterio.me`, and build 
my website from anywhere with a single (and easy to type) command:
`nix build sourcehut:~misterio/misterio.me`

The issue is i need a way to resolve revs into commit ids. The GraphQL 
API works amazingly well for this. That is, if i create and pass on a PAT.

It would be a lot better if public repos' revs could be resolved through 
the API without requiring authentication. As is now, this would expose 
considerable complexity for someone just consuming a dependency graph 
that includes a sourcehut repo. Making the shorthand effectively unusable.

It would be awesome if this worked with zero setup for public repos.

[1]: https://nixos.wiki/wiki/Flakes



So long story short:
Are there any plans to make the (very nice) API publicly accessible, so 
it can be easier to use it to query public resources? I'm very interested 
in it. It might be interesting for other people's usecases too.


I'm sorry if i got a bit carried away or was overly detailed.

Thanks a lot for your attention,
-- 
Gabriel Fontes

https://misterio.me
PGP: 7088 C742 1873 E0DB 97FF 17C2 245C AB70 B4C2 25E9
Details
Message ID
<CES174AXXP2D.G6U74PWMFGM6@nix>
In-Reply-To
<20211006040446.unarhltnmrohbfmy@atlas> (view parent)
DKIM signature
missing
Download raw message
I know I am not directed at, but this is a public mailing lists
for users as well, so I want to chime it (-;

> For a quick example, i can refer to my personal website flake by using 
> `git+https://git.sr.ht/~misterio/misterio.me?ref=main`, my patch allows 
> me to do that with simply `sourcehut:~misterio/misterio.me`, and build 
> my website from anywhere with a single (and easy to type) command:
> `nix build sourcehut:~misterio/misterio.me`

What is wrong with the current argument if I may ask?  While sr.ht
seems to be the only public instance at the moment, SourceHut
is free software and the maintainers encourage hosting it, so a redirect
from sourcehut scheme to *.sr.ht would not make sense.  Plus, hg is also
supported.

I don't use flakes but I think if you want default branch inference
it can be done with existing information from a clone.  It would be
cheaper to clone only the specified branch but I think it's a fair cost
for implicity.

In addition, I think git.sr.ht only generates tarballs for tags
by design, but I'll wait for the maintainers to confirm this.
I do not recall if private repositories will be clonable via HTTPS
with OAuth or SSH is the only option though.
Details
Message ID
<20211006050833.mxc6bxodhnokvjom@atlas>
In-Reply-To
<CES174AXXP2D.G6U74PWMFGM6@nix> (view parent)
DKIM signature
missing
Download raw message
(Sorry for double posting, i accidently forgot to reply-all)

>I know I am not directed at, but this is a public mailing lists
>for users as well, so I want to chime it (-;

Thanks a lot for chiming in! Posting to the public list was intended :)

>What is wrong with the current argument if I may ask?  While sr.ht
>seems to be the only public instance at the moment, SourceHut
>is free software and the maintainers encourage hosting it, so a redirect
>from sourcehut scheme to *.sr.ht would not make sense.  Plus, hg is also
>supported.

IMHO, it's error prone and hard to remember. But, of course, it's just a=20
QOL.

About custom instances, this can be customized. Both the gitlab and=20
github shorthands can be pointed to third-party instances by changing=20
an attribute, if i'm not mistaken.

The url used in the request is actually factored out and just defaults=20
to `git.sr.ht`!

About hg, perhaps using `hgsourcehut` or `gitsourcehut` as shorthands=20
could make sense. But i think an attribute is a possibility too.

>I don't use flakes but I think if you want default branch inference
>it can be done with existing information from a clone.  It would be
>cheaper to clone only the specified branch but I think it's a fair cost
>for implicity.

I've just scrapped at the surface of Nix, but i think the shorthands=20
have some more advantages besides the simplicity.

They can be resolved to a lock without a clone, for instance (if i'm not=20
mistaken).

I'm pretty sure the default branch isn't inferred when using the generic=20
syntax, as i have to always specify "main", or it defaults to "master".

This doesn't work:
`nix build git+https://git.sr.ht/~misterio/misterio.me`

While this does:
`nix build git+https://git.sr.ht/~misterio/misterio.me?ref=3Dmain`

A lot of stuff to type, IMHO.

>In addition, I think git.sr.ht only generates tarballs for tags
>by design, but I'll wait for the maintainers to confirm this.
>I do not recall if private repositories will be clonable via HTTPS
>with OAuth or SSH is the only option though.

It does generate tarballs for any commits, here's an example:
https://git.sr.ht/~misterio/nix-config/archive/a5a7d35f.tar.gz

You're right about private repos, just tested it and (although the=20
commit id does resolve), using OAuth does not allow access to private=20
repos' tarballs.



You said you currently don't use flakes, but if you're interested,=20
here's my patch (it is working as intended, you just need to pass in=20
your PAT with NIX_CONFIG=3D"access-tokens =3D git.sr.ht=3D123abcxyz"):
https://git.sr.ht/~misterio/nix-config/tree/a5a7d35f/item/overlays/nix-sour=
cehut.patch

Overall, i understand it might not be a huge priority thing, but i'm=20
sure public API access can be useful for a lot of different use cases.

Having an easy to remember shorthand for using sourcehut repos on my=20
flakes would make me use it even more :)

Again, thanks for chiming in!
-- 
Gabriel Fontes

https://misterio.me
PGP: 7088 C742 1873 E0DB 97FF 17C2 245C AB70 B4C2 25E9
Details
Message ID
<CES3BEZZDKX6.11SPQ2E85YDSL@taiga>
In-Reply-To
<20211006040446.unarhltnmrohbfmy@atlas> (view parent)
DKIM signature
missing
Download raw message
I intend to implement at least some form of anonymous GraphQL access in
the foreseeable future, but the plans are presently vague and
ill-defined.
Details
Message ID
<87sfxe7k6v.fsf@zenithia.net>
In-Reply-To
<CES174AXXP2D.G6U74PWMFGM6@nix> (view parent)
DKIM signature
missing
Download raw message
Nguyễn Gia Phong <mcsinyx@disroot.org> writes:

> What is wrong with the current argument if I may ask?  While sr.ht
> seems to be the only public instance at the moment, SourceHut
> is free software and the maintainers encourage hosting it, so a redirect
> from sourcehut scheme to *.sr.ht would not make sense.  Plus, hg is also
> supported.

My understanding(*) is that usually the project is called Sourcehut and
this particular instance is called sr.ht, so perhaps srht: would make
more sense as a shortcut prefix?

I'm sure there are other instances, and likely will be many more in the
future, but sr.ht is sort of the marquee instance, IMO.

*: I can't find anything explicitly saying this other than this first
 line on the pricing page:  "sr.ht is the hosted instance of sourcehut
 and provides paid services to its users."

--
Ted Reed
Details
Message ID
<20211006143012.mke3up4vcqqmncmc@atlas>
In-Reply-To
<87sfxe7k6v.fsf@zenithia.net> (view parent)
DKIM signature
missing
Download raw message
Hey!

>My understanding(*) is that usually the project is called Sourcehut and
>this particular instance is called sr.ht, so perhaps srht: would make
>more sense as a shortcut prefix?

Actually, this is not for a specific host, but for a repository "kind". 
For example, the "gitlab" type works for any and all gitlab instances. 
That's why i personally think sourcehut makes more sense than srht, 
as this refers to the software, not the specific instance.

Here's an example flake referring to gitgud.io's gitlab instance:

```
{
   description = "example";

   inputs.foobar = {
     type = "gitlab";
     owner = "misterio";
     repo = "testitytest";
     host = "gitgud.io";
   };

   outputs = { self, foobar }: {
     test = foobar.example;
   };
}
```

The shorthand syntax is kind of a bonus that comes from implementing 
a "type", and it just defaults to the official instance.

Regards,
-- 
Gabriel Fontes

https://misterio.me
PGP: 7088 C742 1873 E0DB 97FF 17C2 245C AB70 B4C2 25E9
Details
Message ID
<20211006143557.dyuonoviykldogox@atlas>
In-Reply-To
<CES3BEZZDKX6.11SPQ2E85YDSL@taiga> (view parent)
DKIM signature
missing
Download raw message
>I intend to implement at least some form of anonymous GraphQL access in
>the foreseeable future, but the plans are presently vague and
>ill-defined.

Thank you, Drew.

-- 
Gabriel Fontes

https://misterio.me
PGP: 7088 C742 1873 E0DB 97FF 17C2 245C AB70 B4C2 25E9
Details
Message ID
<87o8817fle.fsf@zenithia.net>
In-Reply-To
<20211006143012.mke3up4vcqqmncmc@atlas> (view parent)
DKIM signature
missing
Download raw message
Gabriel Fontes <eu@misterio.me> writes:

> Actually, this is not for a specific host, but for a repository "kind". For
> example, the "gitlab" type works for any and all gitlab instances. That's why i
> personally think sourcehut makes more sense than srht, as this refers to the
> software, not the specific instance.
>
> [...]
>
> The shorthand syntax is kind of a bonus that comes from implementing a "type",
> and it just defaults to the official instance.

Oh, that's really neat. I've been trying to wait for stabilization
before really getting into flakes. Given this, then I agree sourcehut as
a name probably makes sense.

--
Ted Reed
Reply to thread Export thread (mbox)