about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--.gitignore1
m---------ArcaneLibs0
-rw-r--r--CONTRIBUTING.MD30
-rw-r--r--LibMatrix.EventTypes/LibMatrix.EventTypes.csproj3
-rw-r--r--LibMatrix.EventTypes/deps.json0
-rw-r--r--LibMatrix.Federation/LibMatrix.Federation.csproj1
-rw-r--r--LibMatrix.Federation/deps.json22
-rw-r--r--LibMatrix/LibMatrix.csproj1
-rw-r--r--LibMatrix/deps.json12
-rw-r--r--README.MD29
-rw-r--r--Utilities/LibMatrix.Utilities.Bot/LibMatrix.Utilities.Bot.csproj1
-rw-r--r--flake.lock116
-rw-r--r--flake.nix94
-rwxr-xr-xscripts/fetchdeps.sh5
-rwxr-xr-xscripts/publish.sh20
15 files changed, 306 insertions, 29 deletions
diff --git a/.gitignore b/.gitignore

index 509a921..c6629e3 100644 --- a/.gitignore +++ b/.gitignore
@@ -12,3 +12,4 @@ appsettings.Local*.json appservice.yaml appservice.json Tests/LibMatrix.Tests/appsettings.json +result diff --git a/ArcaneLibs b/ArcaneLibs -Subproject 65bd14a92cc24c62b5ae298086987a3eed067ca +Subproject 6fd695c339b851d971a88422ee8875b4b4d2c9f diff --git a/CONTRIBUTING.MD b/CONTRIBUTING.MD new file mode 100644
index 0000000..8c305b7 --- /dev/null +++ b/CONTRIBUTING.MD
@@ -0,0 +1,30 @@ +# Contributing + +Any contribution is welcome, even if it's just documentation or recommended git practices! We're not too strict on code style, but we do have a few guidelines: +- Use spaces, not tabs +- Use 4 spaces for indentation +- Use the C# naming convention for variables, methods, etc. +- Wrap lines at 160 characters, though this value can be changed if it's too lean or strict +- Use the `#region` and `#endregion` directives to group code if you're adding utility functions + +```sh +# Prepare patch set +mkdir patches +git format-patch --output-directory "./patches" @{u}.. + +# Send patches +... +``` +You can send the patches to [@emma:rory.gay](https://matrix.to/#/@emma:rory.gay) or in the [Rory&::LibMatrix room](https://matrix.to/#/#libmatrix:rory.gay). + +### Developer utility commands + +Error reporting upon file save (may not work): +```sh +inotifywait -rmqe CLOSE_WRITE --include '.*\.cs$' . | while read l; do clear; dotnet build --property WarningLevel=0; done +``` + +Hot rebuild on file save: +```sh +dotnet watch run --no-hot-reload --property WarningLevel=0 +``` diff --git a/LibMatrix.EventTypes/LibMatrix.EventTypes.csproj b/LibMatrix.EventTypes/LibMatrix.EventTypes.csproj
index 20346ad..31dfe16 100644 --- a/LibMatrix.EventTypes/LibMatrix.EventTypes.csproj +++ b/LibMatrix.EventTypes/LibMatrix.EventTypes.csproj
@@ -9,7 +9,8 @@ <ItemGroup> <!-- <PackageReference Include="ArcaneLibs" Version="1.0.0-preview.20250806-011111" Condition="'$(Configuration)' == 'Release'" />--> <!-- <ProjectReference Include="..\ArcaneLibs\ArcaneLibs\ArcaneLibs.csproj" Condition="'$(Configuration)' == 'Debug'"/>--> - <ProjectReference Include="..\ArcaneLibs\ArcaneLibs\ArcaneLibs.csproj"/> + <ProjectReference Include="..\ArcaneLibs\ArcaneLibs\ArcaneLibs.csproj" Condition="'$(ContinuousIntegrationBuild)'!='true'"/> + <PackageReference Include="ArcaneLibs" Version="*-*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/> </ItemGroup> </Project> diff --git a/LibMatrix.EventTypes/deps.json b/LibMatrix.EventTypes/deps.json new file mode 100644
index 0000000..e69de29 --- /dev/null +++ b/LibMatrix.EventTypes/deps.json
diff --git a/LibMatrix.Federation/LibMatrix.Federation.csproj b/LibMatrix.Federation/LibMatrix.Federation.csproj
index b5cb7b2..851bf25 100644 --- a/LibMatrix.Federation/LibMatrix.Federation.csproj +++ b/LibMatrix.Federation/LibMatrix.Federation.csproj
@@ -9,6 +9,7 @@ <ItemGroup> <ProjectReference Include="..\LibMatrix\LibMatrix.csproj"/> + <PackageReference Include="LibMatrix" Version="*-*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/> </ItemGroup> <ItemGroup> diff --git a/LibMatrix.Federation/deps.json b/LibMatrix.Federation/deps.json new file mode 100644
index 0000000..cccc7bb --- /dev/null +++ b/LibMatrix.Federation/deps.json
@@ -0,0 +1,22 @@ +[ + { + "pname": "BouncyCastle.Cryptography", + "version": "2.6.2", + "hash": "sha256-Yjk2+x/RcVeccGOQOQcRKCiYzyx1mlFnhS5auCII+Ms=" + }, + { + "pname": "Microsoft.Extensions.DependencyInjection.Abstractions", + "version": "10.0.0-rc.2.25502.107", + "hash": "sha256-1nh8z2nglCizQkl0iWwJ/au4BAuuBu0xghKHGBeTM1I=" + }, + { + "pname": "Microsoft.Extensions.Logging.Abstractions", + "version": "10.0.0-rc.2.25502.107", + "hash": "sha256-krml7WL+lF7oiYOvQ8NHQp7BVpHJrLIHhyxUgkHO+WE=" + }, + { + "pname": "Microsoft.Extensions.Primitives", + "version": "10.0.0-rc.2.25502.107", + "hash": "sha256-jvjZK/c8TGYIUA4zw7yR9uAFJmw90YE7TD3+DaxX9Ls=" + } +] diff --git a/LibMatrix/LibMatrix.csproj b/LibMatrix/LibMatrix.csproj
index 61810a3..7d4ca5c 100644 --- a/LibMatrix/LibMatrix.csproj +++ b/LibMatrix/LibMatrix.csproj
@@ -21,6 +21,7 @@ <!-- <PackageReference Include="ArcaneLibs" Version="1.0.0-preview.20250313-104848" Condition="'$(Configuration)' == 'Release'" />--> <!-- <ProjectReference Include="..\ArcaneLibs\ArcaneLibs\ArcaneLibs.csproj" Condition="'$(Configuration)' == 'Debug'"/>--> <ProjectReference Include="..\ArcaneLibs\ArcaneLibs\ArcaneLibs.csproj"/> + <PackageReference Include="ArcaneLibs" Version="*-*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/> </ItemGroup> </Project> diff --git a/LibMatrix/deps.json b/LibMatrix/deps.json new file mode 100644
index 0000000..d6ba81b --- /dev/null +++ b/LibMatrix/deps.json
@@ -0,0 +1,12 @@ +[ + { + "pname": "Microsoft.Extensions.DependencyInjection.Abstractions", + "version": "10.0.0-rc.2.25502.107", + "hash": "sha256-1nh8z2nglCizQkl0iWwJ/au4BAuuBu0xghKHGBeTM1I=" + }, + { + "pname": "Microsoft.Extensions.Logging.Abstractions", + "version": "10.0.0-rc.2.25502.107", + "hash": "sha256-krml7WL+lF7oiYOvQ8NHQp7BVpHJrLIHhyxUgkHO+WE=" + } +] diff --git a/README.MD b/README.MD
index 31915d4..85a8137 100644 --- a/README.MD +++ b/README.MD
@@ -11,31 +11,4 @@ Probably add as a submodule for now? NuGet packaging still has to be implemented # Contributing -Any contribution is welcome, even if it's just documentation or recommended git practices! We're not too strict on code style, but we do have a few guidelines: -- Use spaces, not tabs -- Use 4 spaces for indentation -- Use the C# naming convention for variables, methods, etc. -- Wrap lines at 160 characters, though this value can be changed if it's too lean or strict -- Use the `#region` and `#endregion` directives to group code if you're adding utility functions - -```sh -# Prepare patch set -mkdir patches -git format-patch --output-directory "./patches" @{u}.. - -# Send patches -... -``` -You can send the patches to [@emma:rory.gay](https://matrix.to/#/@emma:rory.gay) or in the [Rory&::LibMatrix room](https://matrix.to/#/#libmatrix:rory.gay). - -### Developer utility commands - -Error reporting upon file save (may not work): -```sh -inotifywait -rmqe CLOSE_WRITE --include '.*\.cs$' . | while read l; do clear; dotnet build --property WarningLevel=0; done -``` - -Hot rebuild on file save: -```sh -dotnet watch run --no-hot-reload --property WarningLevel=0 -``` +See the [contributing guidelines](CONTRIBUTING.md) for more information. \ No newline at end of file diff --git a/Utilities/LibMatrix.Utilities.Bot/LibMatrix.Utilities.Bot.csproj b/Utilities/LibMatrix.Utilities.Bot/LibMatrix.Utilities.Bot.csproj
index 6c8b322..80d43be 100644 --- a/Utilities/LibMatrix.Utilities.Bot/LibMatrix.Utilities.Bot.csproj +++ b/Utilities/LibMatrix.Utilities.Bot/LibMatrix.Utilities.Bot.csproj
@@ -9,6 +9,7 @@ <ItemGroup> <ProjectReference Include="..\..\LibMatrix\LibMatrix.csproj"/> + <PackageReference Include="LibMatrix" Version="*-*" Condition="'$(ContinuousIntegrationBuild)'=='true'"/> </ItemGroup> <ItemGroup> diff --git a/flake.lock b/flake.lock new file mode 100644
index 0000000..7601b18 --- /dev/null +++ b/flake.lock
@@ -0,0 +1,116 @@ +{ + "nodes": { + "arcanelibs": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1762221395, + "narHash": "sha256-32HqkPZ/bBaoND33MBJQMtuSec2fjvM3rDNPtbVd5lQ=", + "owner": "TheArcaneBrony", + "repo": "ArcaneLibs", + "rev": "6fd695c339b851d971a88422ee8875b4b4d2c9f0", + "type": "github" + }, + "original": { + "owner": "TheArcaneBrony", + "repo": "ArcaneLibs", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1731533236, + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1762363567, + "narHash": "sha256-YRqMDEtSMbitIMj+JLpheSz0pwEr0Rmy5mC7myl17xs=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "ae814fd3904b621d8ab97418f1d0f2eb0d3716f4", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "arcanelibs": "arcanelibs", + "flake-utils": "flake-utils_2", + "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" + } + }, + "systems_2": { + "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..60dc085 --- /dev/null +++ b/flake.nix
@@ -0,0 +1,94 @@ +{ + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs.arcanelibs.url = "github:TheArcaneBrony/ArcaneLibs"; + inputs.arcanelibs.inputs.nixpkgs.follows = "nixpkgs"; + + outputs = + { + self, + nixpkgs, + flake-utils, + arcanelibs, + }: + let + pkgs = nixpkgs.legacyPackages.x86_64-linux; + rVersion = + let + rev = self.sourceInfo.shortRev or self.sourceInfo.dirtyShortRev; + date = builtins.substring 0 8 self.sourceInfo.lastModifiedDate; + time = builtins.substring 8 6 self.sourceInfo.lastModifiedDate; + in + "preview.${date}-${time}+${rev}"; + + makeNupkg = + { + name, + nugetDeps ? null, + projectReferences ? [ ], + projectFile ? "${name}/${name}.csproj", + }: + pkgs.buildDotnetModule rec { + inherit projectReferences nugetDeps; + + pname = "${name}"; + version = "1.0.0-" + rVersion; + dotnetPackFlags = [ + "--include-symbols" + "--include-source" + "--version-suffix ${rVersion}" + ]; + # dotnetFlags = [ "-v:diag" ]; + dotnet-sdk = pkgs.dotnet-sdk_10; + dotnet-runtime = pkgs.dotnet-aspnetcore_10; + src = ./.; + projectFile = [ + "${name}/${name}.csproj" + ]; + packNupkg = true; + meta = with pkgs.lib; { + description = "Rory&::LibMatrix"; + homepage = "https://cgit.rory.gay/matrix/LibMatrix.git"; + license = licenses.agpl3Plus; + maintainers = with maintainers; [ RorySys ]; + }; + }; + in + { + packages.x86_64-linux = + let + # HACKHACK: trim version string until nuget learns to deal with semver properly + # See: https://github.com/NuGet/Home/issues/14628 + ArcaneLibs = arcanelibs.packages."${pkgs.stdenv.hostPlatform.system}".ArcaneLibs.overrideAttrs (old: { + __intentionallyOverridingVersion = true; + version = builtins.substring 0 29 old.version; # "1.0.0-preview-20251106-123456"; + }); + LibMatrix = self.packages."${pkgs.stdenv.hostPlatform.system}".LibMatrix.overrideAttrs (old: { + __intentionallyOverridingVersion = true; + version = builtins.substring 0 29 old.version; # "1.0.0-preview-20251106-123456"; + }); + in + { + LibMatrix = makeNupkg { + name = "LibMatrix"; + nugetDeps = LibMatrix/deps.json; + projectReferences = [ ArcaneLibs ]; + }; + LibMatrix-EventTypes = makeNupkg { + name = "LibMatrix.EventTypes"; + projectReferences = [ + ArcaneLibs + LibMatrix + ]; + }; + LibMatrix-Federation = makeNupkg { + name = "LibMatrix.Federation"; + nugetDeps = LibMatrix.Federation/deps.json; + projectReferences = [ + ArcaneLibs + LibMatrix + ]; + }; + }; + }; +} diff --git a/scripts/fetchdeps.sh b/scripts/fetchdeps.sh new file mode 100755
index 0000000..a93ff53 --- /dev/null +++ b/scripts/fetchdeps.sh
@@ -0,0 +1,5 @@ +#! /usr/bin/env sh +for p in `nix flake show --json | jq '.packages."x86_64-linux" | keys[]' -r` +do + nix build .\#${p}.passthru.fetch-deps && ./result ./${p//-/\.}/deps.json +done diff --git a/scripts/publish.sh b/scripts/publish.sh new file mode 100755
index 0000000..2fd910f --- /dev/null +++ b/scripts/publish.sh
@@ -0,0 +1,20 @@ +BASEDIR="$PWD" +rm ./result* *.nupkg + +for p in `nix flake show --json | jq '.packages."x86_64-linux" | keys[]' -r` +do + nix build .\#${p} -j4 -L --out-link ./result-${p//-/\.} & +done +wait + +for p in result*/share/nuget/packages/*/*/.unpacked +do + PNAME=$(basename `realpath "${p}/../.."`) + PRNAME=$(basename $(cd "${p}/../../../../../.." && echo $PWD)) + echo $PNAME: $PRNAME + cd "${p}" || continue + zip -db -ds 32k -9 -r "${BASEDIR}/${PNAME//./-}.nupkg" * + cd - + dotnet nuget push *.nupkg -k ${NUGET_KEY} --source https://api.nuget.org/v3/index.json --skip-duplicate + rm -rfv "${PRNAME}" "${PNAME//./-}.nupkg" +done \ No newline at end of file