From f3d4f84fde24bb92e7cf6a22d94a703c753f3cbe Mon Sep 17 00:00:00 2001 From: Rory& Date: Fri, 14 Aug 2026 05:21:15 +0200 Subject: Working files and symlinks? --- Rhea/Controllers/MetaController.cs | 17 +++++++++++++++++ Rhea/Controllers/NarController.cs | 20 ++++++++++++++++++++ Rhea/Controllers/NarInfoController.cs | 32 ++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 Rhea/Controllers/MetaController.cs create mode 100644 Rhea/Controllers/NarController.cs create mode 100644 Rhea/Controllers/NarInfoController.cs (limited to 'Rhea/Controllers') diff --git a/Rhea/Controllers/MetaController.cs b/Rhea/Controllers/MetaController.cs new file mode 100644 index 0000000..ca20e99 --- /dev/null +++ b/Rhea/Controllers/MetaController.cs @@ -0,0 +1,17 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Rhea.Controllers; + +[ApiController] +public class MetaController(RheaConfiguration cfg) : ControllerBase +{ + [HttpGet("/nix-cache-info")] + public async Task GetNixCacheInfo() + { + return $""" + StoreDir: {cfg.StorePath} + WantMassQuery: 1 + Priority: 5 + """; + } +} \ No newline at end of file diff --git a/Rhea/Controllers/NarController.cs b/Rhea/Controllers/NarController.cs new file mode 100644 index 0000000..7ba44ba --- /dev/null +++ b/Rhea/Controllers/NarController.cs @@ -0,0 +1,20 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Rhea.Controllers; + +[ApiController] +public class NarController(RheaConfiguration cfg, StoreMetaService storeSvc) : ControllerBase +{ + [HttpHead("/nar/{hash}.nar.zst")] + public async Task CheckNixNarExists(string hash) + { + var path = await storeSvc.GetStorePathByBaseName(hash); + Response.StatusCode = string.IsNullOrWhiteSpace(path) ? 404 : 200; + } + + [HttpGet("/nar/{hash}.nar.zst")] + public async Task GetNixCacheInfo() + { + return ""; + } +} \ No newline at end of file diff --git a/Rhea/Controllers/NarInfoController.cs b/Rhea/Controllers/NarInfoController.cs new file mode 100644 index 0000000..b81b655 --- /dev/null +++ b/Rhea/Controllers/NarInfoController.cs @@ -0,0 +1,32 @@ +using Microsoft.AspNetCore.Mvc; + +namespace Rhea.Controllers; + +[ApiController] +public class NarInfoController(RheaConfiguration cfg, StoreMetaService storeSvc) : ControllerBase +{ + [HttpHead("/{hash}.narinfo")] + public async Task CheckNixNarExists(string hash) + { + var path = await storeSvc.GetStorePathByBaseName(hash); + Response.StatusCode = string.IsNullOrWhiteSpace(path) ? 404 : 200; + } + + [HttpGet("/{hash}.narinfo")] + public async Task GetNixNarInfo(string hash) + { + var path = await storeSvc.GetStorePathByBaseName(hash); + + return $""" + StorePath: {cfg.StorePath}/{path} + URL: nar/09d83cyl9dlfkkbspkgkk7bfydj3mvw6r1x98kvc2v8wl2xd8ldy.nar.zst + Compression: zstd + FileHash: sha256:0yzqbk88qqh0c7dswwcm27y1pxs5a83hga81vjmcs9d331psv1g8 + FileSize: 48255244 + NarHash: sha256:09d83cyl9dlfkkbspkgkk7bfydj3mvw6r1x98kvc2v8wl2xd8ldy + NarSize: 209581048 + Sig: cache.nixos.org-1:sRYhPUkDDRCgZDlgPMvXYEgYvX3GF24wT0v6HOUrtB/4g5lZffgRksiSmsth2wKRPlMijKP/yoDkG4NZDJfJCA== + CA: fixed:r:sha256:09d83cyl9dlfkkbspkgkk7bfydj3mvw6r1x98kvc2v8wl2xd8ldy + """; + } +} \ No newline at end of file -- cgit 1.5.1