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/Program.cs | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 Rhea/Program.cs (limited to 'Rhea/Program.cs') diff --git a/Rhea/Program.cs b/Rhea/Program.cs new file mode 100644 index 0000000..a7310b4 --- /dev/null +++ b/Rhea/Program.cs @@ -0,0 +1,67 @@ +using System.Diagnostics; +using ArcaneLibs; +using ArcaneLibs.Extensions; +using ArcaneLibs.Extensions.Streams; +using Rhea; +using Rhea.Nar; + +var builder = WebApplication.CreateBuilder(args); + +// Add services to the container. + +builder.Services.AddControllers(); +// Learn more about configuring OpenAPI at https://aka.ms/aspnet/openapi +builder.Services.AddOpenApi(); +builder.Services.AddSingleton(); +builder.Services.AddSingleton(); + +var app = builder.Build(); + +// Configure the HTTP request pipeline. +if (app.Environment.IsDevelopment()) +{ + app.MapOpenApi(); +} + +app.UseAuthorization(); + +app.MapControllers(); + +new NarWriter().GetHeader().ToArray().HexDump(64); + + +foreach (var srcPath in (string[])["/etc/nix/nix.conf", FileUtils.GetBinDir() + "/Rhea.runtimeconfig.json"]) +{ + Console.WriteLine($"Original {srcPath}:"); + + var pe = new ProcessStartInfo("nix", ["nar", "dump-path", srcPath]) + { + RedirectStandardOutput = true + }; + var origBuf = new List(); + var pr = Process.Start(pe); + int b; + while ((b = pr.StandardOutput.BaseStream.ReadByte()) != -1) origBuf.Add((byte)b); + origBuf.ToArray().HexDump(64); + + Console.WriteLine($"\nNew {srcPath}:"); + List tbuf = []; + List buf = []; + foreach (var chunk in new NarWriter().GetNarStreamContents(srcPath)) + { + tbuf.AddRange(chunk); + buf.AddRange(chunk); + while (buf.Count > 64) + { + byte[] data = buf[..64].ToArray(); + buf = buf[64..]; + data.HexDump(64); + } + } + + buf.ToArray().HexDump(64); + + Console.WriteLine("Is equal: " + origBuf.SequenceEqual(tbuf)); +} + +// app.Run(); \ No newline at end of file -- cgit 1.5.1