about summary refs log tree commit diff
path: root/nixpkgs/pkgs/by-name/xs
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/pkgs/by-name/xs')
-rw-r--r--nixpkgs/pkgs/by-name/xs/xscreensaver/package.nix131
-rw-r--r--nixpkgs/pkgs/by-name/xs/xscreensaver/xscreensaver-wrapper-prefix.patch37
-rw-r--r--nixpkgs/pkgs/by-name/xs/xsct/package.nix39
3 files changed, 207 insertions, 0 deletions
diff --git a/nixpkgs/pkgs/by-name/xs/xscreensaver/package.nix b/nixpkgs/pkgs/by-name/xs/xscreensaver/package.nix
new file mode 100644
index 000000000000..54129c938e5e
--- /dev/null
+++ b/nixpkgs/pkgs/by-name/xs/xscreensaver/package.nix
@@ -0,0 +1,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;
+  };
+})
diff --git a/nixpkgs/pkgs/by-name/xs/xscreensaver/xscreensaver-wrapper-prefix.patch b/nixpkgs/pkgs/by-name/xs/xscreensaver/xscreensaver-wrapper-prefix.patch
new file mode 100644
index 000000000000..892924b560b7
--- /dev/null
+++ b/nixpkgs/pkgs/by-name/xs/xscreensaver/xscreensaver-wrapper-prefix.patch
@@ -0,0 +1,37 @@
+--- a/driver/xscreensaver.c
++++ b/driver/xscreensaver.c
+@@ -253,6 +253,8 @@
+ #undef MAX
+ #define MAX(x,y)((x)>(y)?(x):(y))
+ 
++/* Define the default wrapper prefix here, for NixOS */
++#define NIXOS_WRAPPER_PREFIX "@wrapperPrefix@"
+ 
+ /* Globals used in this file.
+  */
+@@ -632,12 +634,24 @@ handle_sigchld (Display *dpy, Bool blanked_p)
+ static void
+ hack_environment (void)
+ {
++  static const char *wrapper_path = NIXOS_WRAPPER_PREFIX;
+   static const char *def_path = DEFAULT_PATH_PREFIX;
+   const char *opath = getenv("PATH");
+   char *npath;
+   if (! opath) opath = "/bin:/usr/bin";  /* WTF */
+-  npath = (char *) malloc(strlen(def_path) + strlen(opath) + 20);
++  /* NOTE: The NixOS patch adds extra margin than what would be expected for a
++     single extra ":" PATH separator to account for UTF-32 encoding. The
++     original 20 bytes would have only accounted for UTF-16 safely (the path
++     concatenation would have needed 28 bytes of margin at minimum for UTF-32).
++   */
++  npath = (char *) malloc(strlen(wrapper_path) + strlen(def_path) + strlen(opath) + 32);
+   strcpy (npath, "PATH=");
++  if (wrapper_path && *wrapper_path)
++    {
++      strcat (npath, wrapper_path);
++      strcat (npath, ":");
++    }
++
+   strcat (npath, def_path);
+   strcat (npath, ":");
+   strcat (npath, opath);
diff --git a/nixpkgs/pkgs/by-name/xs/xsct/package.nix b/nixpkgs/pkgs/by-name/xs/xsct/package.nix
new file mode 100644
index 000000000000..8e384f8ef978
--- /dev/null
+++ b/nixpkgs/pkgs/by-name/xs/xsct/package.nix
@@ -0,0 +1,39 @@
+{ stdenv
+, lib
+, fetchFromGitHub
+, gitUpdater
+, libX11
+, libXrandr
+}:
+
+stdenv.mkDerivation (finalAttrs: {
+  pname = "xsct";
+  version = "2.2";
+
+  src = fetchFromGitHub {
+    owner = "faf0";
+    repo = "sct";
+    rev = finalAttrs.version;
+    hash = "sha256-PDkbZTtl14wYdfALv43SIU9MKhbfiYlRqkI1mFn1qa4=";
+  };
+
+  buildInputs = [
+    libX11
+    libXrandr
+  ];
+
+  makeFlags = [
+    "PREFIX=${placeholder "out"}"
+  ];
+
+  passthru.updateScript = gitUpdater { };
+
+  meta = with lib; {
+    description = "Set color temperature of screen";
+    mainProgram = "xsct";
+    homepage = "https://github.com/faf0/sct";
+    license = licenses.unlicense;
+    maintainers = with maintainers; [ OPNA2608 ];
+    platforms = with platforms; linux ++ freebsd ++ openbsd;
+  };
+})