emacsPackages.lsp-bridge: 0-unstable-2025-01-11 -> 0-unstable-2025-01-22 (#376531)
[NixPkgs.git] / pkgs / applications / terminal-emulators / rxvt-unicode / default.nix
blobe380fe052d266a5b697802604f6aed1d79e1d702
2   lib,
3   stdenv,
4   fetchurl,
5   fetchpatch,
6   makeDesktopItem,
7   libX11,
8   libXt,
9   libXft,
10   libXrender,
11   libXext,
12   ncurses,
13   fontconfig,
14   freetype,
15   pkg-config,
16   gdk-pixbuf,
17   perl,
18   libptytty,
19   perlSupport ? true,
20   gdkPixbufSupport ? true,
21   unicode3Support ? true,
22   emojiSupport ? false,
23   nixosTests,
26 let
27   pname = "rxvt-unicode";
28   version = "9.31";
29   description = "A clone of the well-known terminal emulator rxvt";
31   desktopItem = makeDesktopItem {
32     name = pname;
33     exec = "urxvt";
34     icon = "utilities-terminal";
35     comment = description;
36     desktopName = "URxvt";
37     genericName = pname;
38     categories = [
39       "System"
40       "TerminalEmulator"
41     ];
42   };
44   fetchPatchFromAUR =
45     {
46       package,
47       name,
48       rev,
49       sha256,
50     }:
51     fetchpatch rec {
52       url = "https://aur.archlinux.org/cgit/aur.git/plain/${name}?h=${package}&id=${rev}";
53       extraPrefix = "";
54       inherit name sha256;
55     };
58 stdenv.mkDerivation {
59   name = "${pname}-unwrapped-${version}";
60   inherit pname version;
62   src = fetchurl {
63     url = "http://dist.schmorp.de/rxvt-unicode/Attic/rxvt-unicode-${version}.tar.bz2";
64     sha256 = "qqE/y8FJ/g8/OR+TMnlYD3Spb9MS1u0GuP8DwtRmcug=";
65   };
67   nativeBuildInputs = [ pkg-config ];
68   buildInputs =
69     [
70       libX11
71       libXt
72       libXft
73       ncurses # required to build the terminfo file
74       fontconfig
75       freetype
76       libXrender
77       libptytty
78     ]
79     ++ lib.optionals perlSupport [
80       perl
81       libXext
82     ]
83     ++ lib.optional gdkPixbufSupport gdk-pixbuf;
85   outputs = [
86     "out"
87     "terminfo"
88   ];
90   patches =
91     (
92       if emojiSupport then
93         [
94           # the required patches to libXft are in nixpkgs by default, see
95           # ../../../servers/x11/xorg/overrides.nix
96           (fetchPatchFromAUR {
97             name = "enable-wide-glyphs.patch";
98             package = "rxvt-unicode-truecolor-wide-glyphs";
99             rev = "69701a09c2c206233952b84bc966407f6774f1dc";
100             sha256 = "0jfcj0ahky4dxdfrhqvh1v83mblhf5nak56dk1vq3bhyifdg7ffq";
101           })
102           (fetchPatchFromAUR {
103             name = "improve-font-rendering.patch";
104             package = "rxvt-unicode-truecolor-wide-glyphs";
105             rev = "69701a09c2c206233952b84bc966407f6774f1dc";
106             sha256 = "1jj5ai2182nq912279adihi4zph1w4dvbdqa1pwacy4na6y0fz9y";
107           })
108         ]
109       else
110         [
111           ./patches/9.06-font-width.patch
112         ]
113     )
114     ++ [
115       ./patches/256-color-resources.patch
116     ]
117     ++ lib.optional (perlSupport && lib.versionAtLeast perl.version "5.38") (fetchpatch {
118       name = "perl538-locale-c.patch";
119       url = "https://github.com/exg/rxvt-unicode/commit/16634bc8dd5fc4af62faf899687dfa8f27768d15.patch";
120       excludes = [ "Changes" ];
121       sha256 = "sha256-JVqzYi3tcWIN2j5JByZSztImKqbbbB3lnfAwUXrumHM=";
122     })
123     ++ lib.optional stdenv.hostPlatform.isDarwin ./patches/makefile-phony.patch;
125   configureFlags = [
126     "--with-terminfo=${placeholder "terminfo"}/share/terminfo"
127     "--enable-256-color"
128     (lib.enableFeature perlSupport "perl")
129     (lib.enableFeature unicode3Support "unicode3")
130   ] ++ lib.optional emojiSupport "--enable-wide-glyphs";
132   LDFLAGS = [
133     "-lfontconfig"
134     "-lXrender"
135     "-lpthread"
136   ];
137   CFLAGS = [ "-I${freetype.dev}/include/freetype2" ];
139   preConfigure =
140     ''
141       # without this the terminfo won't be compiled by tic, see man tic
142       mkdir -p $terminfo/share/terminfo
143       export TERMINFO=$terminfo/share/terminfo
144     ''
145     + lib.optionalString perlSupport ''
146       # make urxvt find its perl file lib/perl5/site_perl
147       # is added to PERL5LIB automatically
148       mkdir -p $out/$(dirname ${perl.libPrefix})
149       ln -s $out/lib/urxvt $out/${perl.libPrefix}
150     '';
152   postInstall = ''
153     mkdir -p $out/nix-support
154     echo "$terminfo" >> $out/nix-support/propagated-user-env-packages
155     cp -r ${desktopItem}/share/applications/ $out/share/
156   '';
158   passthru.tests.test = nixosTests.terminal-emulators.urxvt;
160   meta = with lib; {
161     inherit description;
162     homepage = "http://software.schmorp.de/pkg/rxvt-unicode.html";
163     downloadPage = "http://dist.schmorp.de/rxvt-unicode/Attic/";
164     maintainers = with maintainers; [ rnhmjoj ];
165     platforms = platforms.unix;
166     license = licenses.gpl3;
167   };