about summary refs log tree commit diff
path: root/pkgs/tools/X11/xdg-utils
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/tools/X11/xdg-utils')
-rw-r--r--pkgs/tools/X11/xdg-utils/default.nix63
1 files changed, 42 insertions, 21 deletions
diff --git a/pkgs/tools/X11/xdg-utils/default.nix b/pkgs/tools/X11/xdg-utils/default.nix
index 3cbafa7c97bc9..5b3a1a5367c07 100644
--- a/pkgs/tools/X11/xdg-utils/default.nix
+++ b/pkgs/tools/X11/xdg-utils/default.nix
@@ -1,20 +1,13 @@
-{ lib, stdenv, fetchFromGitLab, fetchFromGitHub, writeText
+{ lib, stdenv, fetchurl, fetchFromGitLab, fetchFromGitHub, runCommand, writeText
 # docs deps
 , libxslt, docbook_xml_dtd_412, docbook_xml_dtd_43, docbook_xsl, xmlto
 # runtime deps
 , resholve, bash, coreutils, dbus, file, gawk, glib, gnugrep, gnused, jq, nettools, procmail, procps, which, xdg-user-dirs
+, shared-mime-info
 , 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 ];
@@ -121,6 +114,7 @@ let
         "$KTRADER" = true;
       };
       prologue = "${writeText "xdg-mime-prologue" ''
+        export XDG_DATA_DIRS="$XDG_DATA_DIRS''${XDG_DATA_DIRS:+:}${shared-mime-info}/share"
         export PERL5LIB=${with perlPackages; makePerlPath [ FileMimeInfo ]}
         export PATH=$PATH:${lib.makeBinPath [ coreutils perlPackages.FileMimeInfo ]}
       ''}";
@@ -165,7 +159,10 @@ let
     {
       scripts = [ "bin/xdg-screensaver" ];
       interpreter = "${bash}/bin/bash";
-      inputs = commonDeps ++ [ nettools perl procmail procps ];
+      inputs = commonDeps ++ [ nettools perl procps ]
+        # procmail's funky build system is currently broken in cross-build.
+        # xdg-screensaver will gracefully degrade if it's not available.
+        ++ lib.optional (stdenv.hostPlatform == stdenv.buildPlatform) procmail;
       # 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 ++ [
@@ -174,7 +171,7 @@ let
         "xautolock"                 # Xautolock
         "xscreensaver-command"      # Xscreensaver
         "xset"                      # generic-ish X
-      ];
+      ] ++ lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) "lockfile"; # procmail
       keep = {
         "$MV" = true;
         "$XPROP" = true;
@@ -237,7 +234,7 @@ let
   ];
 in
 
-stdenv.mkDerivation rec {
+stdenv.mkDerivation (self: {
   pname = "xdg-utils";
   version = "1.2.1";
 
@@ -245,7 +242,7 @@ stdenv.mkDerivation rec {
     domain = "gitlab.freedesktop.org";
     owner = "xdg";
     repo = "xdg-utils";
-    rev = "v${version}";
+    rev = "v${self.version}";
     hash = "sha256-58ElbrVlk+13DUODSEHBPcDDt9H+Kuee8Rz9CIcoy0I=";
   };
 
@@ -263,17 +260,41 @@ stdenv.mkDerivation rec {
   # 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);
 
+  passthru.tests.xdg-mime = runCommand "xdg-mime-test" {
+    nativeBuildInputs = [ self.finalPackage ];
+    preferLocalBuild = true;
+    xenias = lib.mapAttrsToList (hash: urls: fetchurl { inherit hash urls; }) {
+      "sha256-SL95tM1AjOi7vDnCyT10s0tvQvc+ZSZBbkNOYXfbOy0=" = [
+        "https://staging.cohostcdn.org/attachment/0f5d9832-0cda-4d07-b35f-832b287feb6c/kernelkisser.png"
+        "https://static1.e621.net/data/0e/76/0e7672980d48e48c2d1373eb2505db5a.png"
+      ];
+      "sha256-Si9AtB7J9o6rK/oftv+saST77CNaeWomWU5ECfbRioM=" = [
+        "https://static1.e621.net/data/25/3d/253dc77fbc60d7214bc60e4a647d1c32.jpg"
+      ];
+      "sha256-Z+onQRY5zlDWPp5/y4E6crLz3TaMCNipcxEEMSHuLkM=" = [
+        "https://d.furaffinity.net/art/neotheta/1691409857/1691409857.neotheta_quickmakeanentry_by_neotheta-sig.png"
+        "https://static1.e621.net/data/bf/e4/bfe43ba264ad68e5d8a101ecef69c03e.png"
+      ];
+    };
+  } ''
+    for x in $xenias; do
+      ext=''${x##*.}
+      type="$(xdg-mime query filetype $x)"
+      [ $? -eq 0 ] && [ "$type" = "image/''${ext/jpg/jpeg}" ] || {
+        echo "Incorrect MIME type '$type' for '$x'" >&2
+        exit 1
+      }
+    done
+    touch $out
+  '';
+
   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.gpl2Only else licenses.mit;
-    maintainers = [ maintainers.eelco ];
+    description = "Set of command line tools that assist applications with a variety of desktop integration tasks";
+    license = licenses.mit;
+    maintainers = [ ];
     platforms = platforms.all;
   };
-}
+})