Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

freetube: build from source #365997

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 85 additions & 33 deletions pkgs/by-name/fr/freetube/package.nix
Original file line number Diff line number Diff line change
@@ -1,55 +1,107 @@
{
stdenv,
lib,
fetchurl,
appimageTools,
makeWrapper,
stdenvNoCC,
fetchFromGitHub,
fetchYarnDeps,
replaceVars,
makeDesktopItem,

nodejs,
yarnConfigHook,
yarnBuildHook,
makeShellWrapper,
copyDesktopItems,
electron,

nixosTests,
}:

stdenv.mkDerivation rec {
let
description = "Open Source YouTube app for privacy";
in
stdenvNoCC.mkDerivation (finalAttrs: {
pname = "freetube";
version = "0.22.1";

src = fetchurl {
url = "https://github.com/FreeTubeApp/FreeTube/releases/download/v${version}-beta/freetube_${version}_amd64.AppImage";
hash = "sha256-HbU5yRSP5Gk473ZoQL3HD2Bph/U/sq1Dd0eFpxyKc9s=";
src = fetchFromGitHub {
owner = "FreeTubeApp";
repo = "FreeTube";
tag = "v${finalAttrs.version}-beta";
hash = "sha256-FND4jYnNeqsyCXkVB+DKr8hu720+XEjOZJ/iRZGI3y8=";
};

passthru.tests = nixosTests.freetube;
# Darwin requires writable Electron dist
postUnpack =
if stdenvNoCC.hostPlatform.isDarwin then
''
cp -r ${electron.dist} electron-dist
chmod -R u+w electron-dist
''
else
''
ln -s ${electron.dist} electron-dist
'';

appimageContents = appimageTools.extractType2 { inherit pname version src; };
patches = [
(replaceVars ./patch-build-script.patch {
electron-version = electron.version;
})
];

dontUnpack = true;
dontConfigure = true;
dontBuild = true;

nativeBuildInputs = [ makeWrapper ];
yarnOfflineCache = fetchYarnDeps {
yarnLock = "${finalAttrs.src}/yarn.lock";
hash = "sha256-cvRnPxRy3oawZUu97qYu+IgbXLYej/kykrCDJ4qLvIg=";
};

installPhase = ''
runHook preInstall
nativeBuildInputs = [
nodejs
yarnConfigHook
yarnBuildHook
makeShellWrapper
copyDesktopItems
];

mkdir -p $out/bin $out/share/${pname} $out/share/applications $out/share/icons/hicolor/scalable/apps
installPhase =
''
runHook preInstall
''
+ lib.optionalString stdenvNoCC.hostPlatform.isLinux ''
mkdir -p $out/share/freetube
cp -r build/*-unpacked/{locales,resources{,.pak}} -t $out/share/freetube

cp -a ${appimageContents}/{locales,resources} $out/share/${pname}
cp -a ${appimageContents}/freetube.desktop $out/share/applications/${pname}.desktop
cp -a ${appimageContents}/usr/share/icons/hicolor/scalable/freetube.svg $out/share/icons/hicolor/scalable/apps
makeWrapper ${lib.getExe electron} $out/bin/freetube \
--add-flags "$out/share/freetube/resources/app.asar" \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations --enable-wayland-ime=true}}"

substituteInPlace $out/share/applications/${pname}.desktop \
--replace 'Exec=AppRun' 'Exec=${pname}'
install -D _icons/icon.svg $out/share/icons/hicolor/scalable/apps/freetube.svg
''
+ lib.optionalString stdenvNoCC.hostPlatform.isDarwin ''
mkdir -p $out/Applications
cp -r build/mac*/FreeTube.app $out/Applications
ln -s "$out/Applications/FreeTube.app/Contents/MacOS/FreeTube" $out/bin/freetube
''
+ ''
runHook postInstall
'';

runHook postInstall
'';
desktopItems = [
(makeDesktopItem {
name = "freetube";
desktopName = "FreeTube";
comment = description;
exec = "freetube %U";
terminal = false;
type = "Application";
icon = "freetube";
startupWMClass = "FreeTube";
mimeTypes = [ "x-scheme-handler/freetube" ];
categories = [ "Network" ];
})
];

postFixup = ''
makeWrapper ${electron}/bin/electron $out/bin/${pname} \
--add-flags $out/share/${pname}/resources/app.asar \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland --enable-wayland-ime=true}}"
'';
passthru.tests = nixosTests.freetube;

meta = {
description = "Open Source YouTube app for privacy";
inherit description;
homepage = "https://freetubeapp.io/";
license = lib.licenses.agpl3Only;
maintainers = with lib.maintainers; [
Expand All @@ -61,4 +113,4 @@ stdenv.mkDerivation rec {
inherit (electron.meta) platforms;
mainProgram = "freetube";
};
}
})
13 changes: 13 additions & 0 deletions pkgs/by-name/fr/freetube/patch-build-script.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/_scripts/ebuilder.config.js b/_scripts/ebuilder.config.js
index 5b79d961..9f5945d2 100644
--- a/_scripts/ebuilder.config.js
+++ b/_scripts/ebuilder.config.js
@@ -1,6 +1,8 @@
const { name, productName } = require('../package.json')

const config = {
+ electronVersion: "@electron-version@",
+ electronDist: "electron-dist",
appId: `io.freetubeapp.${name}`,
copyright: 'Copyleft © 2020-2024 [email protected]',
// asar: false,
Loading