From e9f6b90683b402ba050cbe921da4bdf1fd0c9c31 Mon Sep 17 00:00:00 2001 From: Matteo Evola Date: Thu, 29 Oct 2026 17:59:11 +0100 Subject: [PATCH] build(nix): add flake to build, run and package the app Add a Nix flake providing a dev shell and a packaged build of the Avalonia app using buildDotnetModule. - NuGet dependencies are pinned in deps.json for the offline sandbox. - Single-file, ReadyToRun, trimming and AOT publish options are disabled for the Nix build only, since they require a self-contained publish and conflict with the Nix-provided runtime. - Install a desktop entry and icon.svg into the hicolor theme so the package shows up in application launchers. - Expose a lowercase ratiomaster-net alias in bin/. - Set meta.mainProgram so `nix run` works. --- .envrc | 1 + .gitignore | 2 + deps.json | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.lock | 61 ++++++++++++++++++++ flake.nix | 88 +++++++++++++++++++++++++++++ 5 files changed, 314 insertions(+) create mode 100644 .envrc create mode 100644 deps.json create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/.envrc @@ -0,0 +1 @@ +use flake diff --git a/.gitignore b/.gitignore index 3014bb9..ad58f3e 100644 --- a/.gitignore +++ b/.gitignore @@ -115,3 +115,5 @@ node_modules/ # Visual Studio workspace state .vs/ +/.direnv +result diff --git a/deps.json b/deps.json new file mode 100644 index 0000000..09987e9 --- /dev/null +++ b/deps.json @@ -0,0 +1,162 @@ +[ + { + "pname": "Avalonia", + "version": "12.1.4", + "hash": "sha256-kM+WOg5f7X/A5c2c7+PBWbeN4IYnLD3d6Ux1y4P5xKw=" + }, + { + "pname": "Avalonia.Angle.Windows.Natives", + "version": "2.1.27548.20260419", + "hash": "sha256-dtZ5AQl+kXPRVe/EwrfSyOMSLywuBBUCjrDIhHijhvk=" + }, + { + "pname": "Avalonia.BuildServices", + "version": "11.3.2", + "hash": "sha256-6wx06tjSKWQOlX2czdp6Wh0nuwVapx5qf/s8Qj5we40=" + }, + { + "pname": "Avalonia.Controls.DataGrid", + "version": "12.1.2", + "hash": "sha256-EKv+UnSScgONwbIY9NLTRHyGlK9QTCvXIT/bFP+13Go=" + }, + { + "pname": "Avalonia.Desktop", + "version": "12.1.4", + "hash": "sha256-XaV99PVtMvOJRHXahp01ValoCF9dk7c7P1ron3ClzVg=" + }, + { + "pname": "Avalonia.Fonts.Inter", + "version": "12.1.4", + "hash": "sha256-ttm0xKYJcJlilVO0AIUeEhJ2d8FBGOgsBC/3rtN6VIs=" + }, + { + "pname": "Avalonia.FreeDesktop", + "version": "12.1.4", + "hash": "sha256-5ol5EzhTOUOiRtNSIFXttEIpqhnreoIzgB8Niftj2nI=" + }, + { + "pname": "Avalonia.FreeDesktop.AtSpi", + "version": "12.1.4", + "hash": "sha256-2NKWgMF65G6Id3XmhA+Ww35oAW+e2su7e2LUU+VoVkk=" + }, + { + "pname": "Avalonia.HarfBuzz", + "version": "12.1.4", + "hash": "sha256-9S5cG2oAiG70aBbtL8miwohEKJsa8wvX6iR+Ig0gwMs=" + }, + { + "pname": "Avalonia.Native", + "version": "12.1.4", + "hash": "sha256-QY2/RSUnSMUpWpSENtZG7ZDVSlhy6DUkZ9GBWHvBtR0=" + }, + { + "pname": "Avalonia.Remote.Protocol", + "version": "12.1.4", + "hash": "sha256-4RX1FD7w/HRc8XG7kmrRCD7UyDPKl3oOsRvbDEFgX1w=" + }, + { + "pname": "Avalonia.Skia", + "version": "12.1.4", + "hash": "sha256-9C4S0G35KuEW5bqqxeAxnOwJDZkKMD7cGv0OfCAqbmk=" + }, + { + "pname": "Avalonia.Themes.Fluent", + "version": "12.1.4", + "hash": "sha256-CywxfuTbybEsnLVk1PmbEIcrZVpFDJGmasBj2QVqPDg=" + }, + { + "pname": "Avalonia.Win32", + "version": "12.1.4", + "hash": "sha256-dDq+riEPKHuEakLSkrLYzIWzRb743xOgHkgdJSCQuBs=" + }, + { + "pname": "Avalonia.X11", + "version": "12.1.4", + "hash": "sha256-wQF50to9DX36dbppioBnSjvtm1Gk06ROyCmDLGjm1pY=" + }, + { + "pname": "CommunityToolkit.Mvvm", + "version": "8.4.2", + "hash": "sha256-jLS1vo6V+fHsJs80HYT77oJE6IEC68fIgkLpYODjWAU=" + }, + { + "pname": "HarfBuzzSharp", + "version": "8.3.1.3", + "hash": "sha256-/+ZEhjpOs8B4tMPw3vDyuQqGGZHJEWvy3WaKMaDwmrU=" + }, + { + "pname": "HarfBuzzSharp.NativeAssets.Linux", + "version": "8.3.1.3", + "hash": "sha256-feWOna/8ncvmrq7CxnDczv1facV2poZV5R+OyCtocpU=" + }, + { + "pname": "HarfBuzzSharp.NativeAssets.macOS", + "version": "8.3.1.3", + "hash": "sha256-6WKsJ/jF9pHnaWcQvaezc5AV6flu3XsOxQs7i4BGYJs=" + }, + { + "pname": "HarfBuzzSharp.NativeAssets.WebAssembly", + "version": "8.3.1.3", + "hash": "sha256-arBiI82fXPjAqftqnG7Wc3BRzZ6+vKd7b58vQSWJVk0=" + }, + { + "pname": "HarfBuzzSharp.NativeAssets.Win32", + "version": "8.3.1.3", + "hash": "sha256-WNUQmLWVFSwBKT9x7UdhSz9T2FA7wibvwjuPew/3yUM=" + }, + { + "pname": "MicroCom.Runtime", + "version": "0.11.6", + "hash": "sha256-RTr200R3sZuyxi0XQ25ox2p1kVt5R1CbH/YBs21+eNg=" + }, + { + "pname": "Microsoft.Extensions.DependencyInjection", + "version": "10.0.12", + "hash": "sha256-uXnGMBkfbEi1SMrYZtgiSg7Q5ue+CrqH9FS1dZe2N3k=" + }, + { + "pname": "Microsoft.Extensions.DependencyInjection.Abstractions", + "version": "10.0.12", + "hash": "sha256-RmT6sKxLVriTUzP1nunngByKuW3nxXyztuuBkqWmHFU=" + }, + { + "pname": "SkiaSharp", + "version": "3.119.4", + "hash": "sha256-4ypEnTGUXAudFp61vGduHj9YmqtpiI5J1wP9wcOEwXY=" + }, + { + "pname": "SkiaSharp.NativeAssets.Linux", + "version": "3.119.4", + "hash": "sha256-+uBVQFmxEH73iI5GwgvftUhAHvenpvc5GtT63HQy1Qo=" + }, + { + "pname": "SkiaSharp.NativeAssets.macOS", + "version": "3.119.4", + "hash": "sha256-9/L1Oc5bujN6pKjW6sJcr1jL3RLt8/Mt3MmClOcwzyw=" + }, + { + "pname": "SkiaSharp.NativeAssets.WebAssembly", + "version": "3.119.4", + "hash": "sha256-xLfsWBsFFpv5Qg79GIMi+5CM6YDfcg//oywNlB5Y3J0=" + }, + { + "pname": "SkiaSharp.NativeAssets.Win32", + "version": "3.119.4", + "hash": "sha256-WlaYsbTh/cn/6YaN9odNtfpp8hpN52unGgGlQum0M5E=" + }, + { + "pname": "StyleCop.Analyzers", + "version": "1.2.0-beta.556", + "hash": "sha256-97YYQcr5vZxTvi36608eUkA1wb6xllZQ7UcXbjrYIfU=" + }, + { + "pname": "StyleCop.Analyzers.Unstable", + "version": "1.2.0.556", + "hash": "sha256-aVop7a9r+X2RsZETgngBm3qQPEIiPBWgHzicGSTEymc=" + }, + { + "pname": "Tmds.DBus.Protocol", + "version": "0.94.1", + "hash": "sha256-T3HQasQOcl/7zxt5hT3ZMhhpWoTyPTb6/IX0d6TJWA8=" + } +] diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..ef2f958 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1791914995, + "narHash": "sha256-Zf/xfQEAasnwnmEfHqW/4hjDE/s44yn2hD4RuVIZRjA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "b7a79d3fea1e214f6d668d521cecec0c01e26544", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1793110635, + "narHash": "sha256-dhoW6VgFWlaodSY5jrBn+CF2FLmaUvDVgM7+C7T2+NM=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "31ecbaca1bdefa45dffc409f0250bd8039ea0010", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..27a8a6a --- /dev/null +++ b/flake.nix @@ -0,0 +1,88 @@ +{ + description = "RatioMaster.NET - BitTorrent tracker simulator"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = + { + self, + nixpkgs, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { inherit system; }; + + runtimeLibs = with pkgs; [ + fontconfig + libx11 + libice + libsm + ]; + in + { + devShells.default = pkgs.mkShell { + buildInputs = [ + pkgs.dotnetCorePackages.sdk_10_0 + ] + ++ runtimeLibs; + + LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath runtimeLibs; + }; + + packages.default = pkgs.buildDotnetModule { + pname = "ratiomaster-net"; + version = "1.3.1"; + + src = ./.; + + projectFile = "src/RatioMaster.App/RatioMaster.App.csproj"; + nugetDeps = ./deps.json; + + dotnet-sdk = pkgs.dotnetCorePackages.sdk_10_0; + dotnet-runtime = pkgs.dotnetCorePackages.runtime_10_0; + + selfContainedBuild = false; + + nativeBuildInputs = [ pkgs.copyDesktopItems ]; + + desktopItems = [ + (pkgs.makeDesktopItem { + name = "RatioMaster.NET"; + desktopName = "RatioMaster.NET"; + exec = "RatioMaster.NET"; + icon = "ratiomaster-net"; + comment = "BitTorrent tracker simulator"; + categories = [ "Network" ]; + }) + ]; + + dotnetFlags = [ + "-p:PublishSingleFile=false" + "-p:EnableCompressionInSingleFile=false" + "-p:PublishReadyToRun=false" + "-p:PublishTrimmed=false" + "-p:PublishAot=false" + ]; + + executables = [ "RatioMaster.NET" ]; + + runtimeDeps = runtimeLibs; + + postInstall = '' + install -Dm644 icon.svg $out/share/icons/hicolor/scalable/apps/ratiomaster-net.svg + ''; + + postFixup = '' + ln -s $out/bin/RatioMaster.NET $out/bin/ratiomaster-net + ''; + + meta.mainProgram = "RatioMaster.NET"; + }; + } + ); +}