The Activity is now the full bug.tv site plus a small Discord overlay. Whoever starts the instance hosts and controls everything; everyone else mirrors the host's page and playback. The server is a relay keyed by activity instance and checks membership through Discord's activity-instances API, so it works in DM and group calls. The bot gateway, slash commands and control message are gone.
101 lines
3.0 KiB
Nix
101 lines
3.0 KiB
Nix
{
|
|
description = "bug.tv Discord Activity: the bug.tv site as a host-controlled watch party in calls";
|
|
|
|
inputs = {
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
|
bug-tv = {
|
|
url = "git+https://git.bug.tools/bug/tv";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
|
|
outputs =
|
|
{
|
|
self,
|
|
nixpkgs,
|
|
bug-tv,
|
|
...
|
|
}:
|
|
let
|
|
inherit (nixpkgs) lib;
|
|
|
|
systems = [ "x86_64-linux" "aarch64-linux" ];
|
|
forAllSystems = f: lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
|
|
in
|
|
{
|
|
packages = forAllSystems (pkgs: rec {
|
|
# bug-tv's site, overridden in activity.nix to use the /tv URL mapping
|
|
activity = pkgs.callPackage ./nix/activity.nix {
|
|
bugTvWeb = bug-tv.packages.${pkgs.stdenv.hostPlatform.system}.web;
|
|
};
|
|
bot = pkgs.callPackage ./nix/package.nix { inherit activity; };
|
|
default = bot;
|
|
});
|
|
|
|
apps = forAllSystems (pkgs: {
|
|
default = {
|
|
type = "app";
|
|
program = lib.getExe self.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
|
meta.description = "Run the Activity server (reads ./config.json or $BUG_TV_DISCORD_CONFIG)";
|
|
};
|
|
});
|
|
|
|
devShells = forAllSystems (pkgs: {
|
|
default = pkgs.mkShell { packages = [ pkgs.nodejs_22 pkgs.esbuild ]; };
|
|
});
|
|
|
|
formatter = forAllSystems (pkgs: pkgs.nixfmt);
|
|
|
|
checks = forAllSystems (
|
|
pkgs:
|
|
let
|
|
inherit (self.packages.${pkgs.stdenv.hostPlatform.system}) bot activity;
|
|
in
|
|
{
|
|
inherit bot activity;
|
|
|
|
lint =
|
|
pkgs.runCommand "bug-tv-discord-lint"
|
|
{
|
|
nativeBuildInputs = [ pkgs.nodejs_22 pkgs.findutils ];
|
|
}
|
|
''
|
|
cd ${bot}/lib/bug-tv-discord
|
|
find src -name '*.js' -print0 | xargs -0 -n1 node --check
|
|
touch $out
|
|
'';
|
|
|
|
# no network in the sandbox: tests must not need it
|
|
test = pkgs.buildNpmPackage {
|
|
pname = "bug-tv-discord-test";
|
|
inherit (bot) version npmDeps npmConfigHook npmFlags;
|
|
nodejs = pkgs.nodejs_22;
|
|
src = lib.fileset.toSource {
|
|
root = ./.;
|
|
fileset = lib.fileset.unions [
|
|
./src
|
|
./test
|
|
(lib.fileset.difference ./activity (lib.fileset.maybeMissing ./activity/dist))
|
|
(lib.fileset.maybeMissing ./scripts)
|
|
./package.json
|
|
./package-lock.json
|
|
];
|
|
};
|
|
dontNpmBuild = true;
|
|
doCheck = true;
|
|
checkPhase = ''
|
|
runHook preCheck
|
|
export HOME=$TMPDIR
|
|
node --test
|
|
runHook postCheck
|
|
'';
|
|
installPhase = "touch $out";
|
|
};
|
|
}
|
|
);
|
|
|
|
nixosModules.default = import ./nix/module.nix self;
|
|
nixosModules.bug-tv-discord = self.nixosModules.default;
|
|
};
|
|
}
|