diff --git a/pkgs/by-name/br/broadcast-box/allow-no-env.patch b/pkgs/by-name/br/broadcast-box/allow-no-env.patch new file mode 100644 index 000000000000..cad4bbf5ff21 --- /dev/null +++ b/pkgs/by-name/br/broadcast-box/allow-no-env.patch @@ -0,0 +1,13 @@ +diff --git a/main.go b/main.go +index 1814da0..2befc13 100644 +--- a/main.go ++++ b/main.go +@@ -175,6 +175,8 @@ func main() { + if os.Getenv("APP_ENV") == "development" { + log.Println("Loading `" + envFileDev + "`") + return godotenv.Load(envFileDev) ++ } else if os.Getenv("APP_ENV") == "nixos" { ++ return nil + } else { + if _, err := os.Stat("./web/build"); os.IsNotExist(err) { + return noBuildDirectoryErr diff --git a/pkgs/by-name/br/broadcast-box/package.nix b/pkgs/by-name/br/broadcast-box/package.nix new file mode 100644 index 000000000000..a176bb35c510 --- /dev/null +++ b/pkgs/by-name/br/broadcast-box/package.nix @@ -0,0 +1,69 @@ +{ + lib, + nixosTests, + fetchFromGitHub, + buildNpmPackage, + buildGoModule, +}: +let + name = "broadcast-box"; + version = "0-unstable-2025-06-04"; + + src = fetchFromGitHub { + repo = "broadcast-box"; + owner = "Glimesh"; + rev = "a091f147f750759084a2c9d25a12e815e2feebf8"; + hash = "sha256-Evhye+DYtFM/VjxqmhH5kU32khvEFUxTUgH9DXytIbo="; + }; + + frontend = buildNpmPackage { + inherit version; + pname = "${name}-web"; + src = "${src}/web"; + npmDepsHash = "sha256-e1cCezmF20Q6JEXwPb1asRSXuC/GGaR+ImvrTabLl5c="; + preBuild = '' + # The VITE_API_PATH environment variable is needed + cp "${src}/.env.production" ../ + ''; + installPhase = '' + mkdir -p $out + cp -r build $out + ''; + }; +in +buildGoModule { + inherit version src frontend; + pname = name; + vendorHash = "sha256-Jpee7UmG9AB9SOoTv2fPP2l5BmkDPPdciGFu9Naq9h8="; + proxyVendor = true; # fixes darwin/linux hash mismatch + + patches = [ ./allow-no-env.patch ]; + postPatch = '' + substituteInPlace main.go \ + --replace-fail './web/build' '${placeholder "out"}/share' + ''; + + installPhase = '' + runHook preInstall + + mkdir -p $out/share + cp -r $frontend/build/* $out/share + + install -Dm755 $GOPATH/bin/broadcast-box -t $out/bin + + runHook postInstall + ''; + + passthru.tests = { + inherit (nixosTests) broadcast-box; + }; + + meta = { + description = "WebRTC broadcast server"; + homepage = "https://github.com/Glimesh/broadcast-box"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ JManch ]; + platforms = lib.platforms.unix; + mainProgram = "broadcast-box"; + }; +}