From 662bbb526c09e522846183005f56ace7b709ef76 Mon Sep 17 00:00:00 2001 From: Raymond Gauthier Date: Sat, 10 Oct 2015 12:16:42 -0400 Subject: [PATCH] thunar: improvements (close #10306) Add the possibility to specify plugin set to be used as overridable `thunar` derivation argument. New nixos config attribute: `services.xserver.desktopManager.xfce.thunarPlugins` that allows user to specify plugins in the context of nixos. Tests: - With and without plugins. - Using the nixos attributes. --- .../services/x11/desktop-managers/xfce.nix | 10 ++- pkgs/desktops/xfce/core/thunar-build.nix | 38 +++++++++ pkgs/desktops/xfce/core/thunar.nix | 85 +++++++++++++------ pkgs/desktops/xfce/default.nix | 2 + .../xfce/thunar-plugins/archive/default.nix | 4 +- .../xfce/thunar-plugins/dropbox/default.nix | 4 +- 6 files changed, 111 insertions(+), 32 deletions(-) create mode 100644 pkgs/desktops/xfce/core/thunar-build.nix diff --git a/nixos/modules/services/x11/desktop-managers/xfce.nix b/nixos/modules/services/x11/desktop-managers/xfce.nix index 88eefa13de35..33b6dd32c193 100644 --- a/nixos/modules/services/x11/desktop-managers/xfce.nix +++ b/nixos/modules/services/x11/desktop-managers/xfce.nix @@ -18,6 +18,14 @@ in description = "Enable the Xfce desktop environment."; }; + services.xserver.desktopManager.xfce.thunarPlugins = mkOption { + default = []; + type = types.listOf types.package; + example = literalExample "[ pkgs.xfce.thunar-archive-plugin ]"; + description = '' + A list of plugin that should be installed with Thunar. + ''; + }; }; @@ -49,7 +57,7 @@ in pkgs.xfce.mousepad pkgs.xfce.ristretto pkgs.xfce.terminal - pkgs.xfce.thunar + (pkgs.xfce.thunar.override { thunarPlugins = cfg.thunarPlugins; }) pkgs.xfce.xfce4icontheme pkgs.xfce.xfce4panel pkgs.xfce.xfce4session diff --git a/pkgs/desktops/xfce/core/thunar-build.nix b/pkgs/desktops/xfce/core/thunar-build.nix new file mode 100644 index 000000000000..7a69295d34dd --- /dev/null +++ b/pkgs/desktops/xfce/core/thunar-build.nix @@ -0,0 +1,38 @@ +{ stdenv, fetchurl, pkgconfig, intltool +, gtk, dbus_glib, libstartup_notification, libnotify, libexif, pcre, udev +, exo, libxfce4util, xfconf, xfce4panel +}: + +stdenv.mkDerivation rec { + p_name = "thunar"; + ver_maj = "1.6"; + ver_min = "10"; + + src = fetchurl { + url = "mirror://xfce/src/xfce/${p_name}/${ver_maj}/Thunar-${ver_maj}.${ver_min}.tar.bz2"; + sha256 = "7e9d24067268900e5e44d3325e60a1a2b2f8f556ec238ec12574fbea15fdee8a"; + }; + + name = "${p_name}-build-${ver_maj}.${ver_min}"; + + patches = [ ./thunarx_plugins_directory.patch ]; + + buildInputs = [ + pkgconfig intltool + gtk dbus_glib libstartup_notification libnotify libexif pcre udev + exo libxfce4util xfconf xfce4panel + ]; + # TODO: optionality? + + enableParallelBuilding = true; + + preFixup = "rm $out/share/icons/hicolor/icon-theme.cache"; + + meta = { + homepage = http://thunar.xfce.org/; + description = "Xfce file manager"; + license = stdenv.lib.licenses.gpl2Plus; + platforms = stdenv.lib.platforms.linux; + maintainers = [ stdenv.lib.maintainers.eelco ]; + }; +} \ No newline at end of file diff --git a/pkgs/desktops/xfce/core/thunar.nix b/pkgs/desktops/xfce/core/thunar.nix index 1ddab2b07525..037a3f947fbe 100644 --- a/pkgs/desktops/xfce/core/thunar.nix +++ b/pkgs/desktops/xfce/core/thunar.nix @@ -1,37 +1,68 @@ -{ stdenv, fetchurl, pkgconfig, intltool -, gtk, dbus_glib, libstartup_notification, libnotify, libexif, pcre, udev -, exo, libxfce4util, xfconf, xfce4panel +{ stdenv, buildEnv, runCommand, makeWrapper, lndir, thunar-build +, thunarPlugins ? [] }: -stdenv.mkDerivation rec { - p_name = "thunar"; - ver_maj = "1.6"; - ver_min = "10"; +with stdenv.lib; - src = fetchurl { - url = "mirror://xfce/src/xfce/${p_name}/${ver_maj}/Thunar-${ver_maj}.${ver_min}.tar.bz2"; - sha256 = "7e9d24067268900e5e44d3325e60a1a2b2f8f556ec238ec12574fbea15fdee8a"; - }; - name = "${p_name}-${ver_maj}.${ver_min}"; +let - patches = [ ./thunarx_plugins_directory.patch ]; + build = thunar-build; - buildInputs = [ - pkgconfig intltool - gtk dbus_glib libstartup_notification libnotify libexif pcre udev - exo libxfce4util xfconf xfce4panel - ]; - # TODO: optionality? + replaceLnExeListWithWrapped = exeDir: exeNameList: mkWrapArgs: '' + exeDir="${exeDir}" + oriDir=`realpath -e "$exeDir"` + unlink "$exeDir" + mkdir -p "$exeDir" + lndir "$oriDir" "$exeDir" - enableParallelBuilding = true; + exeList="${concatStrings (intersperse " " (map (x: "${exeDir}/${x}") exeNameList))}" - preFixup = "rm $out/share/icons/hicolor/icon-theme.cache"; + for exe in $exeList; do + oriExe=`realpath -e "$exe"` + rm -f "$exe" + makeWrapper "$oriExe" "$exe" ${concatStrings (intersperse " " mkWrapArgs)} + done + ''; + + name = "${build.p_name}-${build.ver_maj}.${build.ver_min}"; meta = { - homepage = http://thunar.xfce.org/; - description = "Xfce file manager"; - license = stdenv.lib.licenses.gpl2Plus; - platforms = stdenv.lib.platforms.linux; - maintainers = [ stdenv.lib.maintainers.eelco ]; + inherit (build.meta) homepage license platforms; + + description = build.meta.description + optionalString + (0 != length thunarPlugins) + " (with plugins: ${concatStrings (intersperse ", " (map (x: x.name) thunarPlugins))})"; + maintainers = build.meta.maintainers /*++ [ jraygauthier ]*/; }; -} + +in + +# TODO: To be replaced with `buildEnv` awaiting missing features. +runCommand name { + inherit build; + inherit meta; + + nativeBuildInputs = [ makeWrapper lndir ]; + + dontPatchELF = true; + dontStrip = true; + +} +(let + buildWithPlugins = buildEnv { + name = "thunar-build-with-plugins"; + paths = [ build ] ++ thunarPlugins; + }; + +in '' + mkdir -p $out + pushd ${buildWithPlugins} > /dev/null + for d in `find . -maxdepth 1 -name "*" -printf "%f\n" | tail -n+2`; do + ln -s "${buildWithPlugins}/$d" "$out/$d" + done + popd > /dev/null + + ${replaceLnExeListWithWrapped "$out/bin" [ "thunar" "thunar-settings" ] [ + "--set THUNARX_MODULE_DIR \"${buildWithPlugins}/lib/thunarx-2\"" + ]} +'') diff --git a/pkgs/desktops/xfce/default.nix b/pkgs/desktops/xfce/default.nix index b7e233d5766f..944e9ba013de 100644 --- a/pkgs/desktops/xfce/default.nix +++ b/pkgs/desktops/xfce/default.nix @@ -26,7 +26,9 @@ xfce_self = rec { # the lines are very long but it seems better than the even-od libxfce4ui_gtk3 = libxfce4ui.override { withGtk3 = true; }; libxfce4util = callPackage ./core/libxfce4util.nix { }; libxfcegui4 = callPackage ./core/libxfcegui4.nix { }; + thunar-build = callPackage ./core/thunar-build.nix { }; thunar = callPackage ./core/thunar.nix { }; + thunarx-2-dev = thunar-build; # Plugins need only the `thunarx-2` part of the package. Awaiting multiple outputs. thunar_volman = callPackage ./core/thunar-volman.nix { }; # ToDo: probably inside Thunar now thunar-archive-plugin = callPackage ./thunar-plugins/archive { }; diff --git a/pkgs/desktops/xfce/thunar-plugins/archive/default.nix b/pkgs/desktops/xfce/thunar-plugins/archive/default.nix index 78e5f5002cd4..b954cc4980db 100644 --- a/pkgs/desktops/xfce/thunar-plugins/archive/default.nix +++ b/pkgs/desktops/xfce/thunar-plugins/archive/default.nix @@ -1,6 +1,6 @@ { stdenv, fetchFromGitHub, pkgconfig, xfce4_dev_tools , gtk -, thunar +, thunarx-2-dev , exo, libxfce4util, libxfce4ui , xfconf, udev, libnotify }: @@ -21,7 +21,7 @@ stdenv.mkDerivation rec { buildInputs = [ pkgconfig xfce4_dev_tools - thunar + thunarx-2-dev exo gtk libxfce4util libxfce4ui xfconf udev libnotify ]; diff --git a/pkgs/desktops/xfce/thunar-plugins/dropbox/default.nix b/pkgs/desktops/xfce/thunar-plugins/dropbox/default.nix index cf83386fa261..e3cdfc13812a 100644 --- a/pkgs/desktops/xfce/thunar-plugins/dropbox/default.nix +++ b/pkgs/desktops/xfce/thunar-plugins/dropbox/default.nix @@ -1,6 +1,6 @@ { stdenv, fetchurl, pkgconfig , gtk -, thunar, python2 +, thunarx-2-dev, python2 }: stdenv.mkDerivation rec { @@ -17,7 +17,7 @@ stdenv.mkDerivation rec { buildInputs = [ pkgconfig gtk - thunar python2 + thunarx-2-dev python2 ]; configurePhase = "python2 waf configure --prefix=$out";