feat: add Nix flake package, AppImage and .deb packaging
- flake: build teleportfling and teleportfling-gui as nixpkgs packages (buildGoModule) with a .desktop entry and icon for the GUI - packaging/appimage.sh: bundle the GUI + runtime libs (recursive ldd) into a self-contained AppImage via appimagetool - packaging/deb.sh: build a .deb for Debian/Ubuntu with both binaries, desktop entry, icon and declared runtime dependencies - README: document all three packaging methods - .gitignore: ignore dist/
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
{
|
||||
description = "TeleportFling Development Environment";
|
||||
description = "TeleportFling - standalone screen + audio sender for the OBS Teleport protocol";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
@@ -10,8 +10,111 @@
|
||||
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 = "http://homeserver:3050/pedley/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 = "http://homeserver:3050/pedley/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; [
|
||||
@@ -27,21 +130,7 @@
|
||||
git
|
||||
direnv
|
||||
nix-direnv
|
||||
libjpeg_turbo
|
||||
pipewire
|
||||
xdg-desktop-portal
|
||||
# Fyne / GLFW (cgo) native dependencies.
|
||||
libGL
|
||||
mesa
|
||||
wayland
|
||||
libxkbcommon
|
||||
libX11
|
||||
libXrandr
|
||||
libXi
|
||||
libXcursor
|
||||
libXinerama
|
||||
libXxf86vm
|
||||
];
|
||||
] ++ streamLibs ++ guiLibs;
|
||||
|
||||
# Make turbojpeg resolve via pkg-config for cgo builds.
|
||||
PKG_CONFIG_PATH = "${pkgs.libjpeg_turbo.dev}/lib/pkgconfig";
|
||||
@@ -50,26 +139,15 @@
|
||||
# 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 [
|
||||
libGL
|
||||
mesa
|
||||
wayland
|
||||
libxkbcommon
|
||||
libX11
|
||||
libXrandr
|
||||
libXi
|
||||
libXcursor
|
||||
libXinerama
|
||||
libXxf86vm
|
||||
];
|
||||
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 = "-fno-strict-overflow|-fno-strict-aliasing";
|
||||
CGO_CFLAGS_ALLOW = cgoFlagsAllow;
|
||||
|
||||
shellHook = ''
|
||||
echo "TeleportFling dev shell ready!"
|
||||
'';
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user