building synctube from source

This commit is contained in:
Danilo Reyes
2026-02-21 20:30:16 -06:00
parent b7ec8f0f2d
commit 3fa9df295c
3 changed files with 104 additions and 84 deletions

17
flake.lock generated
View File

@@ -1098,6 +1098,7 @@
"qbit_manage": "qbit_manage",
"sops-nix": "sops-nix",
"stylix": "stylix",
"synctube": "synctube",
"ucodenix": "ucodenix",
"wallpapers": "wallpapers"
}
@@ -1174,6 +1175,22 @@
"jawz-scripts"
]
},
"synctube": {
"flake": false,
"locked": {
"lastModified": 1768650831,
"narHash": "sha256-1ySSYF4DjkND1FTpn/HUtemmXVzK6+k/89HsKZ0r0PE=",
"owner": "RblSb",
"repo": "SyncTube",
"rev": "276e12db29ab31aa002f55b1a3cc69f170c1a2c2",
"type": "github"
},
"original": {
"owner": "RblSb",
"repo": "SyncTube",
"type": "github"
}
},
"systems": {
"locked": {
"lastModified": 1681028828,

View File

@@ -66,6 +66,10 @@
url = "github:StuffAnThings/qbit_manage";
flake = false;
};
synctube = {
url = "github:RblSb/SyncTube";
flake = false;
};
};
outputs =
inputs:

View File

@@ -1,20 +1,22 @@
{
lib,
config,
inputs,
pkgs,
...
}:
let
setup = import ../factories/mkserver.nix { inherit lib config; };
cfg = config.my.servers.synctube;
synctubeSrc = inputs.synctube;
withCommas = lib.replaceStrings [ "." ] [ "," ];
mkHaxeLib =
{
libname,
version,
src,
version ? "git",
}:
pkgs.stdenv.mkDerivation {
pkgs.stdenvNoCC.mkDerivation {
name = "${libname}-${version}";
inherit src;
installPhase = ''
@@ -35,7 +37,6 @@ let
}:
mkHaxeLib {
inherit libname;
version = "git";
src = pkgs.fetchFromGitHub {
inherit
owner
@@ -45,94 +46,95 @@ let
;
};
};
hxnodejsGit = mkHaxeGitLib {
haxeLibs = pkgs.symlinkJoin {
name = "synctube-haxelibs";
paths = [
(mkHaxeGitLib {
libname = "hxnodejs";
owner = "HaxeFoundation";
repo = "hxnodejs";
rev = "ba7d9a566a79b3b36b4e1f58bc8e66306983e9e4";
hash = "sha256-RZ+GoRlTvcalVsexd8Fw3/P4XZYh5IZQJNzyFkEOgAc=";
};
hxnodejsWs = mkHaxeGitLib {
})
(mkHaxeGitLib {
libname = "hxnodejs-ws";
owner = "haxe-externs";
repo = "hxnodejs-ws";
rev = "2d0e770489abdb8d095fc4694353eaa9d6743562";
hash = "sha256-Gls4OeOCSU9Ld3rZ76086BH2TMxRvPj658sKWDP4pds=";
};
json2object = mkHaxeGitLib {
})
(mkHaxeGitLib {
libname = "json2object";
owner = "RblSb";
repo = "json2object";
rev = "8d949c12a93bdae010603af955a453458603cd47";
hash = "sha256-lD1IDg6xULRwisAtSZIyBju8yIa7nmM5eSezz05udaw=";
};
hxjsonast = mkHaxeGitLib {
})
(mkHaxeGitLib {
libname = "hxjsonast";
owner = "elnabo";
repo = "hxjsonast";
rev = "9a9544378c9517e5cf4c5fa3c092e77bec125e64";
hash = "sha256-AvcxbksuLCKGRCHAxFYHdF7e32efBvPdXLTbHbd+q/c=";
};
ytdlpNodejs = mkHaxeGitLib {
})
(mkHaxeGitLib {
libname = "ytdlp-nodejs";
owner = "haxe-externs";
repo = "ytdlp-nodejs-externs";
rev = "dbd476ce53a0c38db36e430ded28b2740001e8aa";
hash = "sha256-mitC7wzZdJxt4B0UhMrnShhMd9Gup5G9EpSbUSJj8dA=";
};
youtubeIFramePlayer = mkHaxeGitLib {
})
(mkHaxeGitLib {
libname = "youtubeIFramePlayer";
owner = "haxe-externs";
repo = "youtubeIFramePlayer-externs";
rev = "8d47d71a4e3b8030a83a2e11672f120ca9a086d4";
hash = "sha256-ov0nbhEazVCcWHcxplCNdN0KRhxBKqsvFHjmGzvTvPI=";
};
hlsJsExtern = mkHaxeGitLib {
})
(mkHaxeGitLib {
libname = "hls.js-extern";
owner = "zoldesi-andor";
repo = "hls.js-haxe-extern";
rev = "86448a1dad21e72126ce8cc078062648de8bc2c5";
hash = "sha256-MnT71PwoQd66DOzHMp8X3Yt8XulUkA1tX4dgUv7JLio=";
};
utest = mkHaxeGitLib {
})
(mkHaxeGitLib {
libname = "utest";
owner = "haxe-utest";
repo = "utest";
rev = "654d6a32cc84c81972a5d3768e400d7317fff6e5";
hash = "sha256-3tdiEE1tXx5Jht+amAH3e5mKa5kAihJlklFaJLeTriE=";
})
];
};
haxeLibs = pkgs.runCommand "synctube-haxelibs" { } ''
mkdir -p "$out/lib/haxe"
cp -r ${hxnodejsGit}/lib/haxe/* "$out/lib/haxe/"
cp -r ${hxnodejsWs}/lib/haxe/* "$out/lib/haxe/"
cp -r ${json2object}/lib/haxe/* "$out/lib/haxe/"
cp -r ${hxjsonast}/lib/haxe/* "$out/lib/haxe/"
cp -r ${ytdlpNodejs}/lib/haxe/* "$out/lib/haxe/"
cp -r ${youtubeIFramePlayer}/lib/haxe/* "$out/lib/haxe/"
cp -r ${hlsJsExtern}/lib/haxe/* "$out/lib/haxe/"
cp -r ${utest}/lib/haxe/* "$out/lib/haxe/"
'';
synctubePackage = pkgs.buildNpmPackage {
npmDeps = pkgs.fetchNpmDeps {
src = synctubeSrc;
hash = "sha256-dIbBNvTQCv1fjboBC6Q8kGqcZbLNuGmgHw9DgOmVnTw=";
};
synctubeApp = pkgs.stdenv.mkDerivation {
pname = "synctube";
version = "1.0.0";
src = pkgs.fetchFromGitHub {
owner = "RblSb";
repo = "SyncTube";
rev = "276e12db29ab31aa002f55b1a3cc69f170c1a2c2";
hash = "sha256-1ySSYF4DjkND1FTpn/HUtemmXVzK6+k/89HsKZ0r0PE=";
};
npmDepsHash = "sha256-dIbBNvTQCv1fjboBC6Q8kGqcZbLNuGmgHw9DgOmVnTw=";
dontNpmBuild = true;
src = synctubeSrc;
nativeBuildInputs = [
pkgs.haxe
pkgs.neko
pkgs.nodejs
];
buildPhase = ''
runHook preBuild
export HAXELIB_PATH=${haxeLibs}/lib/haxe
export npm_config_cache=${npmDeps}
npm ci --offline --ignore-scripts
haxe build-all.hxml
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p "$out/app"
cp -R build res user default-config.json package.json package-lock.json "$out/app/"
cp -R node_modules "$out/app/"
runHook postInstall
'';
};
synctubeImage = pkgs.dockerTools.buildImage {
name = "synctube";
@@ -140,23 +142,20 @@ let
copyToRoot = pkgs.buildEnv {
name = "synctube-root";
paths = [
synctubePackage
synctubeApp
pkgs.nodejs
];
pathsToLink = [
"/app"
"/bin"
];
pathsToLink = [ "/" ];
};
config = {
WorkingDir = "/app/lib/node_modules/synctube";
WorkingDir = "/app";
Cmd = [
"/bin/node"
"build/server.js"
];
Env = [
"NODE_ENV=production"
"NODE_PATH=/app/lib/node_modules/synctube/node_modules"
"NODE_PATH=/app/node_modules"
"PATH=/bin"
];
};