about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/xs/xscreensaver/package.nix
blob: 54129c938e5e480373c2ee9adab6f19ef154be8f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
{ lib
, stdenv
, fetchurl
, coreutils
, gdk-pixbuf
, gdk-pixbuf-xlib
, gettext
, gle
, gtk3
, intltool
, libGL
, libGLU
, libX11
, libXext
, libXft
, libXi
, libXinerama
, libXrandr
, libXt
, libXxf86vm
, libxml2
, makeWrapper
, pam
, perlPackages
, xorg
, pkg-config
, systemd
, forceInstallAllHacks ? true
, withSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd
, nixosTests
, substituteAll
, wrapperPrefix ? "/run/wrappers/bin"
}:

stdenv.mkDerivation (finalAttrs: {
  pname = "xscreensaver";
  version = "6.08";

  src = fetchurl {
    url = "https://www.jwz.org/xscreensaver/xscreensaver-${finalAttrs.version}.tar.gz";
    hash = "sha256-XPUrpSXO7PlLLyvWNIXr3zGOEvzA8q2tfUwQbYVedqM=";
  };

  outputs = [ "out" "man" ];

  nativeBuildInputs = [
    intltool
    makeWrapper
    pkg-config
  ];

  buildInputs = [
    gdk-pixbuf
    gdk-pixbuf-xlib
    gettext
    gle
    gtk3
    libGL
    libGLU
    libX11
    libXext
    libXft
    libXi
    libXinerama
    libXrandr
    libXt
    libXxf86vm
    libxml2
    pam
    perlPackages.LWPProtocolHttps
    perlPackages.MozillaCA
    perlPackages.perl
  ]
  ++ lib.optionals withSystemd [ systemd ];

  postPatch = ''
    pushd hacks
    patchShebangs check-configs.pl munge-ad.pl xml2man.pl
    popd
  '';

  patches = [
    (substituteAll {
      src = ./xscreensaver-wrapper-prefix.patch;
      inherit wrapperPrefix;
    })
  ];

  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-app-defaults=${placeholder "out"}/share/xscreensaver/app-defaults"
  ];

  # "marbling" has NEON code that mixes signed and unsigned vector types
  env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.hostPlatform.isAarch "-flax-vector-conversions";

  postInstall = ''
    for bin in $out/bin/*; do
      wrapProgram "$bin" \
        --prefix PATH : "$out/libexec/xscreensaver" \
        --prefix PATH : "${lib.makeBinPath [ coreutils perlPackages.perl xorg.appres ]}" \
        --prefix PERL5LIB ':' $PERL5LIB
    done
  ''
  + lib.optionalString forceInstallAllHacks ''
    make -j$NIX_BUILD_CORES -C hacks/glx dnalogo
    cat hacks/Makefile.in \
      | grep -E '([a-z0-9]+):[[:space:]]*\1[.]o' | cut -d : -f 1 | xargs make -j$NIX_BUILD_CORES -C hacks
    cat hacks/glx/Makefile.in \
      | grep -E '([a-z0-9]+):[[:space:]]*\1[.]o' | cut -d : -f 1 | xargs make -j$NIX_BUILD_CORES -C hacks/glx
    cp -f $(find hacks -type f -perm -111 "!" -name "*.*" ) "$out/libexec/xscreensaver"
  '';

  passthru.tests = {
    xscreensaver = nixosTests.xscreensaver;
  };

  meta = {
    homepage = "https://www.jwz.org/xscreensaver/";
    description = "A set of screensavers";
    downloadPage = "https://www.jwz.org/xscreensaver/download.html";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ raskin AndersonTorres ];
    platforms = lib.platforms.unix;
  };
})