about summary refs log tree commit diff
path: root/flake.nix
blob: 3349b4592536a12963c8c63e6b2216b0356bc806 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
{
  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",
        }@args:
        pkgs.buildDotnetModule rec {
          inherit projectReferences nugetDeps projectFile;

          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 = ./.;
          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
            ];
          };
          LibMatrix-Bot-Utils = makeNupkg {
            name = "LibMatrix.Utilities.Bot";
            nugetDeps = Utilities/LibMatrix.Utilities.Bot/deps.json;
            projectFile = "Utilities/LibMatrix.Utilities.Bot/LibMatrix.Utilities.Bot.csproj";
            projectReferences = [
              ArcaneLibs
              LibMatrix
            ];
          };
        };
      checks = pkgs.lib.attrsets.unionOfDisjoint {
        # Actual checks
      } self.packages;
    };

}