nixpkgs/pkgs/misc/screensavers/xscreensaver/default.nix
rnhmjoj 61b7cab481
treewide: use perl.withPackages when possible
Since 03eaa48 added perl.withPackages, there is a canonical way to
create a perl interpreter from a list of libraries, for use in script
shebangs or generic build inputs. This method is declarative (what we
are doing is clear), produces short shebangs[1] and needs not to wrap
existing scripts.

Unfortunately there are a few exceptions that I've found:

  1. Scripts that are calling perl with the -T switch. This makes perl
  ignore PERL5LIB, which is what perl.withPackages is using to inform
  the interpreter of the library paths.

  2. Perl packages that depends on libraries in their own path. This
  is not possible because perl.withPackages works at build time. The
  workaround is to add `-I $out/${perl.libPrefix}` to the shebang.

In all other cases I propose to switch to perl.withPackages.

[1]: https://lwn.net/Articles/779997/
2021-03-31 21:35:37 +02:00

67 lines
2.4 KiB
Nix

{ lib, stdenv, fetchurl, pkg-config, bc, perl, pam, libXext, libXScrnSaver, libX11
, libXrandr, libXmu, libXxf86vm, libXrender, libXxf86misc, libjpeg, libGLU, libGL, gtk2
, libxml2, libglade, intltool, xorg, makeWrapper, gle, gdk-pixbuf, gdk-pixbuf-xlib
, forceInstallAllHacks ? false
}:
stdenv.mkDerivation rec {
version = "5.44";
pname = "xscreensaver";
src = fetchurl {
url = "https://www.jwz.org/${pname}/${pname}-${version}.tar.gz";
sha256 = "15bv05vpfjwsrqbazrjmm382jd7vvw0mp6y9vasn6wvxzjf0in3k";
};
buildInputs =
[ pkg-config bc perl libjpeg libGLU libGL gtk2 libxml2 libglade pam
libXext libXScrnSaver libX11 libXrandr libXmu libXxf86vm libXrender
libXxf86misc intltool xorg.appres makeWrapper gle gdk-pixbuf
gdk-pixbuf-xlib
];
preConfigure =
''
# Fix installation paths for GTK resources.
sed -e 's%@GTK_DATADIR@%@datadir@% ; s%@PO_DATADIR@%@datadir@%' \
-i driver/Makefile.in po/Makefile.in.in
'';
configureFlags =
[ "--with-gl" "--with-pam" "--with-pixbuf" "--with-proc-interrupts"
"--with-dpms-ext" "--with-randr-ext" "--with-xinerama-ext"
"--with-xf86vmode-ext" "--with-xf86gamma-ext" "--with-randr-ext"
"--with-xshm-ext" "--with-xdbe-ext"
"--with-x-app-defaults=\${out}/share/xscreensaver/app-defaults"
];
postInstall = ''
wrapProgram $out/bin/xscreensaver-text \
--prefix PATH : ${lib.makeBinPath [xorg.appres]}
substituteInPlace $out/bin/xscreensaver-getimage-file \
--replace '${perl}' '${perl.withPackages (p: with p;
[ EncodeLocale HTTPDate HTTPMessage IOSocketSSL
LWP LWPProtocolHttps MozillaCA NetHTTP
NetSSLeay TryTiny URI
])}'
''
+ lib.optionalString forceInstallAllHacks ''
make -C hacks/glx dnalogo
cat hacks/Makefile.in | grep -E '([a-z0-9]+):[[:space:]]*\1[.]o' | cut -d : -f 1 | xargs make -C hacks
cat hacks/glx/Makefile.in | grep -E '([a-z0-9]+):[[:space:]]*\1[.]o' | cut -d : -f 1 | xargs make -C hacks/glx
cp -f $(find hacks -type f -perm -111 "!" -name "*.*" ) "$out/libexec/xscreensaver"
''
;
meta = {
homepage = "https://www.jwz.org/xscreensaver/";
description = "A set of screensavers";
maintainers = with lib.maintainers; [ raskin ];
platforms = lib.platforms.unix; # Once had cygwin problems
inherit version;
downloadPage = "https://www.jwz.org/xscreensaver/download.html";
updateWalker = true;
};
}