Files
2026-10-27 05:49:38 -05:00

81 lines
2.5 KiB
Nix

{
description = "bug.tv: multi-provider stream finder API + web frontend";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
outputs =
{ self, nixpkgs, ... }:
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 {
api = pkgs.callPackage ./nix/package.nix { };
# web.override { apiBase = "https://..."; }
web = pkgs.callPackage ./nix/web.nix { };
default = api;
});
apps = forAllSystems (pkgs: {
default = {
type = "app";
program = lib.getExe self.packages.${pkgs.stdenv.hostPlatform.system}.api;
meta.description = "Run the bug.tv API (reads ./config.json or $BUG_TV_CONFIG)";
};
});
devShells = forAllSystems (pkgs: {
default = pkgs.mkShell {
packages = [ pkgs.nodejs pkgs.ffmpeg-headless ];
};
});
formatter = forAllSystems (pkgs: pkgs.nixfmt);
checks = forAllSystems (
pkgs:
let
inherit (self.packages.${pkgs.stdenv.hostPlatform.system}) api web;
in
{
inherit api web;
smoke =
pkgs.runCommand "bug-tv-smoke"
{
nativeBuildInputs = [ pkgs.nodejs pkgs.curl pkgs.findutils ];
}
''
cd ${api}/lib/bug-tv
find src -name '*.js' -print0 | xargs -0 -n1 node --check
port=$((20000 + RANDOM % 20000))
cat > $TMPDIR/config.json <<JSON
{ "tmdbKey": "dummy", "host": "127.0.0.1", "port": $port }
JSON
export HOME=$TMPDIR BUG_TV_CONFIG=$TMPDIR/config.json BUG_TV_CACHE_DIR=$TMPDIR/cache
${lib.getExe api} > $TMPDIR/server.log 2>&1 &
pid=$!
ok=
for _ in $(seq 60); do
if curl -fsS "http://127.0.0.1:$port/healthz"; then ok=1; break; fi
kill -0 $pid 2>/dev/null || break
sleep 0.5
done
kill $pid 2>/dev/null || true
cat $TMPDIR/server.log
[ -n "$ok" ] || { echo "server did not answer /healthz"; exit 1; }
touch $out
'';
}
);
nixosModules.default = import ./nix/module.nix self;
nixosModules.bug-tv = self.nixosModules.default;
};
}