Compare commits

..

2 commits

Author SHA1 Message Date
chayleaf 910055176f
matrix-appservice-discord: +1 patch 2024-06-11 22:48:54 +07:00
chayleaf 04ffe78439
update inputs 2024-06-11 22:48:50 +07:00
8 changed files with 41871 additions and 3701 deletions

View file

@ -95,33 +95,32 @@
# extended lib
lib = nixpkgs.lib // import ./lib.nix { inherit (nixpkgs) lib; };
# can't use callPackage ./pkgs here, idk why; use import instead
overlay' = args: self: super: import ./pkgs ({
overlay' = args: self: super: import (if args.pluginsOverlay or false then ./pkgs/nix-plugins-overlay.nix else ./pkgs) ({
pkgs = super;
pkgs' = self;
lib = super.lib;
inherit inputs;
} // args);
overlay = overlay' { };
nix-plugins-overlay = overlay' { pluginsOverlay = true; };
all-overlays = [ nix-plugins-overlay overlay ];
# I override some settings down the line, but overlays always stay the same
mkPkgs = config: import nixpkgs (config // {
overlays = config.overlays or [ ] ++ [ overlay ];
overlays = config.overlays or [ ] ++ all-overlays;
});
# this is actual config, it gets processed below
config = let
mkBpiR3 = args: config: config // rec {
mkBpiR3 = args: config: config // {
system = "aarch64-linux";
modules = config.modules or [ ] ++ [
({ _module.args.pkgs-kernel = import inputs.nixpkgs-kernel { inherit system; overlays = [ overlay ]; }; })
(import ./system/devices/bpi-r3-router.nix args)
];
};
routerConfig = rec {
system = "aarch64-linux";
modules = [
{
_module.args.server-config = self.nixosConfigurations.server.config;
_module.args.notnft = inputs.notnft.lib.${system};
}
{ _module.args.server-config = self.nixosConfigurations.server.config;
_module.args.notnft = inputs.notnft.lib.${system}; }
inputs.nixos-router.nixosModules.default
];
};
@ -154,7 +153,10 @@
};
in {
overlays.default = overlay;
overlays = {
default = overlay;
nix-plugins = nix-plugins-overlay;
};
packages = lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
@ -187,17 +189,18 @@
inherit (args) system;
# allow modules to access nixpkgs directly, use customized lib,
# and pass nixos-harware to let hardware modules import parts of nixos-hardware
specialArgs = {
inherit inputs lib;
specialArgs = { inherit inputs lib; } // args.specialArgs or { };
modules = [
{ _module.args = {
hardware = inputs.nixos-hardware.nixosModules;
} // args.specialArgs or { };
modules = args.modules or [ ]
++ [
pkgs-kernel = import inputs.nixpkgs-kernel { inherit (args) system; overlays = all-overlays; };
}; }
(getPrivSys hostname)
{ networking.hostName = lib.mkDefault hostname;
nixpkgs.overlays = [ overlay ]; }
nixpkgs.overlays = all-overlays; }
inputs.impermanence.nixosModule
]
++ args.modules or [ ]
++ map (x: ./system/modules/${x}) (builtins.attrNames (builtins.readDir ./system/modules))
# the following is NixOS home-manager module configuration. Currently unused, but I might start using it for some hosts later.
++ lib.optionals (home != { } && home.common.enableNixosModule or false) [
@ -211,7 +214,7 @@
{ nixpkgs = home.common.nixpkgs or { };
nix = home.common.nix or { }; }
({ config, pkgs, lib, ...}: {
nixpkgs.overlays = [ overlay ];
nixpkgs.overlays = all-overlays;
nix.package = lib.mkDefault pkgs.nixForNixPlugins; })
(getPrivUser hostname username)
];
@ -240,7 +243,7 @@
++ [
(getPrivUser hostname user)
({ pkgs, lib, ... }: {
nixpkgs.overlays = [ overlay ];
nixpkgs.overlays = all-overlays;
nix.package = lib.mkDefault pkgs.nixForNixPlugins;
})
];

View file

@ -11,7 +11,6 @@ let
sources = import ./_sources/generated.nix {
inherit (pkgs) fetchgit fetchurl fetchFromGitHub dockerTools;
};
nixForNixPlugins = pkgs.nixVersions.nix_2_18;
nur = import inputs.nur {
inherit pkgs;
nurpkgs = pkgs;
@ -95,48 +94,6 @@ in
stdenv = pkgs'.ccacheStdenv;
};
}
// lib.optionalAttrs isOverlay {
inherit nixForNixPlugins;
nix = nixForNixPlugins;
nixVersions = pkgs.nixVersions // {
stable = nixForNixPlugins;
unstable = nixForNixPlugins;
};
# Various patches to change Nix version of existing packages so they don't error out because of nix-plugins in nix.conf
/*nix-plugins = (pkgs.nix-plugins.override { nix = nixForNixPlugins; }).overrideAttrs (old: {
version = "13.0.0";
patches = [
(pkgs.fetchpatch {
# pull 16
url = "https://github.com/chayleaf/nix-plugins/commit/8f945cadad7f2e60e8f308b2f498ec5e16961ede.patch";
hash = "sha256-pOogMtjXYkSDtXW12TmBpGr/plnizJtud2nP3q2UldQ=";
})
];
});*/
harmonia = (pkgs.harmonia.override { nixVersions.nix_2_21 = nixForNixPlugins; }).overrideAttrs (old: rec {
version = "0.7.3";
src = old.src.override {
rev = "refs/tags/${old.pname}-v${version}";
hash = "sha256-XtnK54HvZMKZGSCrVD0FO5PQLMo3Vkj8ezUlsfqStq0=";
};
cargoDeps = pkgs.rustPlatform.importCargoLock { lockFile = "${src}/Cargo.lock"; };
});
nix-init = pkgs.nix-init.override { nix = nixForNixPlugins; };
nix-serve = pkgs.nix-serve.override { nix = nixForNixPlugins; };
nix-serve-ng = pkgs.nix-serve-ng.override { nix = nixForNixPlugins; };
hydra_unstable = (pkgs.hydra_unstable.override {
nix = nixForNixPlugins;
}).overrideAttrs (old: {
version = "2023-12-01";
# who cares about tests amirite
doCheck = false;
src = old.src.override {
rev = "4d1c8505120961f10897b8fe9a070d4e193c9a13";
hash = "sha256-vXTuE83GL15mgZHegbllVAsVdDFcWWSayPfZxTJN5ys=";
};
});
nurl = pkgs.nurl.override { nix = nixForNixPlugins; };
}
// import ./ccache.nix { inherit pkgs pkgs' lib sources; }
// import ../system/hardware/bpi-r3/pkgs.nix { inherit pkgs pkgs' lib sources; }
// import ../system/hardware/oneplus-enchilada/pkgs.nix { inherit inputs pkgs pkgs' lib sources; }

View file

@ -42,6 +42,28 @@ matrix-appservice-discord.overrideAttrs (old: {
hash = "sha256-1qb4Zah1XKzxTpVJqOOqz+TiXMFmnsIMZeuqJQdqSIA=";
name = "bridge-matrix-edits-2.patch";
})
# https://github.com/matrix-org/matrix-appservice-discord/pull/862
(fetchpatch {
url = "https://github.com/matrix-org/matrix-appservice-discord/commit/3106957ebd857bc88ba3f62182a61dd00275f2fc.patch";
hash = "sha256-Xf+TuWXNVqi+0YRwBbCkLcMfsYNxq1ZlsgLWpwjqPww=";
name = "discord-to-matrix-reactions-1.patch";
})
(fetchpatch {
url = "https://github.com/matrix-org/matrix-appservice-discord/commit/a8186874b03c545a8728892b299a4367776fc538.patch";
hash = "sha256-Hq2HY44hPeGPXI3MglyN7Am+NCNAHAbr2hYhXvDYtGk=";
name = "discord-to-matrix-reactions-2.patch";
})
(fetchpatch {
url = "https://github.com/matrix-org/matrix-appservice-discord/commit/da2c3b88c7dd4f3a679890c58f934e9b2ed775df.patch";
hash = "sha256-4NMAr+Ni+7pI/I007YH5Y+4ZwAhwg91/BXGvLVcO0BQ=";
name = "discord-to-matrix-reactions-3.patch";
})
(fetchpatch {
url = "https://github.com/matrix-org/matrix-appservice-discord/commit/a33f269c88c432c532d7816f180e5262d73ebf02.patch";
hash = "sha256-0WkfDkQsDoxfKH3MgPb893UPDPxeWueQwVSaxD2RKAw=";
name = "discord-to-matrix-reactions-4.patch";
})
./reactions-as-mxc-urls.patch
./disable-attachment-forwarding-to-matrix.patch
];
})

View file

@ -0,0 +1,100 @@
diff --git a/src/bot.ts b/src/bot.ts
index 4445aa6..8613b5a 100644
--- a/src/bot.ts
+++ b/src/bot.ts
@@ -1199,7 +1199,9 @@ export class DiscordBot {
public async OnMessageReactionAdd(reaction: Discord.MessageReaction, user: Discord.User | Discord.PartialUser) {
const message = reaction.message;
- const reactionName = reaction.emoji.name;
+ const reactionName = (reaction.emoji.id
+ ? await this.GetEmoji(reaction.emoji.name, reaction.emoji.animated, reaction.emoji.id) + "#" + reaction.emoji.name
+ : reaction.emoji.name);
log.verbose(`Got message reaction add event for ${message.id} with ${reactionName}`);
const storeEvent = await this.store.Get(DbEvent, {
@@ -1229,7 +1231,7 @@ export class DiscordBot {
const reactionEventId = await intent.underlyingClient.unstableApis.addReactionToEvent(
roomId,
eventId,
- reaction.emoji.id ? `:${reactionName}:` : reactionName
+ reactionName,
);
const event = new DbEvent();
@@ -1246,7 +1248,10 @@ export class DiscordBot {
public async OnMessageReactionRemove(reaction: Discord.MessageReaction, user: Discord.User | Discord.PartialUser) {
const message = reaction.message;
- log.verbose(`Got message reaction remove event for ${message.id} with ${reaction.emoji.name}`);
+ const reactionName = (reaction.emoji.id
+ ? await this.GetEmoji(reaction.emoji.name, reaction.emoji.animated, reaction.emoji.id) + "#" + reaction.emoji.name
+ : reaction.emoji.name);
+ log.verbose(`Got message reaction remove event for ${message.id} with ${reactionName}`);
const storeEvent = await this.store.Get(DbEvent, {
discord_id: message.id,
@@ -1274,7 +1279,7 @@ export class DiscordBot {
const underlyingClient = intent.underlyingClient;
- const { chunk } = await underlyingClient.unstableApis.getRelationsForEvent(
+ const { chunk } = await underlyingClient.getRelationsForEvent(
roomId,
eventId,
"m.annotation"
@@ -1285,7 +1290,7 @@ export class DiscordBot {
return false;
}
- return event.content["m.relates_to"].key === reaction.emoji.name;
+ return event.content["m.relates_to"].key === reactionName;
});
if (!event) {
@@ -1324,7 +1329,7 @@ export class DiscordBot {
const [ eventId, roomId ] = storeEvent.MatrixId.split(";");
const underlyingClient = this.bridge.botIntent.underlyingClient;
- const { chunk } = await underlyingClient.unstableApis.getRelationsForEvent(
+ const { chunk } = await underlyingClient.getRelationsForEvent(
roomId,
eventId,
"m.annotation"
diff --git a/test/mocks/appservicemock.ts b/test/mocks/appservicemock.ts
index 06cc3ce..f6ef585 100644
--- a/test/mocks/appservicemock.ts
+++ b/test/mocks/appservicemock.ts
@@ -281,6 +281,10 @@ class MatrixClientMock extends AppserviceMockBase {
public async redactEvent(roomId: string, eventId: string, reason?: string | null) {
this.funcCalled("redactEvent", roomId, eventId, reason);
}
+
+ public async getRelationsForEvent(roomId: string, eventId: string, relationType?: string, eventType?: string): Promise<any> {
+ this.funcCalled("getRelationsForEvent", roomId, eventId, relationType, eventType);
+ }
}
class UnstableApis extends AppserviceMockBase {
@@ -288,8 +292,4 @@ class UnstableApis extends AppserviceMockBase {
public async addReactionToEvent(roomId: string, eventId: string, emoji: string) {
this.funcCalled("addReactionToEvent", roomId, eventId, emoji);
}
-
- public async getRelationsForEvent(roomId: string, eventId: string, relationType?: string, eventType?: string): Promise<any> {
- this.funcCalled("getRelationsForEvent", roomId, eventId, relationType, eventType);
- }
}
diff --git a/test/test_discordbot.ts b/test/test_discordbot.ts
index 9c9e469..2109bb7 100644
--- a/test/test_discordbot.ts
+++ b/test/test_discordbot.ts
@@ -501,7 +501,7 @@ describe("DiscordBot", () => {
discordBot = getDiscordBot();
const intent = mockBridge.getIntent(author.id);
- intent.underlyingClient.unstableApis.getRelationsForEvent = async () => {
+ intent.underlyingClient.getRelationsForEvent = async () => {
return {
chunk: [
{

View file

@ -0,0 +1,46 @@
{ pkgs, pkgs', ... }:
let
nixForNixPlugins = pkgs.nixVersions.nix_2_18;
in {
inherit nixForNixPlugins;
nix = nixForNixPlugins;
nixVersions = pkgs.nixVersions // {
stable = nixForNixPlugins;
unstable = nixForNixPlugins;
};
# Various patches to change Nix version of existing packages so they don't error out because of nix-plugins in nix.conf
/*nix-plugins = (pkgs.nix-plugins.override { nix = nixForNixPlugins; }).overrideAttrs (old: {
version = "13.0.0";
patches = [
(pkgs.fetchpatch {
# pull 16
url = "https://github.com/chayleaf/nix-plugins/commit/8f945cadad7f2e60e8f308b2f498ec5e16961ede.patch";
hash = "sha256-pOogMtjXYkSDtXW12TmBpGr/plnizJtud2nP3q2UldQ=";
})
];
});*/
harmonia = (pkgs.harmonia.override { nixVersions.nix_2_21 = nixForNixPlugins; }).overrideAttrs (old: rec {
version = "0.7.3";
src = old.src.override {
rev = "refs/tags/${old.pname}-v${version}";
hash = "sha256-XtnK54HvZMKZGSCrVD0FO5PQLMo3Vkj8ezUlsfqStq0=";
};
cargoDeps = pkgs'.rustPlatform.importCargoLock { lockFile = "${src}/Cargo.lock"; };
});
nix-init = pkgs.nix-init.override { nix = nixForNixPlugins; };
nix-serve = pkgs.nix-serve.override { nix = nixForNixPlugins; };
nix-serve-ng = pkgs.nix-serve-ng.override { nix = nixForNixPlugins; };
hydra_unstable = (pkgs.hydra_unstable.override {
nix = nixForNixPlugins;
}).overrideAttrs (old: {
version = "2023-12-01";
# who cares about tests amirite
doCheck = false;
src = old.src.override {
rev = "4d1c8505120961f10897b8fe9a070d4e193c9a13";
hash = "sha256-vXTuE83GL15mgZHegbllVAsVdDFcWWSayPfZxTJN5ys=";
};
});
nurl = pkgs.nurl.override { nix = nixForNixPlugins; };
}

View file

@ -1,4 +1,5 @@
{ pkgs
, pkgs-kernel
, lib
, config
, inputs
@ -63,7 +64,7 @@ in
criticalPowerAction = "PowerOff";
};
hardware.firmware = lib.mkAfter [ pkgs.firmware-oneplus-sdm845 ];
boot.kernelPackages = lib.mkForce (pkgs.linuxPackagesFor pkgs.linux_enchilada_ccache);
boot.kernelPackages = lib.mkForce (pkgs-kernel.linuxPackagesFor pkgs-kernel.linux_enchilada_ccache);
hardware.deviceTree.enable = true;
hardware.deviceTree.name = "qcom/sdm845-oneplus-enchilada.dtb";
# loglevel=7 console=ttyMSM0,115200 is a way to delay boot

View file

@ -124,8 +124,8 @@ in {
# ignoreConfigErrors = false;
kernelPatches = [
{
name = "linux_6_8";
patch = ./linux_6_8.patch;
name = "linux_6_9";
patch = ./linux_6_9.patch;
}
{
name = "config_fixes";