{ description = "TeleportFling - standalone screen + audio sender for the OBS Teleport protocol"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; }; outputs = { self, nixpkgs, flake-utils, ... }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; # Native/cgo build-time dependencies shared by both binaries. nativeBuildInputs = with pkgs; [ go pkg-config ]; # Libraries linked (or dlopened) by the capture/encode stack. # libpipewire is dlopened at runtime; libturbojpeg is linked. streamLibs = with pkgs; [ libjpeg_turbo pipewire xdg-desktop-portal ]; # Libraries required by the Fyne/GLFW GUI (cgo). guiLibs = with pkgs; [ libGL mesa wayland libxkbcommon libX11 libXrandr libXi libXcursor libXinerama libXxf86vm ]; # Nix's libspa-0.2.pc emits -fno-strict-aliasing/-fno-strict-overflow # which Go's cgo rejects unless explicitly allowed. cgoFlagsAllow = "-fno-strict-overflow|-fno-strict-aliasing"; # Common build environment so cgo finds headers/libs. buildEnv = pkg: { nativeBuildInputs = nativeBuildInputs; buildInputs = pkg; # Make turbojpeg resolve via pkg-config for cgo builds. PKG_CONFIG_PATH = "${pkgs.libjpeg_turbo.dev}/lib/pkgconfig"; # Fyne/GLFW link against X11, Wayland, GL and misc libs. Go's cgo # linker does not read NIX_LDFLAGS, so expose the runtime lib dirs # via LIBRARY_PATH for the link step. LIBRARY_PATH = with pkgs; lib.makeLibraryPath (pkg); CGO_CFLAGS_ALLOW = cgoFlagsAllow; }; # The headless CLI (no GLFW needed). teleportfling = pkgs.buildGoModule (buildEnv streamLibs // { pname = "teleportfling"; version = "0.1.0"; src = self; sourceRoot = self.sourceRoot or null; subPackages = [ "cmd/teleportfling" ]; vendorHash = "sha256-1PDoL45BWhWNVX9wktR3WXpNbXJ+7V4mfp3la+Nv0wI="; postInstall = '' mkdir -p $out/share/applications ''; meta = with pkgs.lib; { description = "Stream a screen and audio to OBS Teleport receivers"; homepage = "https://gitea.edley.me/petere/TeleportFling"; license = licenses.gpl2; mainProgram = "teleportfling"; platforms = platforms.linux; }; }); # The desktop GUI + system tray. teleportfling-gui = pkgs.buildGoModule (buildEnv (streamLibs ++ guiLibs) // { pname = "teleportfling-gui"; version = "0.1.0"; src = self; sourceRoot = self.sourceRoot or null; subPackages = [ "cmd/teleportfling-gui" ]; vendorHash = "sha256-1PDoL45BWhWNVX9wktR3WXpNbXJ+7V4mfp3la+Nv0wI="; postInstall = '' mkdir -p $out/share/applications install -m 0644 ${./assets/teleportfling.desktop} $out/share/applications/teleportfling.desktop mkdir -p $out/share/icons/hicolor/512x512/apps install -m 0644 ${./assets/teleportfling.png} $out/share/icons/hicolor/512x512/apps/teleportfling.png ''; meta = with pkgs.lib; { description = "TeleportFling desktop GUI and system tray"; homepage = "https://gitea.edley.me/petere/TeleportFling"; license = licenses.gpl2; mainProgram = "teleportfling-gui"; platforms = platforms.linux; }; }); in { packages = { default = teleportfling-gui; inherit teleportfling teleportfling-gui; }; apps = { teleportfling = flake-utils.lib.mkApp { drv = teleportfling; }; teleportfling-gui = flake-utils.lib.mkApp { drv = teleportfling-gui; }; default = self.apps.${system}.teleportfling-gui; }; devShells.default = pkgs.mkShell { inputsFrom = []; nativeBuildInputs = with pkgs; [ go golangci-lint pkg-config gopls nixd nodejs ]; buildInputs = with pkgs; [ git direnv nix-direnv ] ++ streamLibs ++ guiLibs; # Make turbojpeg resolve via pkg-config for cgo builds. PKG_CONFIG_PATH = "${pkgs.libjpeg_turbo.dev}/lib/pkgconfig"; LD_LIBRARY_PATH = "${pkgs.libjpeg_turbo.out}/lib"; # Fyne/GLFW link against X11, Wayland, GL and misc libs. Go's cgo # linker does not read NIX_LDFLAGS, so expose the runtime lib dirs # via LIBRARY_PATH for the link step. LIBRARY_PATH = with pkgs; lib.makeLibraryPath (streamLibs ++ guiLibs); # Nix's libspa-0.2.pc emits -fno-strict-aliasing/-fno-strict-overflow # which Go's cgo rejects unless explicitly allowed. CGO_CFLAGS_ALLOW = cgoFlagsAllow; shellHook = '' echo "TeleportFling dev shell ready!" ''; }; }); }