134 lines
4.4 KiB
Nix
134 lines
4.4 KiB
Nix
{
|
|
lib,
|
|
stdenv,
|
|
fetchFromGitHub,
|
|
python3,
|
|
wrapGAppsHook3,
|
|
gobject-introspection,
|
|
gtk3,
|
|
nautilus,
|
|
nautilus-python,
|
|
ffmpeg,
|
|
makeDesktopItem,
|
|
copyDesktopItems,
|
|
}:
|
|
stdenv.mkDerivation rec {
|
|
pname = "nautilus-file-converter-addon";
|
|
version = "1.3.11";
|
|
|
|
src = fetchFromGitHub {
|
|
owner = "Lich-Corals";
|
|
repo = "linux-file-converter-addon";
|
|
rev = version;
|
|
hash = "sha256-wldyhPeZayzrwFcYyFDUhlp8/8PQZ7tnJZ88v37kAa8=";
|
|
};
|
|
|
|
nativeBuildInputs = [
|
|
wrapGAppsHook3
|
|
gobject-introspection
|
|
copyDesktopItems
|
|
];
|
|
|
|
buildInputs = [
|
|
gtk3
|
|
nautilus
|
|
nautilus-python
|
|
python3
|
|
];
|
|
|
|
propagatedBuildInputs = with python3.pkgs; [
|
|
pillow
|
|
python-magic
|
|
pygobject3
|
|
# Optional dependencies for additional format support
|
|
pillow-heif
|
|
];
|
|
|
|
dontBuild = true;
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
# Create necessary directories
|
|
mkdir -p $out/share/nautilus-python/extensions
|
|
mkdir -p $out/bin
|
|
|
|
# Install the main script for Nautilus
|
|
cp nautilus-fileconverter.py $out/share/nautilus-python/extensions/linux-file-converter-addon.py
|
|
|
|
# Also install as a standalone script for other file managers
|
|
cp nautilus-fileconverter.py $out/bin/linux-file-converter-addon
|
|
chmod +x $out/bin/linux-file-converter-addon
|
|
|
|
# Install additional files for other file managers if they exist
|
|
if [ -f "nautilus-fileconverter.nemo_action" ]; then
|
|
mkdir -p $out/share/nemo/actions
|
|
cp nautilus-fileconverter.nemo_action $out/share/nemo/actions/linux-file-converter-addon.nemo_action
|
|
# Update the exec path in the nemo action
|
|
substituteInPlace $out/share/nemo/actions/linux-file-converter-addon.nemo_action \
|
|
--replace "nautilus-fileconverter.py" "$out/bin/linux-file-converter-addon"
|
|
fi
|
|
|
|
if [ -f "linux-file-converter-addon.kde_servicemenu" ]; then
|
|
mkdir -p $out/share/kio/servicemenus
|
|
cp linux-file-converter-addon.kde_servicemenu $out/share/kio/servicemenus/linux-file-converter-addon.desktop
|
|
# Update the exec path in the service menu
|
|
substituteInPlace $out/share/kio/servicemenus/linux-file-converter-addon.desktop \
|
|
--replace "python3 ~/.local/bin/linux-file-converter-addon.py" "$out/bin/linux-file-converter-addon"
|
|
fi
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
desktopItems = [
|
|
(makeDesktopItem {
|
|
name = "linux-file-converter-addon";
|
|
desktopName = "Linux File Converter Addon";
|
|
comment = "Convert files from context menu";
|
|
exec = "${placeholder "out"}/bin/linux-file-converter-addon";
|
|
categories = ["Utility" "FileTools"];
|
|
noDisplay = true;
|
|
})
|
|
];
|
|
|
|
postInstall = ''
|
|
# Patch the script to use absolute paths for dependencies and disable auto-updates
|
|
for script in $out/share/nautilus-python/extensions/linux-file-converter-addon.py $out/bin/linux-file-converter-addon; do
|
|
# Use absolute path for ffmpeg
|
|
substituteInPlace $script \
|
|
--replace 'ffmpeg' '${ffmpeg}/bin/ffmpeg' \
|
|
--replace '"automaticUpdates": True,' '"automaticUpdates": False,'
|
|
done
|
|
'';
|
|
|
|
postFixup = ''
|
|
# Wrap the standalone script to ensure proper environment
|
|
wrapProgram $out/bin/linux-file-converter-addon \
|
|
--prefix PATH : ${lib.makeBinPath [ffmpeg]} \
|
|
--prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH" \
|
|
--prefix PYTHONPATH : "${python3.withPackages (ps: with ps; [pillow python-magic pygobject3 pillow-heif])}/lib/python*/site-packages"
|
|
'';
|
|
|
|
meta = with lib; {
|
|
description = "File converter addon for Linux file managers (Nautilus, Nemo, Thunar, Dolphin)";
|
|
longDescription = ''
|
|
Linux File Converter Addon adds context menu options to convert between
|
|
various image, audio, and video formats using FFmpeg and Python libraries.
|
|
Supports multiple file managers including Nautilus, Nemo, Thunar, and Dolphin.
|
|
|
|
Features:
|
|
- Convert images between formats (PNG, JPEG, WebP, TIFF, etc.)
|
|
- Convert audio files (MP3, WAV, FLAC, OGG, etc.)
|
|
- Convert video files (MP4, WebM, AVI, etc.)
|
|
- Resize images to specific dimensions
|
|
- Built-in wallpaper and square format presets
|
|
- Support for modern formats like HEIF, AVIF (with optional dependencies)
|
|
'';
|
|
homepage = "https://github.com/Lich-Corals/linux-file-converter-addon";
|
|
license = licenses.agpl3Plus;
|
|
# maintainers = [];
|
|
platforms = platforms.linux;
|
|
mainProgram = "linux-file-converter-addon";
|
|
};
|
|
}
|