summary refs log tree commit diff
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2020-05-02 18:08:22 +0000
committerAlyssa Ross <hi@alyssa.is>2020-05-07 14:35:15 +0000
commit204bdf5a364068b4be057ada37179fb9f954712c (patch)
treedf4571c8e1b729627669651c12c163050685853c
parent1a728a14d6b13167e670dbbf5d370e09ee41f671 (diff)
downloadnixpkgs-204bdf5a364068b4be057ada37179fb9f954712c.tar
nixpkgs-204bdf5a364068b4be057ada37179fb9f954712c.tar.gz
nixpkgs-204bdf5a364068b4be057ada37179fb9f954712c.tar.bz2
nixpkgs-204bdf5a364068b4be057ada37179fb9f954712c.tar.lz
nixpkgs-204bdf5a364068b4be057ada37179fb9f954712c.tar.xz
nixpkgs-204bdf5a364068b4be057ada37179fb9f954712c.tar.zst
nixpkgs-204bdf5a364068b4be057ada37179fb9f954712c.zip
wayfire: add plugin support
The top-level "wayfire" attribute is a Wayfire with wf-shell installed
and nothing else.  But wayfireApplications.withPlugins can be used to
create a Wayfire with arbitrary plugins, or no plugins at all.
-rw-r--r--pkgs/applications/window-managers/wayfire/applications.nix23
-rw-r--r--pkgs/applications/window-managers/wayfire/default.nix105
-rw-r--r--pkgs/applications/window-managers/wayfire/plugins.nix12
-rw-r--r--pkgs/applications/window-managers/wayfire/wrapper.nix39
-rw-r--r--pkgs/top-level/all-packages.nix11
5 files changed, 136 insertions, 54 deletions
diff --git a/pkgs/applications/window-managers/wayfire/applications.nix b/pkgs/applications/window-managers/wayfire/applications.nix
new file mode 100644
index 00000000000..6c22227c0c5
--- /dev/null
+++ b/pkgs/applications/window-managers/wayfire/applications.nix
@@ -0,0 +1,23 @@
+{ newScope, wayfirePlugins }:
+
+let
+  self = with self; {
+    inherit wayfirePlugins;
+
+    callPackage = newScope self;
+
+    wayfire = callPackage ./. { };
+
+    wcm = callPackage ./wcm.nix {
+      inherit (wayfirePlugins) wf-shell;
+    };
+
+    wrapWayfireApplication = callPackage ./wrapper.nix { };
+
+    withPlugins = selector: self // {
+      wayfire = wrapWayfireApplication wayfire selector;
+      wcm = wrapWayfireApplication wcm selector;
+    };
+  };
+in
+self
diff --git a/pkgs/applications/window-managers/wayfire/default.nix b/pkgs/applications/window-managers/wayfire/default.nix
index 94884cac745..c870d7aed78 100644
--- a/pkgs/applications/window-managers/wayfire/default.nix
+++ b/pkgs/applications/window-managers/wayfire/default.nix
@@ -3,61 +3,64 @@
 , wayland-protocols, wf-config, wlroots
 }:
 
-stdenv.mkDerivation rec {
-  pname = "wayfire";
-  version = "0.4.0";
+let
+  self = stdenv.mkDerivation rec {
+    pname = "wayfire";
+    version = "0.4.0";
 
-  src = fetchFromGitHub {
-    owner = "WayfireWM";
-    repo = "wayfire";
-    rev = version;
-    sha256 = "01rfkb7m1b4d0a9ph9c9jzaa7q6xa91i2ygd3xcnkz35b35qcxn2";
-  };
+    src = fetchFromGitHub {
+      owner = "WayfireWM";
+      repo = "wayfire";
+      rev = version;
+      sha256 = "01rfkb7m1b4d0a9ph9c9jzaa7q6xa91i2ygd3xcnkz35b35qcxn2";
+    };
 
-  patches = [
-    # Fix gles32 support with Nixpkgs' LibGL's glesv2.pc.  Can be
-    # removed if <https://github.com/WayfireWM/wayfire/pull/496> is
-    # applied upstream.
-    (fetchpatch {
-      url = "https://github.com/WayfireWM/wayfire/commit/ca3c74d9f472e929bee45a89e40fe6351e9d0bf5.patch";
-      sha256 = "0jl36z1n0vs4dzsxxp4n1wzlzcasm5hy12dpnr3c9gzwlvns3wk9";
-    })
+    patches = [
+      # Fix gles32 support with Nixpkgs' LibGL's glesv2.pc.  Can be
+      # removed if <https://github.com/WayfireWM/wayfire/pull/496> is
+      # applied upstream.
+      (fetchpatch {
+        url = "https://github.com/WayfireWM/wayfire/commit/ca3c74d9f472e929bee45a89e40fe6351e9d0bf5.patch";
+        sha256 = "0jl36z1n0vs4dzsxxp4n1wzlzcasm5hy12dpnr3c9gzwlvns3wk9";
+      })
 
-    # The following three patches add support for plugins installed
-    # outside of Wayfire's prefix.  Without these, Wayfire plugins
-    # would all have to be built in this derivation.  All three
-    # patches can be removed if
-    # <https://github.com/WayfireWM/wayfire/pull/497> is applied
-    # upstream.
-    (fetchpatch {
-      url = "https://github.com/WayfireWM/wayfire/commit/b9a456c8304546bfb66a9474a47937180b2d2555.patch";
-      sha256 = "1l6vsch5n8h6830bisnzdfjjrvp3q9hqml3hzb5d99lrmc3zcld8";
-    })
-    (fetchpatch {
-      url = "https://github.com/WayfireWM/wayfire/commit/4bc39424688b8919311bc7ceee9eae2374e4d521.patch";
-      excludes = [ "subprojects/wf-config" ];
-      sha256 = "1cqhzbqlwlz0gv5239bx29yfjfmfv0lwyb3qx4wcnwxc3f70vr64";
-    })
-    (fetchpatch {
-      url = "https://github.com/WayfireWM/wayfire/commit/39096c8b544d06addf88234a16a93f9a2aada07c.patch";
-      sha256 = "0in6mcx045grbdxwzgckhyfvffq7xs5k1n3pij6fxh9ckjylpx5k";
-    })
-  ];
+      # The following three patches add support for plugins installed
+      # outside of Wayfire's prefix.  Without these, Wayfire plugins
+      # would all have to be built in this derivation.  All three
+      # patches can be removed if
+      # <https://github.com/WayfireWM/wayfire/pull/497> is applied
+      # upstream.
+      (fetchpatch {
+        url = "https://github.com/WayfireWM/wayfire/commit/b9a456c8304546bfb66a9474a47937180b2d2555.patch";
+        sha256 = "1l6vsch5n8h6830bisnzdfjjrvp3q9hqml3hzb5d99lrmc3zcld8";
+      })
+      (fetchpatch {
+        url = "https://github.com/WayfireWM/wayfire/commit/4bc39424688b8919311bc7ceee9eae2374e4d521.patch";
+        excludes = [ "subprojects/wf-config" ];
+        sha256 = "1cqhzbqlwlz0gv5239bx29yfjfmfv0lwyb3qx4wcnwxc3f70vr64";
+      })
+      (fetchpatch {
+        url = "https://github.com/WayfireWM/wayfire/commit/39096c8b544d06addf88234a16a93f9a2aada07c.patch";
+        sha256 = "0in6mcx045grbdxwzgckhyfvffq7xs5k1n3pij6fxh9ckjylpx5k";
+      })
+    ];
 
-  strictDeps = true;
-  nativeBuildInputs = [ meson ninja pkg-config wayland git ];
-  buildInputs = [
-    cairo libdrm libexecinfo libinput libjpeg libxkbcommon wayland
-    wayland-protocols wf-config wlroots
-  ];
+    strictDeps = true;
+    nativeBuildInputs = [ meson ninja pkg-config wayland git ];
+    buildInputs = [
+      cairo libdrm libexecinfo libinput libjpeg libxkbcommon wayland
+      wayland-protocols wf-config wlroots
+    ];
 
-  mesonFlags = [ "--sysconfdir" "/etc" ];
+    mesonFlags = [ "--sysconfdir" "/etc" ];
 
-  meta = with lib; {
-    homepage = "https://wayfire.org/";
-    description = "3D wayland compositor";
-    license = licenses.mit;
-    maintainers = with maintainers; [ qyliss wucke13 ];
-    platforms = platforms.unix;
+    meta = with lib; {
+      homepage = "https://wayfire.org/";
+      description = "3D wayland compositor";
+      license = licenses.mit;
+      maintainers = with maintainers; [ qyliss wucke13 ];
+      platforms = platforms.unix;
+    };
   };
-}
+in
+self
diff --git a/pkgs/applications/window-managers/wayfire/plugins.nix b/pkgs/applications/window-managers/wayfire/plugins.nix
new file mode 100644
index 00000000000..830a918fcb7
--- /dev/null
+++ b/pkgs/applications/window-managers/wayfire/plugins.nix
@@ -0,0 +1,12 @@
+{ newScope, wayfire }:
+
+let
+  self = with self; {
+    inherit wayfire;
+
+    callPackage = newScope self;
+
+    wf-shell = callPackage ./wf-shell.nix { };
+  };
+in
+self
diff --git a/pkgs/applications/window-managers/wayfire/wrapper.nix b/pkgs/applications/window-managers/wayfire/wrapper.nix
new file mode 100644
index 00000000000..62292898547
--- /dev/null
+++ b/pkgs/applications/window-managers/wayfire/wrapper.nix
@@ -0,0 +1,39 @@
+{ runCommandNoCC, lib, makeWrapper, wayfirePlugins }:
+
+let
+  inherit (lib) escapeShellArg makeBinPath;
+
+  xmlPath = plugin: "${plugin}/share/wayfire/metadata/wf-shell";
+
+  makePluginPath = lib.makeLibraryPath;
+  makePluginXMLPath = lib.concatMapStringsSep ":" xmlPath;
+in
+
+application:
+
+choosePlugins:
+
+let
+  plugins = choosePlugins wayfirePlugins;
+in
+
+runCommandNoCC "${application.name}-wrapped" {
+  nativeBuildInputs = [ makeWrapper ];
+
+  passthru = application.passthru // {
+    unwrapped = application;
+  };
+
+  inherit (application) meta;
+} ''
+  mkdir -p $out/bin
+  for bin in ${application}/bin/*
+  do
+      makeWrapper "$bin" $out/bin/''${bin##*/} \
+          --suffix PATH : ${escapeShellArg (makeBinPath plugins)} \
+          --suffix WAYFIRE_PLUGIN_PATH : ${escapeShellArg (makePluginPath plugins)} \
+          --suffix WAYFIRE_PLUGIN_XML_PATH : ${escapeShellArg (makePluginXMLPath plugins)}
+  done
+  find ${application} -mindepth 1 -maxdepth 1 -not -name bin \
+      -exec ln -s '{}' $out ';'
+''
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index e85ff4458a0..dd07cba7246 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -22457,9 +22457,14 @@ in
     "https://way-cooler.org/blog/2020/01/09/way-cooler-post-mortem.html");
 
   wf-config = callPackage ../applications/window-managers/wayfire/wf-config.nix { };
-  wayfire = callPackage ../applications/window-managers/wayfire { };
-  wf-shell = callPackage ../applications/window-managers/wayfire/wf-shell.nix { };
-  wcm = callPackage ../applications/window-managers/wayfire/wcm.nix { };
+
+  wayfireApplications-unwrapped = callPackage ../applications/window-managers/wayfire/applications.nix { };
+  wayfirePlugins = callPackage ../applications/window-managers/wayfire/plugins.nix {
+    inherit (wayfireApplications-unwrapped) wayfire;
+  };
+
+  wayfireApplications = wayfireApplications-unwrapped.withPlugins (plugins: [ plugins.wf-shell ]);
+  inherit (wayfireApplications) wayfire wcm;
 
   waypipe = callPackage ../applications/networking/remote/waypipe { };