tv-discord: Discord bot + Activity for watching bug.tv together
Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
commit
ef7b44f074
36 files changed
+5841
No files matched your search
@@ -0,0 +1,102 @@
|
||||
{
|
||||
description = "bug.tv Discord bot + Activity for watching together in a voice channel";
|
||||
|
||||
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 {
|
||||
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 bot (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;
|
||||
hasTests = builtins.pathExists ./test && builtins.readDir ./test != { };
|
||||
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
|
||||
test -f activity/index.html
|
||||
test -f activity/dist/main.js
|
||||
touch $out
|
||||
'';
|
||||
}
|
||||
// lib.optionalAttrs hasTests {
|
||||
# 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))
|
||||
./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;
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user