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

feat: provide a flake registry #17

Open
cafkafk opened this issue Oct 30, 2023 · 4 comments
Open

feat: provide a flake registry #17

cafkafk opened this issue Oct 30, 2023 · 4 comments

Comments

@cafkafk
Copy link
Owner

cafkafk commented Oct 30, 2023

So, the documentation is not comrehensive https://nixos.org/manual/nix/stable/command-ref/new-cli/nix3-registry.html#registry-format. But I've investigated the possibility of doing this a bit.

Doing something like e.g. this is the closest I've gotten:

{
  "flakes": [
    {
      "from": {
        "id": "rime",
        "type": "indirect"
      },
      "to": {
        "type": "tarball",
        "url": "http://rime.cx/http://rime.cx/v1/github/numtide/flake-utils/b/main.tar.gz"
      }
    }
  ],
  "version": 2
}

It might sadly be the case that there is just no easy way for us to do this in a way that supports arbitrary repositories. In that case, leaning on what we discussed on fedi, we might consider saving requests, allowing people to opt out with a query parameter like ?private=true, and having that populate a registry.json file.

I'm not itching to implement this yet, I'm hoping someone comes along and tells me there is a much easier, more elegant way to do this... 🤞

@algernon
Copy link
Collaborator

algernon commented Oct 30, 2023

An alternative idea: what if this wasn't part of Rime, but in another small service in front of it? As in, this new imaginary service (lets dub it glacier, aka lots of rime, if you squint a bit) would sit in front of Rime, and simply proxy everything to it. If it sees any 303 response that points outside of Rime, it'd save some properties of the request. It would also offer additional API endpoints, such as /v1/registry.json, and some others to aid in discovering flakes.

But before we go down either route, there's something that isn't very clear to me: what would be the use case for the registry? How would I, as an end user make use of it? With nixpkgs, the idea is that I'm able to refer to a package within nixpkgs as nixpkgs#foo. But if the registry only contains tarball references, that... doesn't sound very useful to me? Or would it download every tarball to see the flakes available within? The documentation is sadly not very clear about this works :/

@cafkafk
Copy link
Owner Author

cafkafk commented Oct 31, 2023

Yea I mean, the documentation is very lacking. Honestly what I hoped to get out of it, somehow (likely not possible currently) would be the ability to do something like rime#<forge>/user/repo. I think the registries basically only support github, but I feel like with a little bit of changes to nix, it could be very useful for doing stuff like we're doing.

what if this wasn't part of Rime, but in another small service in front of it

Definitely possible, although I'm not not sure if it is large enough to warrant more than a feature flag. Then again, the registry feature is very non obvious, so I honestly have no idea.

@algernon
Copy link
Collaborator

I think the rime#<forge>/user/repo thing should be possible if Rime didn't point to tarballs, but to git repos instead... Hmm.

I had a quick look at my own nix registry list, my first one is:

❯ nix registry list | head -n 1
system flake:nixpkgs path:/nix/store/fwpalmvh6cnphvvd6n362a5cq22ixniz-source?lastModified=1697226376&narHash=sha256-cumLLb1QOUtWieUnLGqo+ylNt3+fU8Lcv5Zl+tYbRUE=&rev=898cb2064b6e98b8c5499f37e81adbdf2925f7c5

The referenced directory appears to be an extracted tarball. So.... if we want to provide a registry, we'd have to provide not only a JSON, but a tarball with a flake.nix that has the packages. So the tarball referenced in the registry json would be one we generate, and the flake.nix within that would contain the packages themselves.

I'll try to do a bit of experimenting, to see how it works in practice.

@algernon
Copy link
Collaborator

On a related note, perhaps its worth having a look at NUR?

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

No branches or pull requests

2 participants