nixpkgs/pkgs/tools/X11/xdg-utils/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

93 lines
3.2 KiB
Nix
Raw Normal View History

{ lib, stdenv, fetchFromGitLab, fetchFromGitHub, fetchpatch
2016-03-20 00:50:05 +00:00
, file, libxslt, docbook_xml_dtd_412, docbook_xsl, xmlto
, w3m, gnugrep, gnused, coreutils, xset, perlPackages
, mimiSupport ? false, gawk
, bash
, glib
, withXdgOpenUsePortalPatch ? true }:
2015-08-15 19:01:46 +00:00
let
# A much better xdg-open
mimisrc = fetchFromGitHub {
owner = "march-linux";
repo = "mimi";
rev = "8e0070f17bcd3612ee83cb84e663e7c7fabcca3d";
sha256 = "15gw2nyrqmdsdin8gzxihpn77grhk9l97jp7s7pr7sl4n9ya2rpj";
2015-08-15 19:01:46 +00:00
};
perlPath = with perlPackages; makePerlPath [
NetDBus XMLTwig XMLParser X11Protocol
];
2015-08-15 19:01:46 +00:00
in
stdenv.mkDerivation rec {
pname = "xdg-utils";
version = "unstable-2022-11-06";
2022-03-29 22:57:38 +00:00
src = fetchFromGitLab {
domain = "gitlab.freedesktop.org";
owner = "xdg";
repo = "xdg-utils";
rev = "8ae02631a9806da11b34cd6b274af02d28aee5da";
sha256 = "sha256-WdnnAiPYbREny633FnBi5tD9hDuF8NCVVbUaAVIKTxM=";
};
patches = lib.optionals withXdgOpenUsePortalPatch [
# 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
# Allow opening files when using portal with xdg-open.
# Upstream PR: https://gitlab.freedesktop.org/xdg/xdg-utils/-/merge_requests/65
(fetchpatch {
name = "support-openfile-with-portal.patch";
url = "https://gitlab.freedesktop.org/xdg/xdg-utils/-/commit/5cd8c38f58d9db03240f4bc67267fe3853b66ec7.diff";
hash = "sha256-snkhxwGF9hpqEh5NGG8xixTi/ydAk5apXRtgYrVgNY8=";
})
];
# just needed when built from git
2022-05-29 10:54:03 +00:00
nativeBuildInputs = [ libxslt docbook_xml_dtd_412 docbook_xsl xmlto w3m ];
# 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
2017-06-05 23:37:35 +00:00
'' + ''
sed '2s#.#\
sed() { ${gnused}/bin/sed "$@"; }\
grep() { ${gnugrep}/bin/grep "$@"; }\
egrep() { ${gnugrep}/bin/egrep "$@"; }\
file() { ${file}/bin/file "$@"; }\
awk() { ${gawk}/bin/awk "$@"; }\
2018-03-20 19:15:56 +00:00
xset() { ${xset}/bin/xset "$@"; }\
perl() { PERL5LIB=${perlPath} ${perlPackages.perl}/bin/perl "$@"; }\
mimetype() { ${perlPackages.FileMimeInfo}/bin/mimetype "$@"; }\
PATH=$PATH:'$out'/bin:${coreutils}/bin\
2017-06-05 23:37:35 +00:00
&#' -i "$out"/bin/*
2016-03-20 00:50:39 +00:00
substituteInPlace $out/bin/xdg-open \
--replace "/usr/bin/printf" "${coreutils}/bin/printf" \
--replace "gdbus" "${glib}/bin/gdbus" \
--replace "mimeopen" "${perlPackages.FileMimeInfo}/bin/mimeopen"
2016-03-20 00:50:39 +00:00
substituteInPlace $out/bin/xdg-mime \
--replace "/usr/bin/file" "${file}/bin/file"
2017-08-27 02:11:38 +00:00
substituteInPlace $out/bin/xdg-email \
--replace "/bin/echo" "${coreutils}/bin/echo" \
--replace "gdbus" "${glib}/bin/gdbus"
2017-08-27 02:11:38 +00:00
sed 's|\bwhich\b|type -P|g' -i "$out"/bin/*
'';
meta = with lib; {
homepage = "https://www.freedesktop.org/wiki/Software/xdg-utils/";
description = "A set of command line tools that assist applications with a variety of desktop integration tasks";
2015-08-15 19:01:46 +00:00
license = if mimiSupport then licenses.gpl2 else licenses.free;
maintainers = [ maintainers.eelco ];
2015-10-28 17:49:04 +00:00
platforms = platforms.all;
};
}