2024-01-31 08:35:03 +00:00
|
|
|
{ lib, stdenv, fetchFromGitLab, fetchFromGitHub, fetchpatch, writeText
|
|
|
|
# docs deps
|
|
|
|
, libxslt, docbook_xml_dtd_412, docbook_xml_dtd_43, docbook_xsl, xmlto
|
|
|
|
# runtime deps
|
2024-02-05 17:26:47 +00:00
|
|
|
, resholve, bash, coreutils, dbus, file, gawk, glib, gnugrep, gnused, jq, nettools, procmail, procps, xdg-user-dirs
|
2024-01-31 08:35:03 +00:00
|
|
|
, perl, perlPackages
|
|
|
|
, mimiSupport ? false
|
2022-10-21 20:16:49 +00:00
|
|
|
, withXdgOpenUsePortalPatch ? true }:
|
2015-08-15 19:01:46 +00:00
|
|
|
|
|
|
|
let
|
|
|
|
# A much better xdg-open
|
|
|
|
mimisrc = fetchFromGitHub {
|
|
|
|
owner = "march-linux";
|
|
|
|
repo = "mimi";
|
2017-01-04 14:01:35 +00:00
|
|
|
rev = "8e0070f17bcd3612ee83cb84e663e7c7fabcca3d";
|
|
|
|
sha256 = "15gw2nyrqmdsdin8gzxihpn77grhk9l97jp7s7pr7sl4n9ya2rpj";
|
2015-08-15 19:01:46 +00:00
|
|
|
};
|
2019-09-24 20:07:47 +00:00
|
|
|
|
2024-01-31 08:35:03 +00:00
|
|
|
# Required by the common desktop detection code
|
|
|
|
commonDeps = [ dbus coreutils gnugrep gnused ];
|
|
|
|
# These are all faked because the current desktop is detected
|
|
|
|
# based on their presence, so we want them to be missing by default.
|
|
|
|
commonFakes = [
|
|
|
|
"explorer.exe"
|
|
|
|
"gnome-default-applications-properties"
|
|
|
|
"kde-config"
|
|
|
|
"xprop"
|
2019-09-24 20:07:47 +00:00
|
|
|
];
|
|
|
|
|
2024-01-31 08:35:03 +00:00
|
|
|
# This is still required to work around the eval trickery some scripts do
|
|
|
|
commonPrologue = "${writeText "xdg-utils-prologue" ''
|
|
|
|
export PATH=$PATH:${coreutils}/bin
|
|
|
|
''}";
|
|
|
|
|
|
|
|
solutions = [
|
|
|
|
{
|
|
|
|
scripts = [ "bin/xdg-desktop-icon" ];
|
|
|
|
interpreter = "${bash}/bin/bash";
|
|
|
|
inputs = commonDeps ++ [ xdg-user-dirs ];
|
|
|
|
execer = [
|
|
|
|
"cannot:${xdg-user-dirs}/bin/xdg-user-dir"
|
|
|
|
];
|
|
|
|
# These are desktop-specific, so we don't want xdg-utils to be able to
|
|
|
|
# call them when in a different setup.
|
|
|
|
fake.external = commonFakes ++ [
|
|
|
|
"gconftool-2" # GNOME2
|
|
|
|
];
|
|
|
|
keep."$KDE_SESSION_VERSION" = true;
|
|
|
|
prologue = commonPrologue;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
scripts = [ "bin/xdg-desktop-menu" ];
|
|
|
|
interpreter = "${bash}/bin/bash";
|
|
|
|
inputs = commonDeps ++ [ gawk ];
|
|
|
|
fake.external = commonFakes;
|
|
|
|
keep."$KDE_SESSION_VERSION" = true;
|
|
|
|
prologue = commonPrologue;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
scripts = [ "bin/xdg-email" ];
|
|
|
|
interpreter = "${bash}/bin/bash";
|
2024-02-04 23:40:00 +00:00
|
|
|
inputs = commonDeps ++ [ gawk glib.bin "${placeholder "out"}/bin" ];
|
2024-01-31 08:35:03 +00:00
|
|
|
execer = [
|
|
|
|
"cannot:${placeholder "out"}/bin/xdg-mime"
|
|
|
|
"cannot:${placeholder "out"}/bin/xdg-open"
|
|
|
|
];
|
|
|
|
# These are desktop-specific, so we don't want xdg-utils to be able to
|
|
|
|
# call them when in a different setup.
|
|
|
|
fake.external = commonFakes ++ [
|
|
|
|
"exo-open" # XFCE
|
|
|
|
"gconftool-2" # GNOME
|
|
|
|
"gio" # GNOME (new)
|
|
|
|
"gnome-open" # GNOME (very old)
|
|
|
|
"gvfs-open" # GNOME (old)
|
|
|
|
"qtxdg-mat" # LXQT
|
|
|
|
"xdg-email-hook.sh" # user-defined hook that may be available ambiently
|
|
|
|
];
|
|
|
|
fix."/bin/echo" = true;
|
|
|
|
keep = {
|
|
|
|
"$command" = true;
|
|
|
|
"$kreadconfig" = true;
|
|
|
|
"$THUNDERBIRD" = true;
|
|
|
|
"$utf8" = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
scripts = [ "bin/xdg-icon-resource" ];
|
|
|
|
interpreter = "${bash}/bin/bash";
|
|
|
|
inputs = commonDeps;
|
|
|
|
fake.external = commonFakes;
|
|
|
|
keep."$KDE_SESSION_VERSION" = true;
|
|
|
|
prologue = commonPrologue;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
scripts = [ "bin/xdg-mime" ];
|
|
|
|
interpreter = "${bash}/bin/bash";
|
|
|
|
inputs = commonDeps ++ [ file gawk ];
|
|
|
|
# These are desktop-specific, so we don't want xdg-utils to be able to
|
|
|
|
# call them when in a different setup.
|
|
|
|
fake.external = commonFakes ++ [
|
|
|
|
"gio" # GNOME (new)
|
|
|
|
"gnomevfs-info" # GNOME (very old)
|
|
|
|
"gvfs-info" # GNOME (old)
|
|
|
|
"kde4-config" # Plasma 4
|
|
|
|
"kfile" # KDE 3
|
|
|
|
"kmimetypefinder" # Plasma (generic)
|
|
|
|
"kmimetypefinder5" # Plasma 5
|
|
|
|
"ktraderclient" # KDE 3
|
|
|
|
"ktradertest" # KDE 3
|
|
|
|
"mimetype" # alternative tool for file, pulls in perl, avoid
|
|
|
|
"qtpaths" # Plasma
|
|
|
|
"qtxdg-mat" # LXQT
|
|
|
|
];
|
|
|
|
fix."/usr/bin/file" = true;
|
|
|
|
keep = {
|
|
|
|
"$KDE_SESSION_VERSION" = true;
|
|
|
|
"$KTRADER" = true;
|
|
|
|
};
|
|
|
|
prologue = commonPrologue;
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
scripts = [ "bin/xdg-open" ];
|
|
|
|
interpreter = "${bash}/bin/bash";
|
2024-02-04 23:40:00 +00:00
|
|
|
inputs = commonDeps ++ [ nettools glib.bin "${placeholder "out"}/bin" ];
|
2024-01-31 08:35:03 +00:00
|
|
|
execer = [
|
|
|
|
"cannot:${placeholder "out"}/bin/xdg-mime"
|
|
|
|
];
|
|
|
|
# These are desktop-specific, so we don't want xdg-utils to be able to
|
|
|
|
# call them when in a different setup.
|
|
|
|
fake.external = commonFakes ++ [
|
|
|
|
"cygstart" # Cygwin
|
|
|
|
"dde-open" # Deepin
|
|
|
|
"enlightenment_open" # Enlightenment
|
|
|
|
"exo-open" # XFCE
|
|
|
|
"gio" # GNOME (new)
|
|
|
|
"gnome-open" # GNOME (very old)
|
|
|
|
"gvfs-open" # GNOME (old)
|
|
|
|
"kde-open" # Plasma
|
|
|
|
"kfmclient" # KDE3
|
|
|
|
"mate-open" # MATE
|
|
|
|
"mimeopen" # alternative tool for file, pulls in perl, avoid
|
|
|
|
"open" # macOS
|
|
|
|
"pcmanfm" # LXDE
|
|
|
|
"qtxdg-mat" # LXQT
|
|
|
|
"run-mailcap" # generic
|
|
|
|
"rundll32.exe" # WSL
|
|
|
|
"wslpath" # WSL
|
|
|
|
];
|
|
|
|
fix."$printf" = [ "printf" ];
|
|
|
|
keep = {
|
|
|
|
"env:$command" = true;
|
|
|
|
"$browser" = true;
|
|
|
|
"$KDE_SESSION_VERSION" = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
scripts = [ "bin/xdg-screensaver" ];
|
|
|
|
interpreter = "${bash}/bin/bash";
|
2024-02-05 17:26:47 +00:00
|
|
|
inputs = commonDeps ++ [ nettools perl procmail procps ];
|
2024-01-31 08:35:03 +00:00
|
|
|
# These are desktop-specific, so we don't want xdg-utils to be able to
|
|
|
|
# call them when in a different setup.
|
|
|
|
fake.external = commonFakes ++ [
|
|
|
|
"dcop" # KDE3
|
|
|
|
"mate-screensaver-command" # MATE
|
|
|
|
"xautolock" # Xautolock
|
|
|
|
"xscreensaver-command" # Xscreensaver
|
|
|
|
"xset" # generic-ish X
|
|
|
|
];
|
|
|
|
fix."$lockfile_command" = [ "lockfile" ];
|
|
|
|
keep = {
|
|
|
|
"$MV" = true;
|
|
|
|
"$XPROP" = true;
|
|
|
|
};
|
|
|
|
prologue = "${writeText "xdg-screensaver-prologue" ''
|
|
|
|
export PERL5LIB=${with perlPackages; makePerlPath [ NetDBus XMLTwig XMLParser X11Protocol ]}
|
|
|
|
export PATH=$PATH:${coreutils}/bin
|
|
|
|
''}";
|
|
|
|
}
|
|
|
|
|
|
|
|
{
|
|
|
|
scripts = [ "bin/xdg-settings" ];
|
|
|
|
interpreter = "${bash}/bin/bash";
|
|
|
|
inputs = commonDeps ++ [ jq "${placeholder "out"}/bin" ];
|
|
|
|
execer = [
|
|
|
|
"cannot:${placeholder "out"}/bin/xdg-mime"
|
|
|
|
];
|
|
|
|
# These are desktop-specific, so we don't want xdg-utils to be able to
|
|
|
|
# call them when in a different setup.
|
|
|
|
fake.external = commonFakes ++ [
|
|
|
|
"gconftool-2" # GNOME
|
|
|
|
"kreadconfig" # Plasma (generic)
|
|
|
|
"kreadconfig5" # Plasma 5
|
|
|
|
"kreadconfig6" # Plasma 6
|
|
|
|
"ktradertest" # KDE3
|
|
|
|
"kwriteconfig" # Plasma (generic)
|
|
|
|
"kwriteconfig5" # Plasma 5
|
|
|
|
"kwriteconfig6" # Plasma 6
|
|
|
|
"qtxdg-mat" # LXQT
|
|
|
|
];
|
|
|
|
keep = {
|
|
|
|
"$KDE_SESSION_VERSION" = true;
|
|
|
|
# get_browser_$handler
|
|
|
|
"$handler" = true;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
2015-08-15 19:01:46 +00:00
|
|
|
in
|
2010-03-25 19:48:06 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "xdg-utils";
|
2024-02-06 11:50:23 +00:00
|
|
|
version = "1.2.1";
|
2014-11-06 00:44:33 +00:00
|
|
|
|
2022-03-29 22:57:38 +00:00
|
|
|
src = fetchFromGitLab {
|
|
|
|
domain = "gitlab.freedesktop.org";
|
|
|
|
owner = "xdg";
|
|
|
|
repo = "xdg-utils";
|
2024-01-31 08:35:03 +00:00
|
|
|
rev = "v${version}";
|
2024-02-06 11:50:23 +00:00
|
|
|
hash = "sha256-58ElbrVlk+13DUODSEHBPcDDt9H+Kuee8Rz9CIcoy0I=";
|
2010-03-25 19:48:06 +00:00
|
|
|
};
|
2012-10-04 11:38:26 +00:00
|
|
|
|
2024-02-06 11:50:23 +00:00
|
|
|
patches = lib.optionals withXdgOpenUsePortalPatch [
|
2022-10-21 20:16:49 +00:00
|
|
|
# Allow forcing the use of XDG portals using NIXOS_XDG_OPEN_USE_PORTAL environment variable.
|
|
|
|
# Upstream PR: https://github.com/freedesktop/xdg-utils/pull/12
|
|
|
|
./allow-forcing-portal-use.patch
|
|
|
|
];
|
|
|
|
|
2015-02-07 06:30:05 +00:00
|
|
|
# just needed when built from git
|
2024-01-31 08:35:03 +00:00
|
|
|
nativeBuildInputs = [ libxslt docbook_xml_dtd_412 docbook_xml_dtd_43 docbook_xsl xmlto ];
|
2015-01-25 13:30:27 +00:00
|
|
|
|
2023-07-30 00:25:25 +00:00
|
|
|
# explicitly provide a runtime shell so patchShebangs is consistent across build platforms
|
|
|
|
buildInputs = [ bash ];
|
|
|
|
|
2021-01-15 09:19:50 +00:00
|
|
|
postInstall = lib.optionalString mimiSupport ''
|
2015-08-15 19:01:46 +00:00
|
|
|
cp ${mimisrc}/xdg-open $out/bin/xdg-open
|
2012-10-04 11:38:26 +00:00
|
|
|
'';
|
2014-11-06 00:44:33 +00:00
|
|
|
|
2024-01-31 08:35:03 +00:00
|
|
|
preFixup = lib.concatStringsSep "\n" (map (resholve.phraseSolution "xdg-utils-resholved") solutions);
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2020-04-01 01:11:51 +00:00
|
|
|
homepage = "https://www.freedesktop.org/wiki/Software/xdg-utils/";
|
2010-03-25 19:48:06 +00:00
|
|
|
description = "A set of command line tools that assist applications with a variety of desktop integration tasks";
|
2023-12-16 12:58:54 +00:00
|
|
|
license = if mimiSupport then licenses.gpl2 else licenses.mit;
|
2015-08-15 19:01:46 +00:00
|
|
|
maintainers = [ maintainers.eelco ];
|
2015-10-28 17:49:04 +00:00
|
|
|
platforms = platforms.all;
|
2010-03-25 19:48:06 +00:00
|
|
|
};
|
|
|
|
}
|