about summary refs log tree commit diff
path: root/pkgs/applications/window-managers
diff options
context:
space:
mode:
authorrewine <lhongxu@outlook.com>2023-07-16 23:04:25 +0800
committerAnderson Torres <torres.anderson.85@protonmail.com>2023-07-27 00:04:03 -0300
commit8974e68bef967c8a8fa11c758e904bc7642aa48a (patch)
tree7a84cd032eac953e4020b7cb5c1963904a9d06d1 /pkgs/applications/window-managers
parent246e73daade1116c052413133bd56b2c89768a9f (diff)
wayfire: refactor
1
Diffstat (limited to 'pkgs/applications/window-managers')
-rw-r--r--pkgs/applications/window-managers/wayfire/applications.nix20
-rw-r--r--pkgs/applications/window-managers/wayfire/plugins.nix20
-rw-r--r--pkgs/applications/window-managers/wayfire/wrapper.nix55
3 files changed, 33 insertions, 62 deletions
diff --git a/pkgs/applications/window-managers/wayfire/applications.nix b/pkgs/applications/window-managers/wayfire/applications.nix
deleted file mode 100644
index a77d3f8bf5d8c..0000000000000
--- a/pkgs/applications/window-managers/wayfire/applications.nix
+++ /dev/null
@@ -1,20 +0,0 @@
-{ lib, newScope, wayfirePlugins }:
-
-lib.makeExtensible (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;
-  };
-})
diff --git a/pkgs/applications/window-managers/wayfire/plugins.nix b/pkgs/applications/window-managers/wayfire/plugins.nix
index f03cf5255c8fd..111a8c87dd787 100644
--- a/pkgs/applications/window-managers/wayfire/plugins.nix
+++ b/pkgs/applications/window-managers/wayfire/plugins.nix
@@ -1,13 +1,11 @@
-{ newScope, wayfire }:
+{ lib, pkgs }:
 
-let
-  self = with self; {
-    inherit wayfire;
-
-    callPackage = newScope self;
-
-    wf-shell = callPackage ./wf-shell.nix { };
+lib.makeScope pkgs.newScope (self:
+  let
+    inherit (self) callPackage;
+  in {
     wayfire-plugins-extra = callPackage ./wayfire-plugins-extra.nix { };
-  };
-in
-self
+    wcm = callPackage ./wcm.nix { };
+    wf-shell = callPackage ./wf-shell.nix { };
+  }
+)
diff --git a/pkgs/applications/window-managers/wayfire/wrapper.nix b/pkgs/applications/window-managers/wayfire/wrapper.nix
index e972929237d46..35bb3ad15837d 100644
--- a/pkgs/applications/window-managers/wayfire/wrapper.nix
+++ b/pkgs/applications/window-managers/wayfire/wrapper.nix
@@ -1,39 +1,32 @@
-{ runCommand, lib, makeWrapper, wayfirePlugins }:
+{ symlinkJoin, lib, makeWrapper, wayfire, plugins ? [ ] }:
 
-let
-  inherit (lib) escapeShellArg makeBinPath;
+symlinkJoin {
+  name = "wayfire-wrapped-${lib.getVersion wayfire}";
 
-  xmlPath = plugin: "${plugin}/share/wayfire/metadata/wf-shell";
-
-  makePluginPath = lib.makeLibraryPath;
-  makePluginXMLPath = lib.concatMapStringsSep ":" xmlPath;
-in
+  nativeBuildInputs = [ makeWrapper ];
 
-application:
+  paths = [
+    wayfire
+  ] ++ plugins;
 
-choosePlugins:
+  postBuild = ''
+    for binary in $out/bin/*; do
+      wrapProgram $binary \
+        --prefix WAYFIRE_PLUGIN_PATH : $out/lib/wayfire \
+        --prefix WAYFIRE_PLUGIN_XML_PATH : $out/share/wayfire/metadata
+    done
+  '';
 
-let
-  plugins = choosePlugins wayfirePlugins;
-in
+  preferLocalBuild = true;
 
-runCommand "${application.name}-wrapped" {
-  nativeBuildInputs = [ makeWrapper ];
-
-  passthru = application.passthru // {
-    unwrapped = application;
+  passthru = wayfire.passthru // {
+    unwrapped = wayfire;
   };
 
-  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 ';'
-''
+  meta = wayfire.meta // {
+    # To prevent builds on hydra
+    hydraPlatforms = [];
+    # prefer wrapper over the package
+    priority = (wayfire.meta.priority or 0) - 1;
+  };
+}