Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Package request, ueberzug support in ranger #59906

Closed
alkeryn opened this issue Apr 19, 2019 · 18 comments
Closed

Package request, ueberzug support in ranger #59906

alkeryn opened this issue Apr 19, 2019 · 18 comments
Labels
2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md

Comments

@alkeryn
Copy link
Contributor

alkeryn commented Apr 19, 2019

So there is a python package called ueberzug that can be used to display images in ranger, it is kinda similar to w3m except it works better and most importantly it works in termite in bspwm which w3m dosen't

I found out how to install ueberzug but it dosen't work in ranger for some reason ^

@JohnAZoidberg
Copy link
Member

How did you install it? Can you share your derivation please?

@alkeryn
Copy link
Contributor Author

alkeryn commented Apr 22, 2019

Well i'm not the author of that derivation, someone made it for me

{ python3Packages, fetchFromGitHub, libX11, libXext }:

with python3Packages;

let
pillow-simd = pillow.overrideAttrs (_: rec {
	pname = "Pillow-SIMD";
	version = "5.4.1";

	src = fetchFromGitHub {
	owner = "uploadcare";
	repo = "pillow-simd";
	rev = version;
	sha256 = "07c4pkyfg641mb0xfqw349p5s11n4f241v3mkvba2z58w112kgmf";
	};
	});
in
buildPythonPackage rec {
    pname = "ueberzug";
    version = "18.1.3";

    src = fetchPypi {
	inherit pname version;
	sha256 = "1galc64vbi8d1nbq7d8387my87jq4kqmv30jhlcwrl8g7yph00kg";
    };

    postPatch = ''
	substituteInPlace setup.py --replace "pillow-simd" "pillow"
	'';

    buildInputs = [ libX11 libXext ];

    propagatedBuildInputs = [
	xlib
	    pillow-simd
	    psutil
	    docopt
	    attrs
    ];
}

@JohnAZoidberg
Copy link
Member

JohnAZoidberg commented Apr 22, 2019

Ranger has merged ueberzug support but hasn't published a release since then. Therefore the current version in nixpkgs of ranger doesn't support ueberzug yet.
See: ranger/ranger#1284

I tried it out with their current master and it does indeed work with your derivation for ueberzug. (Notice that version 5.4.1 of pillow-simd isn't actually the simd variant, so it's slower)

Here's my ranger derivation:

{ fetchFromGitHub, ranger }:
ranger.overrideAttrs(_old: {
  src = fetchFromGitHub {
    owner = "ranger";
    repo = "ranger";
    rev = "d21f60f2a3c4a15e5b0346d28667409fd920417e";
    sha256= "02gdcs75x2w39j7glm2qd43jm4cidk3jnqrqh3jl5024cql617vd";
  };
})

So I guess we'll have to wait for them to make another release to merge it into nixpkgs, or patch it ourselves.

@alkeryn
Copy link
Contributor Author

alkeryn commented Apr 23, 2019

Oh ok thank you, i was surprised because ranger --version outputed the same but maybe the dev branch didn't updated it well thanks, i guess you can close it as any ranger update will fix it ^

@JohnAZoidberg
Copy link
Member

Do you want to package ueberzug and make a PR to nixpkgs?

@alkeryn
Copy link
Contributor Author

alkeryn commented Apr 25, 2019

Well i could do it, i'm just not the author of that derivation so i'm not much a fan of taking credits for things i didn't do

@JohnAZoidberg
Copy link
Member

Who's the author? Do they want to make the commits?
Otherwise I'd do it - there are some changes that I would want to make anyways.

@alkeryn
Copy link
Contributor Author

alkeryn commented Apr 26, 2019

@tadeokondrak is the author
Ok ^

@tadeokondrak
Copy link
Member

Yeah, I would submit it to nixpkgs but I wasn't exactly sure how Pillow-SIMD should work (the main Pillow derivation is pretty complicated), so I haven't, feel free to do that.

@JohnAZoidberg
Copy link
Member

I renamed the default.nix of pillow to pillow.nix and replaced it with:

{ stdenv, lib, fetchFromGitHub, fetchPypi, callPackage, simd ? false, ... }:
let pillow = callPackage ./pillow.nix {};
in
  if simd
  then (pillow.overrideAttrs (old: rec {
    pname = "pillow-simd";
    version = "5.3.0.post1";
    src = fetchFromGitHub {
	    owner = "uploadcare";
	    repo = "pillow-simd";
	    rev = "v${version}";
	    sha256 = "1xy92vvrf2ljzcp1f9mq3xipfm89sfrargv15fg8qf567z80rs5c";
	  };
    meta.platforms = lib.platforms.x86_64;  # Needs x86 SIMD instructions
  }))
  else pillow

Then in pkgs/top-level/python-packages.nix I changed:

   pillow = callPackage ../development/python-modules/pillow {          
-    inherit (pkgs) freetype libjpeg zlib libtiff libwebp tcl lcms2 tk; 
+    inherit (pkgs.xorg) libX11;                                        
+  };                                                                   
+                                                                       
+  pillow-simd = callPackage ../development/python-modules/pillow {     
+    simd = true;                                                       
     inherit (pkgs.xorg) libX11;                                        
   };                                                                   

For ueberzeug you don't need the substitute, should check for the python version and can choose between the pillow versions:

{ stdenv, buildPythonPackage, fetchFromGitHub, fetchPypi, pythonAtLeast
, libX11, libXext
, xlib, psutil, docopt, attrs, pillow-simd ? null, pillow }:
buildPythonPackage rec {
  pname = "ueberzug";
  version = "18.1.3";

  src = fetchPypi {
    inherit pname version;
    sha256 = "1galc64vbi8d1nbq7d8387my87jq4kqmv30jhlcwrl8g7yph00kg";
  };

 buildInputs = [ libX11 libXext ];

 propagatedBuildInputs = [
   xlib
   psutil
   docopt
   attrs
   (if pillow-simd == null || (!stdenv.hostPlatform.isx86_64) then pillow else pillow-simd)
 ];

 disabled = !(pythonAtLeast "3.5");

  meta = with stdenv.lib; {
    description = "Command line utility which allows to display images in combination with X11";
    homepage = https://github.com/seebye/ueberzug;
    license = licenses.gpl3;
    maintainer = with maintainers; [ tadeokondrak ];
  };
}

Also don't forget to add it to pkgs/top-level/python-packages.nix.

While we're at it, we might as well patch ranger because we're too impatient to wait for the next release :P

-{ stdenv, lib, fetchFromGitHub, python3Packages, file, less, highlight
-, imagePreviewSupport ? true, w3m ? null}:
+{ stdenv, lib, fetchFromGitHub, fetchpatch, python3Packages, file, less, highlight
+, imagePreviewSupport ? true }:

 with stdenv.lib;

-assert imagePreviewSupport -> w3m != null;
-
 python3Packages.buildPythonApplication rec {
   name = "ranger-${version}";
   version = "1.9.2";
@@ -16,11 +14,16 @@ python3Packages.buildPythonApplication rec {
     sha256= "1ws6g8z1m1hfp8bv4msvbaa9f7948p687jmc8h69yib4jkv3qyax";
   };

+  patches = [(fetchpatch {
+    url = "https://patch-diff.githubusercontent.com/raw/ranger/ranger/pull/1284.diff";
+    sha256 = "1hf7wp5d94g2qhdar03h861lwfl71405a3az55lrhwd7z5bsbpx1";
+  })];
+
   LC_ALL = "en_US.UTF-8";

   checkInputs = with python3Packages; [ pytest ];
   propagatedBuildInputs = [ file ]
-    ++ lib.optional (imagePreviewSupport) [ python3Packages.pillow ];
+     ++ (lib.optional imagePreviewSupport (with python3Packages; [ ueberzug ]));

   checkPhase = ''
     py.test tests
@@ -46,12 +49,11 @@ python3Packages.buildPythonApplication rec {
     substituteInPlace ranger/config/rc.conf \
       --replace "#set preview_script ~/.config/ranger/scope.sh" "set preview_script $out/share/doc/ranger/config/scope.sh"                                                                                                                   
   '' + optionalString imagePreviewSupport ''
-    substituteInPlace ranger/ext/img_display.py \
-      --replace /usr/lib/w3m ${w3m}/libexec/w3m
-
-    # give image previews out of the box when building with w3m
+    # give image previews out of the box when building with
     substituteInPlace ranger/config/rc.conf \
       --replace "set preview_images false" "set preview_images true"
+    substituteInPlace ranger/config/rc.conf \
+      --replace "set preview_images_method w3m" "set preview_images_method ueberzug"
   '';

   meta =  with lib; {

@JohnAZoidberg
Copy link
Member

Oh and it works fantastically in ranger :)

@JohnAZoidberg
Copy link
Member

Ranger has published a new release with ueberzug support.
I'll make a PR with my proposed changes, if nobody else wants to do it. cc @alkeryn

@alkeryn
Copy link
Contributor Author

alkeryn commented Jan 4, 2020

@JohnAZoidberg Thanks !

@stale
Copy link

stale bot commented Jul 2, 2020

Thank you for your contributions.

This has been automatically marked as stale because it has had no activity for 180 days.

If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

Here are suggestions that might help resolve this more quickly:

  1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
  2. Ask on the NixOS Discourse.
  3. Ask on the #nixos channel on irc.freenode.net.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jul 2, 2020
@Enteee
Copy link
Contributor

Enteee commented Aug 16, 2020

The pull request that added support for this in ranger was released with 1.9.3. We do have ranger 1.9.3 in nixpkgs. I think we can close this issue.

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Aug 16, 2020
@stale
Copy link

stale bot commented Feb 13, 2021

I marked this as stale due to inactivity. → More info

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Feb 13, 2021
@patka-123
Copy link
Contributor

Hi @alkeryn 👋

When reading the above comments I get the impression that this issue has been resolved. If so, would you be able to close this issue?

(I'm going through issues marked as stale to see what can be resolved. If this is still an issue then don't mind me).

@teto
Copy link
Member

teto commented Nov 23, 2023

@patka-123 where there is little doubt like here, I think it's fair to close and ask for the person to reopen if it's still not solved.

@teto teto closed this as completed Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
Projects
None yet
Development

No branches or pull requests

6 participants