diff --git a/doc/builders/packages/index.xml b/doc/builders/packages/index.xml index 9f3f58a8d90..4e109bd1c59 100644 --- a/doc/builders/packages/index.xml +++ b/doc/builders/packages/index.xml @@ -18,6 +18,7 @@ + diff --git a/doc/builders/packages/urxvt.xml b/doc/builders/packages/urxvt.xml new file mode 100644 index 00000000000..f85680cecc4 --- /dev/null +++ b/doc/builders/packages/urxvt.xml @@ -0,0 +1,101 @@ +
+ Urxvt + + + Urxvt, also known as rxvt-unicode, is a highly customizable terminal emulator. + + +
+ + Configuring urxvt + + + In nixpkgs, urxvt is provided by the package + rxvt-unicode. It can be configured to include your choice + of plugins, reducing its closure size from the default configuration which + includes all available plugins. To make use of this functionality, use an + overlay or directly install an expression that overrides its configuration, + such as + rxvt-unicode.override { configure = { availablePlugins, ... }: { + plugins = with availablePlugins; [ perls resize-font vtwheel ]; + } +} + If the configure function returns an attrset without the + plugins attribute, availablePlugins + will be used automatically. + + + + In order to add plugins but also keep all default plugins installed, it is + possible to use the following method: + rxvt-unicode.override { configure = { availablePlugins, ... }: { + plugins = (builtins.attrValues availablePlugins) ++ [ custom-plugin ]; + }; +} + + + + To get a list of all the plugins available, open the Nix REPL and run + $ nix repl +:l <nixpkgs> +map (p: p.name) pkgs.rxvt-unicode.plugins + + Alternatively, if your shell is bash or zsh and have completion enabled, + simply type nixpkgs.rxvt-unicode.plugins.<tab>. + + + + In addition to plugins the options + extraDeps and perlDeps can be used + to install extra packages. + extraDeps can be used, for example, to provide + xsel (a clipboard manager) to the clipboard plugin, + without installing it globally: + rxvt-unicode.override { configure = { availablePlugins, ... }: { + pluginsDeps = [ xsel ]; + } +} + + perlDeps is a handy way to provide Perl packages to + your custom plugins (in $HOME/.urxvt/ext). For example, + if you need AnyEvent you can do: + rxvt-unicode.override { configure = { availablePlugins, ... }: { + perlDeps = with perlPackages; [ AnyEvent ]; + } +} + + +
+ +
+ + Packaging urxvt plugins + + + Urxvt plugins resides in + pkgs/applications/misc/rxvt-unicode-plugins. + To add a new plugin create an expression in a subdirectory and add the + package to the set in + pkgs/applications/misc/rxvt-unicode-plugins/default.nix. + + + + A plugin can be any kind of derivation, the only requirement is that it + should always install perl scripts in $out/lib/urxvt/perl. + Look for existing plugins for examples. + + + + If the plugin is itself a perl package that needs to be imported from + other plugins or scripts, add the following passthrough: + passthru.perlPackages = [ "self" ]; + + This will make the urxvt wrapper pick up the dependency and set up the perl + path accordingly. + + +
+ +
diff --git a/pkgs/applications/misc/rxvt-unicode-plugins/default.nix b/pkgs/applications/misc/rxvt-unicode-plugins/default.nix new file mode 100644 index 00000000000..74bfbe83e91 --- /dev/null +++ b/pkgs/applications/misc/rxvt-unicode-plugins/default.nix @@ -0,0 +1,22 @@ +{ callPackage }: + +{ + autocomplete-all-the-things = callPackage ./urxvt-autocomplete-all-the-things { }; + + bidi = callPackage ./urxvt-bidi { }; + + font-size = callPackage ./urxvt-font-size { }; + + perl = callPackage ./urxvt-perl { }; + + perls = callPackage ./urxvt-perls { }; + + resize-font = callPackage ./urxvt-resize-font { }; + + tabbedex = callPackage ./urxvt-tabbedex { }; + + theme-switch = callPackage ./urxvt-theme-switch { }; + + vtwheel = callPackage ./urxvt-vtwheel { }; + +} diff --git a/pkgs/applications/misc/rxvt_unicode-plugins/urxvt-autocomplete-all-the-things/default.nix b/pkgs/applications/misc/rxvt-unicode-plugins/urxvt-autocomplete-all-the-things/default.nix similarity index 100% rename from pkgs/applications/misc/rxvt_unicode-plugins/urxvt-autocomplete-all-the-things/default.nix rename to pkgs/applications/misc/rxvt-unicode-plugins/urxvt-autocomplete-all-the-things/default.nix diff --git a/pkgs/applications/misc/rxvt_unicode-plugins/urxvt-bidi/default.nix b/pkgs/applications/misc/rxvt-unicode-plugins/urxvt-bidi/default.nix similarity index 95% rename from pkgs/applications/misc/rxvt_unicode-plugins/urxvt-bidi/default.nix rename to pkgs/applications/misc/rxvt-unicode-plugins/urxvt-bidi/default.nix index 3e67e4ec085..4b6b4eb8184 100644 --- a/pkgs/applications/misc/rxvt_unicode-plugins/urxvt-bidi/default.nix +++ b/pkgs/applications/misc/rxvt-unicode-plugins/urxvt-bidi/default.nix @@ -16,6 +16,8 @@ perlPackages.buildPerlPackage rec { install -Dm555 misc/bidi "$out/lib/urxvt/perl/bidi" ''; + passthru.perlPackages = [ "self" ]; + meta = with lib; { description = "Text::Bidi Perl package using fribidi, providing a urxvt plugin"; homepage = "https://github.com/mkamensky/Text-Bidi"; diff --git a/pkgs/applications/misc/rxvt_unicode-plugins/urxvt-font-size/default.nix b/pkgs/applications/misc/rxvt-unicode-plugins/urxvt-font-size/default.nix similarity index 100% rename from pkgs/applications/misc/rxvt_unicode-plugins/urxvt-font-size/default.nix rename to pkgs/applications/misc/rxvt-unicode-plugins/urxvt-font-size/default.nix diff --git a/pkgs/applications/misc/rxvt_unicode-plugins/urxvt-perl/default.nix b/pkgs/applications/misc/rxvt-unicode-plugins/urxvt-perl/default.nix similarity index 100% rename from pkgs/applications/misc/rxvt_unicode-plugins/urxvt-perl/default.nix rename to pkgs/applications/misc/rxvt-unicode-plugins/urxvt-perl/default.nix diff --git a/pkgs/applications/misc/rxvt_unicode-plugins/urxvt-perls/default.nix b/pkgs/applications/misc/rxvt-unicode-plugins/urxvt-perls/default.nix similarity index 100% rename from pkgs/applications/misc/rxvt_unicode-plugins/urxvt-perls/default.nix rename to pkgs/applications/misc/rxvt-unicode-plugins/urxvt-perls/default.nix diff --git a/pkgs/applications/misc/rxvt-unicode-plugins/urxvt-resize-font/default.nix b/pkgs/applications/misc/rxvt-unicode-plugins/urxvt-resize-font/default.nix new file mode 100644 index 00000000000..a056e603f00 --- /dev/null +++ b/pkgs/applications/misc/rxvt-unicode-plugins/urxvt-resize-font/default.nix @@ -0,0 +1,27 @@ +{ stdenv, fetchFromGitHub }: + +stdenv.mkDerivation { + pname = "urxvt-resize-font"; + version = "2019-10-05"; + dontPatchShebangs = true; + + src = fetchFromGitHub { + owner = "simmel"; + repo = "urxvt-resize-font"; + rev = "e966a5d77264e9263bfc8a51e160fad24055776b"; + sha256 = "18ab3bsfdkzzh1n9fpi2al5bksvv2b7fjmvxpx6fzqcy4bc64vkh"; + }; + + installPhase = '' + mkdir -p $out/lib/urxvt/perl + cp resize-font $out/lib/urxvt/perl + ''; + + meta = with stdenv.lib; { + description = "URxvt Perl extension for resizing the font"; + homepage = "https://github.com/simmel/urxvt-resize-font"; + license = licenses.mit; + maintainers = with maintainers; [ rnhmjoj ]; + platforms = platforms.unix; + }; +} diff --git a/pkgs/applications/misc/rxvt_unicode-plugins/urxvt-tabbedex/default.nix b/pkgs/applications/misc/rxvt-unicode-plugins/urxvt-tabbedex/default.nix similarity index 100% rename from pkgs/applications/misc/rxvt_unicode-plugins/urxvt-tabbedex/default.nix rename to pkgs/applications/misc/rxvt-unicode-plugins/urxvt-tabbedex/default.nix diff --git a/pkgs/applications/misc/rxvt_unicode-plugins/urxvt-theme-switch/default.nix b/pkgs/applications/misc/rxvt-unicode-plugins/urxvt-theme-switch/default.nix similarity index 100% rename from pkgs/applications/misc/rxvt_unicode-plugins/urxvt-theme-switch/default.nix rename to pkgs/applications/misc/rxvt-unicode-plugins/urxvt-theme-switch/default.nix diff --git a/pkgs/applications/misc/rxvt_unicode-plugins/urxvt-vtwheel.nix b/pkgs/applications/misc/rxvt-unicode-plugins/urxvt-vtwheel/default.nix similarity index 100% rename from pkgs/applications/misc/rxvt_unicode-plugins/urxvt-vtwheel.nix rename to pkgs/applications/misc/rxvt-unicode-plugins/urxvt-vtwheel/default.nix diff --git a/pkgs/applications/misc/rxvt-unicode/default.nix b/pkgs/applications/misc/rxvt-unicode/default.nix new file mode 100644 index 00000000000..6512f402ffb --- /dev/null +++ b/pkgs/applications/misc/rxvt-unicode/default.nix @@ -0,0 +1,88 @@ +{ stdenv, fetchurl, makeDesktopItem +, libX11, libXt, libXft, libXrender +, ncurses, fontconfig, freetype +, pkgconfig, gdk-pixbuf, perl +, perlSupport ? true +, gdkPixbufSupport ? true +, unicode3Support ? true +}: + +let + pname = "rxvt-unicode"; + version = "9.22"; + description = "A clone of the well-known terminal emulator rxvt"; + + desktopItem = makeDesktopItem { + name = pname; + exec = "urxvt"; + icon = "utilities-terminal"; + comment = description; + desktopName = "URxvt"; + genericName = pname; + categories = "System;TerminalEmulator;"; + }; +in + +with stdenv.lib; + +stdenv.mkDerivation { + name = "${pname}-unwrapped-${version}"; + inherit pname version; + + src = fetchurl { + url = "http://dist.schmorp.de/rxvt-unicode/Attic/rxvt-unicode-${version}.tar.bz2"; + sha256 = "1pddjn5ynblwfrdmskylrsxb9vfnk3w4jdnq2l8xn2pspkljhip9"; + }; + + buildInputs = + [ libX11 libXt libXft ncurses # required to build the terminfo file + fontconfig freetype pkgconfig libXrender + ] ++ optional perlSupport perl + ++ optional gdkPixbufSupport gdk-pixbuf; + + outputs = [ "out" "terminfo" ]; + + patches = [ + ./patches/9.06-font-width.patch + ./patches/256-color-resources.patch + ] ++ optional stdenv.isDarwin ./patches/makefile-phony.patch; + + + configureFlags = [ + "--with-terminfo=$terminfo/share/terminfo" + "--enable-256-color" + (enableFeature perlSupport "perl") + (enableFeature unicode3Support "unicode3") + ]; + + LDFLAGS = [ "-lfontconfig" "-lXrender" "-lpthread" ]; + CFLAGS = [ "-I${freetype.dev}/include/freetype2" ]; + + preConfigure = + '' + # without this the terminfo won't be compiled by tic, see man tic + mkdir -p $terminfo/share/terminfo + export TERMINFO=$terminfo/share/terminfo + '' + + stdenv.lib.optionalString perlSupport '' + # make urxvt find its perl file lib/perl5/site_perl + # is added to PERL5LIB automatically + mkdir -p $out/$(dirname ${perl.libPrefix}) + ln -s $out/lib/urxvt $out/${perl.libPrefix} + ''; + + postInstall = '' + mkdir -p $out/nix-support + echo "$terminfo" >> $out/nix-support/propagated-user-env-packages + cp -r ${desktopItem}/share/applications/ $out/share/ + ''; + + meta = { + inherit description; + homepage = "http://software.schmorp.de/pkg/rxvt-unicode.html"; + downloadPage = "http://dist.schmorp.de/rxvt-unicode/Attic/"; + maintainers = with maintainers; [ rnhmjoj ]; + platforms = platforms.unix; + license = licenses.gpl3; + }; +} diff --git a/pkgs/applications/misc/rxvt_unicode/rxvt-unicode-256-color-resources.patch b/pkgs/applications/misc/rxvt-unicode/patches/256-color-resources.patch similarity index 100% rename from pkgs/applications/misc/rxvt_unicode/rxvt-unicode-256-color-resources.patch rename to pkgs/applications/misc/rxvt-unicode/patches/256-color-resources.patch diff --git a/pkgs/applications/misc/rxvt_unicode/rxvt-unicode-9.06-font-width.patch b/pkgs/applications/misc/rxvt-unicode/patches/9.06-font-width.patch similarity index 100% rename from pkgs/applications/misc/rxvt_unicode/rxvt-unicode-9.06-font-width.patch rename to pkgs/applications/misc/rxvt-unicode/patches/9.06-font-width.patch diff --git a/pkgs/applications/misc/rxvt_unicode/rxvt-unicode-makefile-phony.patch b/pkgs/applications/misc/rxvt-unicode/patches/makefile-phony.patch similarity index 100% rename from pkgs/applications/misc/rxvt_unicode/rxvt-unicode-makefile-phony.patch rename to pkgs/applications/misc/rxvt-unicode/patches/makefile-phony.patch diff --git a/pkgs/applications/misc/rxvt-unicode/wrapper.nix b/pkgs/applications/misc/rxvt-unicode/wrapper.nix new file mode 100644 index 00000000000..38978799b5a --- /dev/null +++ b/pkgs/applications/misc/rxvt-unicode/wrapper.nix @@ -0,0 +1,58 @@ +{ callPackage +, symlinkJoin +, makeWrapper +, lib +, rxvt-unicode-unwrapped +, rxvt-unicode-plugins +, perlPackages +, configure ? { availablePlugins, ... }: + { plugins = builtins.attrValues availablePlugins; + extraDeps = [ ]; + perlDeps = [ ]; + } +}: + +let + availablePlugins = rxvt-unicode-plugins; + + # Transform the string "self" to the plugin itself. + # It's needed for plugins like bidi who depends on the perl + # package they provide themself. + mkPerlDeps = p: + let deps = p.perlPackages or [ ]; + in map (x: if x == "self" then p else x) deps; + + # The wrapper is called with a `configure` function + # that takes the urxvt plugins as input and produce + # the configuration of the wrapper: list of plugins, + # extra dependencies and perl dependencies. + # This provides simple way to customize urxvt using + # the `.override` mechanism. + wrapper = { configure, ... }: + let + config = configure { inherit availablePlugins; }; + plugins = config.plugins or (builtins.attrValues availablePlugins); + extraDeps = config.extraDeps or [ ]; + perlDeps = (config.perlDeps or [ ]) ++ lib.concatMap mkPerlDeps plugins; + in + symlinkJoin { + name = "rxvt-unicode-${rxvt-unicode-unwrapped.version}"; + + paths = [ rxvt-unicode-unwrapped ] ++ plugins ++ extraDeps; + + buildInputs = [ makeWrapper ]; + + postBuild = '' + wrapProgram $out/bin/urxvt \ + --prefix PERL5LIB : "${perlPackages.makePerlPath perlDeps}" \ + --suffix-each URXVT_PERL_LIB ':' "$out/lib/urxvt/perl" + wrapProgram $out/bin/urxvtd \ + --prefix PERL5LIB : "${perlPackages.makePerlPath perlDeps}" \ + --suffix-each URXVT_PERL_LIB ':' "$out/lib/urxvt/perl" + ''; + + passthru.plugins = plugins; + }; + +in + lib.makeOverridable wrapper { inherit configure; } diff --git a/pkgs/applications/misc/rxvt_unicode/default.nix b/pkgs/applications/misc/rxvt_unicode/default.nix deleted file mode 100644 index 7c239a9b754..00000000000 --- a/pkgs/applications/misc/rxvt_unicode/default.nix +++ /dev/null @@ -1,72 +0,0 @@ -{ stdenv, fetchurl, makeDesktopItem, perlSupport ? true, libX11, libXt, libXft, - ncurses, perl, fontconfig, freetype, pkgconfig, libXrender, - gdkPixbufSupport ? true, gdk-pixbuf, unicode3Support ? true }: - -let - pname = "rxvt-unicode"; - version = "9.22"; - description = "A clone of the well-known terminal emulator rxvt"; - - desktopItem = makeDesktopItem { - name = pname; - exec = "urxvt"; - icon = "utilities-terminal"; - comment = description; - desktopName = "URxvt"; - genericName = pname; - categories = "System;TerminalEmulator;"; - }; -in - -stdenv.mkDerivation ({ - - name = "${pname}${if perlSupport then "-with-perl" else ""}${if unicode3Support then "-with-unicode3" else ""}-${version}"; - - src = fetchurl { - url = "http://dist.schmorp.de/rxvt-unicode/Attic/rxvt-unicode-${version}.tar.bz2"; - sha256 = "1pddjn5ynblwfrdmskylrsxb9vfnk3w4jdnq2l8xn2pspkljhip9"; - }; - - buildInputs = - [ libX11 libXt libXft ncurses /* required to build the terminfo file */ - fontconfig freetype pkgconfig libXrender ] - ++ stdenv.lib.optional perlSupport perl - ++ stdenv.lib.optional gdkPixbufSupport gdk-pixbuf; - - outputs = [ "out" "terminfo" ]; - - patches = [ - ./rxvt-unicode-9.06-font-width.patch - ./rxvt-unicode-256-color-resources.patch - ] - ++ stdenv.lib.optional stdenv.isDarwin ./rxvt-unicode-makefile-phony.patch; - - preConfigure = - '' - mkdir -p $terminfo/share/terminfo - configureFlags="--with-terminfo=$terminfo/share/terminfo --enable-256-color ${if perlSupport then "--enable-perl" else "--disable-perl"} ${if unicode3Support then "--enable-unicode3" else "--disable-unicode3"}"; - export TERMINFO=$terminfo/share/terminfo # without this the terminfo won't be compiled by tic, see man tic - NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${freetype.dev}/include/freetype2" - NIX_LDFLAGS="$NIX_LDFLAGS -lfontconfig -lXrender -lpthread " - '' - # make urxvt find its perl file lib/perl5/site_perl is added to PERL5LIB automatically - + stdenv.lib.optionalString perlSupport '' - mkdir -p $out/$(dirname ${perl.libPrefix}) - ln -s $out/lib/urxvt $out/${perl.libPrefix} - ''; - - postInstall = '' - mkdir -p $out/nix-support - echo "$terminfo" >> $out/nix-support/propagated-user-env-packages - cp -r ${desktopItem}/share/applications/ $out/share/ - ''; - - meta = with stdenv.lib; { - inherit description; - homepage = http://software.schmorp.de/pkg/rxvt-unicode.html; - downloadPage = "http://dist.schmorp.de/rxvt-unicode/Attic/"; - maintainers = with maintainers; [ rnhmjoj ]; - platforms = platforms.unix; - license = licenses.gpl3; - }; -}) diff --git a/pkgs/applications/misc/rxvt_unicode/wrapper.nix b/pkgs/applications/misc/rxvt_unicode/wrapper.nix deleted file mode 100644 index fd0860b3aae..00000000000 --- a/pkgs/applications/misc/rxvt_unicode/wrapper.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ symlinkJoin, rxvt_unicode, makeWrapper, plugins, perlPackages, perlDeps ? []}: - -let - rxvt_name = builtins.parseDrvName rxvt_unicode.name; - -in symlinkJoin { - name = "${rxvt_name.name}-with-plugins-${rxvt_name.version}"; - - paths = [ rxvt_unicode ] ++ plugins; - - buildInputs = [ makeWrapper ]; - - postBuild = '' - wrapProgram $out/bin/urxvt \ - --prefix PERL5LIB : "${perlPackages.makePerlPath perlDeps}" \ - --suffix-each URXVT_PERL_LIB ':' "$out/lib/urxvt/perl" - wrapProgram $out/bin/urxvtd \ - --prefix PERL5LIB : "${perlPackages.makePerlPath perlDeps}" \ - --suffix-each URXVT_PERL_LIB ':' "$out/lib/urxvt/perl" - ''; - - passthru.plugins = plugins; -} diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index 2d5bee58b7f..43a0f829416 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -381,7 +381,16 @@ mapAliases ({ ruby_2_4_3 = throw "deprecated 2018-0213: use ruby_2_4 instead"; ruby_2_5_0 = throw "deprecated 2018-0213: use ruby_2_5 instead"; rubygems = throw "deprecated 2016-03-02: rubygems is now bundled with ruby"; - rxvt_unicode_with-plugins = rxvt_unicode-with-plugins; # added 2015-04-02 + rxvt_unicode_with-plugins = rxvt-unicode; # added 2020-02-02 + rxvt_unicode = rxvt-unicode-unwrapped; # added 2020-02-02 + urxvt_autocomplete_all_the_things = rxvt-unicode-plugins.autocomplete-all-the-things; # added 2020-02-02 + urxvt_perl = rxvt-unicode-plugins.perl; # added 2020-02-02 + urxvt_perls = rxvt-unicode-plugins.perls; # added 2020-02-02 + urxvt_tabbedex = rxvt-unicode-plugins.tabbedex; # added 2020-02-02 + urxvt_font_size = rxvt-unicode-plugins.font-size; # added 2020-02-02 + urxvt_theme_switch = rxvt-unicode-plugins.theme-switch; # added 2020-02-02 + urxvt_vtwheel = rxvt-unicode-plugins.vtwheel; # added 2020-02-02 + urxvt_bidi = rxvt-unicode-plugins.bidi; # added 2020-02-02 s6Dns = s6-dns; # added 2018-07-23 s6Networking = s6-networking; # added 2018-07-23 s6LinuxUtils = s6-linux-utils; # added 2018-07-23 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 94be4b1745d..e34dfdfa823 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -21216,35 +21216,11 @@ in rxvt = callPackage ../applications/misc/rxvt { }; - # urxvt - rxvt_unicode = callPackage ../applications/misc/rxvt_unicode { }; + rxvt-unicode = callPackage ../applications/misc/rxvt-unicode/wrapper.nix { }; - rxvt_unicode-with-plugins = callPackage ../applications/misc/rxvt_unicode/wrapper.nix { - plugins = [ - urxvt_autocomplete_all_the_things - urxvt_perl - urxvt_perls - urxvt_tabbedex - urxvt_font_size - urxvt_theme_switch - urxvt_vtwheel - urxvt_bidi - ]; - perlDeps = [ - # This needs the perl module it self provides - urxvt_bidi - ]; - }; + rxvt-unicode-unwrapped = callPackage ../applications/misc/rxvt-unicode { }; - # urxvt plugins - urxvt_autocomplete_all_the_things = callPackage ../applications/misc/rxvt_unicode-plugins/urxvt-autocomplete-all-the-things { }; - urxvt_perl = callPackage ../applications/misc/rxvt_unicode-plugins/urxvt-perl { }; - urxvt_perls = callPackage ../applications/misc/rxvt_unicode-plugins/urxvt-perls { }; - urxvt_tabbedex = callPackage ../applications/misc/rxvt_unicode-plugins/urxvt-tabbedex { }; - urxvt_font_size = callPackage ../applications/misc/rxvt_unicode-plugins/urxvt-font-size { }; - urxvt_theme_switch = callPackage ../applications/misc/rxvt_unicode-plugins/urxvt-theme-switch { }; - urxvt_vtwheel = callPackage ../applications/misc/rxvt_unicode-plugins/urxvt-vtwheel.nix { }; - urxvt_bidi = callPackage ../applications/misc/rxvt_unicode-plugins/urxvt-bidi { }; + rxvt-unicode-plugins = import ../applications/misc/rxvt-unicode-plugins { inherit callPackage; }; uade123 = callPackage ../applications/audio/uade123 {};