Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 115 lines 3.6 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 coreutils, 6 openjdk17, 7 makeWrapper, 8 autoPatchelfHook, 9 zlib, 10 libzen, 11 libmediainfo, 12 curlWithGnuTls, 13 libmms, 14 glib, 15 genericUpdater, 16 writeShellScript, 17}: 18 19let 20 lanterna = fetchurl { 21 url = "https://search.maven.org/remotecontent?filepath=com/googlecode/lanterna/lanterna/3.1.1/lanterna-3.1.1.jar"; 22 hash = "sha256-7zxCeXYW5v9ritnvkwRpPKdgSptCmkT3HJOaNgQHUmQ="; 23 }; 24in 25stdenv.mkDerivation (finalAttrs: { 26 pname = "filebot"; 27 version = "5.1.7"; 28 29 src = fetchurl { 30 url = "https://web.archive.org/web/20230917142929/https://get.filebot.net/filebot/FileBot_${finalAttrs.version}/FileBot_${finalAttrs.version}-portable.tar.xz"; 31 hash = "sha256-GpjWo2+AsT0hD3CJJ8Pf/K5TbWtG0ZE2tIpH/UEGTws="; 32 }; 33 34 unpackPhase = "tar xvf $src"; 35 36 nativeBuildInputs = [ 37 makeWrapper 38 autoPatchelfHook 39 ]; 40 41 buildInputs = [ 42 zlib 43 libzen 44 libmediainfo 45 curlWithGnuTls 46 libmms 47 glib 48 ]; 49 50 postPatch = '' 51 # replace lanterna.jar to be able to specify `com.googlecode.lanterna.terminal.UnixTerminal.sttyCommand` 52 cp ${lanterna} jar/lanterna.jar 53 ''; 54 55 dontBuild = true; 56 installPhase = '' 57 mkdir -p $out/opt $out/bin 58 # Since FileBot has dependencies on relative paths between files, all required files are copied to the same location as is. 59 cp -r filebot.sh jar/ $out/opt/ 60 # Copy lib based on platform and force filebot to use libmediainfo.so from nix 61 local platformDir 62 case "${stdenv.hostPlatform.system}" in 63 "x86_64-linux") 64 platformDir="Linux-x86_64" 65 ;; 66 "aarch64-linux") 67 platformDir="Linux-aarch64" 68 ;; 69 esac 70 if [ -n "$platformDir" ]; then 71 mkdir -p "$out/opt/lib" 72 cp -r "lib/$platformDir" "$out/opt/lib/" 73 rm "$out/opt/lib/$platformDir/libmediainfo.so" 74 ln -s "${libmediainfo}/lib/libmediainfo.so" "$out/opt/lib/$platformDir/" 75 fi 76 # Filebot writes to $APP_DATA, which fails due to read-only filesystem. Using current user .local directory instead. 77 substituteInPlace $out/opt/filebot.sh \ 78 --replace 'APP_DATA="$FILEBOT_HOME/data/$(id -u)"' 'APP_DATA=''${XDG_DATA_HOME:-$HOME/.local/share}/filebot/data' \ 79 --replace '$FILEBOT_HOME/data/.license' '$APP_DATA/.license' \ 80 --replace '-jar "$FILEBOT_HOME/jar/filebot.jar"' '-Dcom.googlecode.lanterna.terminal.UnixTerminal.sttyCommand=${coreutils}/bin/stty -jar "$FILEBOT_HOME/jar/filebot.jar"' 81 wrapProgram $out/opt/filebot.sh \ 82 --prefix PATH : ${lib.makeBinPath [ openjdk17 ]} 83 # Expose the binary in bin to make runnable. 84 ln -s $out/opt/filebot.sh $out/bin/filebot 85 ''; 86 87 passthru.updateScript = genericUpdater { 88 versionLister = writeShellScript "filebot-versionLister" '' 89 curl -s https://www.filebot.net \ 90 | sed -rne 's,^.*FileBot_([0-9]*\.[0-9]+\.[0-9]+)-portable.tar.xz.*,\1,p' 91 ''; 92 }; 93 94 meta = with lib; { 95 description = "Ultimate TV and Movie Renamer"; 96 longDescription = '' 97 FileBot is the ultimate tool for organizing and renaming your Movies, TV 98 Shows and Anime as well as fetching subtitles and artwork. It's smart and 99 just works. 100 ''; 101 homepage = "https://filebot.net"; 102 changelog = "https://www.filebot.net/forums/viewforum.php?f=7"; 103 sourceProvenance = with sourceTypes; [ 104 binaryBytecode 105 binaryNativeCode 106 ]; 107 license = licenses.unfreeRedistributable; 108 maintainers = with maintainers; [ 109 gleber 110 felschr 111 ]; 112 platforms = platforms.linux; 113 mainProgram = "filebot"; 114 }; 115})