summary refs log tree commit diff
path: root/Rhea/Program.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Rhea/Program.cs')
-rw-r--r--Rhea/Program.cs67
1 files changed, 67 insertions, 0 deletions
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<RheaConfiguration>(); +builder.Services.AddSingleton<StoreMetaService>(); + +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<byte>(); + 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<byte> tbuf = []; + List<byte> 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