Skip to content
This repository has been archived by the owner on Feb 6, 2024. It is now read-only.

Commit

Permalink
xdg-utils: unstable-2023-12-04 -> 1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
K900 committed Jan 31, 2024
1 parent 655ec0f commit e7aded2
Show file tree
Hide file tree
Showing 3 changed files with 314 additions and 22 deletions.
24 changes: 2 additions & 22 deletions pkgs/kde/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@
libsForQt5,
qt6Packages,
cmark,
docbook_xml_dtd_43,
gpgme,
taglib,
wayland-protocols,
wayland,
xdg-utils,
zxing-cpp,
}: let
allPackages = self: let
Expand Down Expand Up @@ -100,26 +98,8 @@
};
});

xdg-utils = xdg-utils.overrideAttrs (old: {
version = "unstable-2023-12-04";

src = fetchFromGitLab {
domain = "gitlab.freedesktop.org";
owner = "xdg";
repo = "xdg-utils";
rev = "d4f00e1d803038af4f245949d8c747a384117852";
hash = "sha256-6s8/3+vsALq8ocAfJ1XBlW9nQhpl2MJ61ueCfjz6tGU=";
};

# Intentionally clobber second patch
patches = [(builtins.head old.patches)];

buildInputs =
old.buildInputs
++ [
docbook_xml_dtd_43
];
});
# FIXME: temporarily vendored pending nixpkgs merge
xdg-utils = self.callPackage ./misc/xdg-utils {};

# MISC FRAMEWORKS WITH KF6 DEPS
# These have KF6 dependencies so can't be upstreamed without KF6
Expand Down
29 changes: 29 additions & 0 deletions pkgs/kde/misc/xdg-utils/allow-forcing-portal-use.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
From 835eed6a2b975fba40c3ac18b4cf5429ba9d2836 Mon Sep 17 00:00:00 2001
From: Luna Nova <git@lunnova.dev>
Date: Wed, 7 Sep 2022 08:45:56 -0700
Subject: [PATCH] xdg-open: add $XDG_OPEN_USE_PORTAL env var

When set, the same mechanism that is used in a flatpak is used,
a dbus call to the portal. This is useful for distros with non-flatpak
wrapper or sandboxing features which require the same treatment, eg NixOS.

See https://github.com/NixOS/nixpkgs/issues/160923
---
scripts/xdg-open.in | 4 ++++
1 file changed, 4 insertions(+)

diff --git a/scripts/xdg-open.in b/scripts/xdg-open.in
index 8de839a..80d8fb3 100644
--- a/scripts/xdg-open.in
+++ b/scripts/xdg-open.in
@@ -508,6 +508,10 @@ if [ x"$DE" = x"" ]; then
DE=generic
fi

+if [ -n "$NIXOS_XDG_OPEN_USE_PORTAL" ]; then
+ DE=flatpak
+fi
+
DEBUG 2 "Selected DE $DE"

# sanitize BROWSER (avoid calling ourselves in particular)
283 changes: 283 additions & 0 deletions pkgs/kde/misc/xdg-utils/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,283 @@
{
lib,
stdenv,
fetchFromGitLab,
fetchFromGitHub,
fetchpatch,
writeText,
# docs deps
libxslt,
docbook_xml_dtd_412,
docbook_xml_dtd_43,
docbook_xsl,
xmlto,
# runtime deps
resholve,
bash,
coreutils,
dbus,
file,
gawk,
gnugrep,
gnused,
jq,
nettools,
procmail,
procps,
perl,
perlPackages,
mimiSupport ? false,
withXdgOpenUsePortalPatch ? true,
}: let
# A much better xdg-open
mimisrc = fetchFromGitHub {
owner = "march-linux";
repo = "mimi";
rev = "8e0070f17bcd3612ee83cb84e663e7c7fabcca3d";
sha256 = "15gw2nyrqmdsdin8gzxihpn77grhk9l97jp7s7pr7sl4n9ya2rpj";
};

# Required by the common desktop detection code
commonDeps = [dbus coreutils gnugrep gnused];
commonFakes = [
"explorer.exe"
"gnome-default-applications-properties"
"kde-config"
"xprop"
];

# 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;
fake.external =
commonFakes
++ [
"gconftool-2"
"xdg-user-dir"
];
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";
inputs = commonDeps ++ [gawk "${placeholder "out"}/bin"];
execer = [
"cannot:${placeholder "out"}/bin/xdg-mime"
"cannot:${placeholder "out"}/bin/xdg-open"
];
fake.external =
commonFakes
++ [
"exo-open"
"gconftool-2"
"gdbus"
"gio"
"gnome-open"
"gvfs-open"
"qtxdg-mat"
"xdg-email-hook.sh"
];
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];
fake.external =
commonFakes
++ [
"gio"
"gnomevfs-info"
"gvfs-info"
"kde4-config"
"kfile"
"kmimetypefinder"
"kmimetypefinder5"
"ktraderclient"
"ktradertest"
"mimetype"
"qtpaths"
"qtxdg-mat"
];
fix."/usr/bin/file" = true;
keep = {
"$KDE_SESSION_VERSION" = true;
"$KTRADER" = true;
};
}

{
scripts = ["bin/xdg-open"];
interpreter = "${bash}/bin/bash";
inputs = commonDeps ++ [nettools "${placeholder "out"}/bin"];
execer = [
"cannot:${placeholder "out"}/bin/xdg-mime"
];
fake.external =
commonFakes
++ [
"cygstart"
"dde-open"
"enlightenment_open"
"env"
"exo-open"
"gdbus"
"gio"
"gnome-open"
"gvfs-open"
"kde-open"
"kfmclient"
"mate-open"
"mimeopen"
"open"
"pcmanfm"
"qtxdg-mat"
"run-mailcap"
"rundll32.exe"
"wslpath"

# actually part of a doc string, resholve bug?
"troublesome"
];
keep = {
"$browser" = true;
"$KDE_SESSION_VERSION" = true;
"$printf" = true;
};
}

{
scripts = ["bin/xdg-screensaver"];
interpreter = "${bash}/bin/bash";
inputs = commonDeps ++ [nettools perl procmail procps];
fake.external =
commonFakes
++ [
"dcop"
"mate-screensaver-command"
"xautolock"
"xscreensaver-command"
"xset"
];
keep = {
"$lockfile_command" = true;
"$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"
];
fake.external =
commonFakes
++ [
"gconftool-2"
"kreadconfig"
"kreadconfig5"
"kreadconfig6"
"ktradertest"
"kwriteconfig"
"kwriteconfig5"
"kwriteconfig6"
"qtxdg-mat"
];
keep = {
"$KDE_SESSION_VERSION" = true;
# get_browser_$handler
"$handler" = true;
};
}
];
in
stdenv.mkDerivation rec {
pname = "xdg-utils";
version = "1.2.0";

src = fetchFromGitLab {
domain = "gitlab.freedesktop.org";
owner = "xdg";
repo = "xdg-utils";
rev = "v${version}";
hash = "sha256-rjNIO4B9jHsBmPaugWTMqTGNpjiw0MTEmf9/ds2Mud4=";
};

patches =
[
# Backport typo fix
(fetchpatch {
url = "https://gitlab.freedesktop.org/xdg/xdg-utils/-/commit/af2fe0d1dcbcd982d84ddf2bbd174afe90976ed9.patch";
hash = "sha256-HhQk06wWkyWjSxjXet+sADKf1irswKxDA8WuOknZKRs=";
})
]
++ 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
];

# just needed when built from git
nativeBuildInputs = [libxslt docbook_xml_dtd_412 docbook_xml_dtd_43 docbook_xsl xmlto];

# explicitly provide a runtime shell so patchShebangs is consistent across build platforms
buildInputs = [bash];

postInstall = lib.optionalString mimiSupport ''
cp ${mimisrc}/xdg-open $out/bin/xdg-open
'';

preFixup = lib.concatStringsSep "\n" (map (resholve.phraseSolution "xdg-utils-resholved") solutions);

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";
license =
if mimiSupport
then licenses.gpl2
else licenses.mit;
maintainers = [maintainers.eelco];
platforms = platforms.all;
};
}

0 comments on commit e7aded2

Please sign in to comment.