about summary refs log tree commit diff
path: root/pkgs/by-name/sw
diff options
context:
space:
mode:
authoréclairevoyant <848000+eclairevoyant@users.noreply.github.com>2024-04-29 14:36:54 -0400
committeréclairevoyant <848000+eclairevoyant@users.noreply.github.com>2024-04-29 15:35:15 -0400
commita1d4b812336cb139e3c77854ad778f8e2bdfaae5 (patch)
treeea8d2758b4267fe86148c0c1ce264d365856dc68 /pkgs/by-name/sw
parentf9f60a5c0987ba668afee88dc6e0bdab390390f7 (diff)
swayfx-unwrapped: decouple from sway-unwrapped
Diffstat (limited to 'pkgs/by-name/sw')
-rw-r--r--pkgs/by-name/sw/swayfx-unwrapped/fix-paths.patch11
-rw-r--r--pkgs/by-name/sw/swayfx-unwrapped/load-configuration-from-etc.patch48
-rw-r--r--pkgs/by-name/sw/swayfx-unwrapped/package.nix99
-rw-r--r--pkgs/by-name/sw/swayfx-unwrapped/sway-config-nixos-paths.patch21
-rw-r--r--pkgs/by-name/sw/swayfx-unwrapped/sway-config-no-nix-store-references.patch21
5 files changed, 194 insertions, 6 deletions
diff --git a/pkgs/by-name/sw/swayfx-unwrapped/fix-paths.patch b/pkgs/by-name/sw/swayfx-unwrapped/fix-paths.patch
new file mode 100644
index 0000000000000..c52f65b146b79
--- /dev/null
+++ b/pkgs/by-name/sw/swayfx-unwrapped/fix-paths.patch
@@ -0,0 +1,11 @@
+--- a/sway/config.c
++++ b/sway/config.c
+@@ -276,7 +276,7 @@
+ 
+ 	if (!(config->active_bar_modifiers = create_list())) goto cleanup;
+ 
+-	if (!(config->swaybg_command = strdup("swaybg"))) goto cleanup;
++	if (!(config->swaybg_command = strdup("@swaybg@/bin/swaybg"))) goto cleanup;
+ 
+ 	if (!(config->config_chain = create_list())) goto cleanup;
+ 	config->current_config_path = NULL;
diff --git a/pkgs/by-name/sw/swayfx-unwrapped/load-configuration-from-etc.patch b/pkgs/by-name/sw/swayfx-unwrapped/load-configuration-from-etc.patch
new file mode 100644
index 0000000000000..46a170abc04a7
--- /dev/null
+++ b/pkgs/by-name/sw/swayfx-unwrapped/load-configuration-from-etc.patch
@@ -0,0 +1,48 @@
+From 92283df3acbffa5c1bb21f23cdd686113d905114 Mon Sep 17 00:00:00 2001
+From: Patrick Hilhorst <git@hilhorst.be>
+Date: Wed, 31 Mar 2021 21:14:13 +0200
+Subject: [PATCH] Load configs from /etc but fallback to /nix/store
+
+This change will load all configuration files from /etc, to make it easy
+to override them, but fallback to /nix/store/.../etc/sway/config to make
+Sway work out-of-the-box with the default configuration on non NixOS
+systems.
+
+Original patch by Michael Weiss, updated for Sway 1.6 by Patrick Hilhorst
+
+Co-authored-by: Michael Weiss <dev.primeos@gmail.com>
+---
+ meson.build   | 3 ++-
+ sway/config.c | 3 ++-
+ 2 files changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/meson.build b/meson.build
+index b7a29660..8ae8ceb3 100644
+--- a/meson.build
++++ b/meson.build
+@@ -164,7 +164,8 @@ if scdoc.found()
+ 	endforeach
+ endif
+ 
+-add_project_arguments('-DSYSCONFDIR="/@0@"'.format(join_paths(prefix, sysconfdir)), language : 'c')
++add_project_arguments('-DSYSCONFDIR="/@0@"'.format(sysconfdir), language : 'c')
++add_project_arguments('-DNIX_SYSCONFDIR="/@0@"'.format(join_paths(prefix, sysconfdir)), language : 'c')
+ 
+ version = '"@0@"'.format(meson.project_version())
+ git = find_program('git', native: true, required: false)
+diff --git a/sway/config.c b/sway/config.c
+index 76b9ec08..fb5b51aa 100644
+--- a/sway/config.c
++++ b/sway/config.c
+@@ -374,7 +374,8 @@ static char *get_config_path(void) {
+ 		{ .prefix = home, .config_folder = ".i3"},
+ 		{ .prefix = config_home, .config_folder = "i3"},
+ 		{ .prefix = SYSCONFDIR, .config_folder = "sway"},
+-		{ .prefix = SYSCONFDIR, .config_folder = "i3"}
++		{ .prefix = SYSCONFDIR, .config_folder = "i3"},
++		{ .prefix = NIX_SYSCONFDIR, .config_folder = "sway"},
+ 	};
+ 
+ 	size_t num_config_paths = sizeof(config_paths)/sizeof(config_paths[0]);
+-- 
+2.30.1
diff --git a/pkgs/by-name/sw/swayfx-unwrapped/package.nix b/pkgs/by-name/sw/swayfx-unwrapped/package.nix
index 4605a01b86a70..e704fcd7db35f 100644
--- a/pkgs/by-name/sw/swayfx-unwrapped/package.nix
+++ b/pkgs/by-name/sw/swayfx-unwrapped/package.nix
@@ -1,9 +1,29 @@
 {
   lib,
   fetchFromGitHub,
-  sway-unwrapped,
   stdenv,
   systemd,
+  meson,
+  substituteAll,
+  swaybg,
+  ninja,
+  pkg-config,
+  gdk-pixbuf,
+  librsvg,
+  wayland-protocols,
+  libdrm,
+  libinput,
+  cairo,
+  pango,
+  wayland,
+  libGL,
+  libxkbcommon,
+  pcre2,
+  json_c,
+  libevdev,
+  scdoc,
+  wayland-scanner,
+  xcbutilwm,
   wlroots_0_16,
   # Used by the NixOS module:
   isNixOS ? false,
@@ -12,16 +32,17 @@
   trayEnabled ? systemdSupport,
 }:
 
-(sway-unwrapped.override {
+let
+  wlroots = wlroots_0_16;
+in
+stdenv.mkDerivation (finalAttrs: {
   inherit
-    isNixOS
     enableXWayland
+    isNixOS
     systemdSupport
     trayEnabled
     ;
 
-  wlroots = wlroots_0_16;
-}).overrideAttrs (finalAttrs: prevAttrs: {
   pname = "swayfx-unwrapped";
   version = "0.3.2";
 
@@ -32,10 +53,76 @@
     sha256 = "sha256-Gwewb0yDVhEBrefSSGDf1hLtpWcntzifPCPJQhqLqI0=";
   };
 
+  patches =
+    [
+      ./load-configuration-from-etc.patch
+
+      (substituteAll {
+        src = ./fix-paths.patch;
+        inherit swaybg;
+      })
+    ]
+    ++ lib.optionals (!finalAttrs.isNixOS) [
+      # References to /nix/store/... will get GC'ed which causes problems when
+      # copying the default configuration:
+      ./sway-config-no-nix-store-references.patch
+    ]
+    ++ lib.optionals finalAttrs.isNixOS [
+      # Use /run/current-system/sw/share and /etc instead of /nix/store
+      # references:
+      ./sway-config-nixos-paths.patch
+    ];
+
+  strictDeps = true;
+  depsBuildBuild = [ pkg-config ];
+
+  nativeBuildInputs = [
+    meson
+    ninja
+    pkg-config
+    wayland-scanner
+    scdoc
+  ];
+
+  buildInputs = [
+    libGL
+    wayland
+    libxkbcommon
+    pcre2
+    json_c
+    libevdev
+    pango
+    cairo
+    libinput
+    gdk-pixbuf
+    librsvg
+    wayland-protocols
+    libdrm
+    (wlroots.override { inherit (finalAttrs) enableXWayland; })
+  ] ++ lib.optionals finalAttrs.enableXWayland [ xcbutilwm ];
+
+  mesonFlags =
+    let
+      inherit (lib.strings) mesonEnable mesonOption;
+
+      # The "sd-bus-provider" meson option does not include a "none" option,
+      # but it is silently ignored iff "-Dtray=disabled".  We use "basu"
+      # (which is not in nixpkgs) instead of "none" to alert us if this
+      # changes: https://github.com/swaywm/sway/issues/6843#issuecomment-1047288761
+      # assert trayEnabled -> systemdSupport && dbusSupport;
+
+      sd-bus-provider = if systemdSupport then "libsystemd" else "basu";
+    in
+    [
+      (mesonOption "sd-bus-provider" sd-bus-provider)
+      (mesonEnable "xwayland" finalAttrs.enableXWayland)
+      (mesonEnable "tray" finalAttrs.trayEnabled)
+    ];
+
   meta = {
     description = "Sway, but with eye candy!";
     homepage = "https://github.com/WillPower3309/swayfx";
-    changelog   = "https://github.com/WillPower3309/swayfx/releases/tag/${finalAttrs.version}";
+    changelog = "https://github.com/WillPower3309/swayfx/releases/tag/${finalAttrs.version}";
     license = lib.licenses.mit;
     maintainers = with lib.maintainers; [
       eclairevoyant
diff --git a/pkgs/by-name/sw/swayfx-unwrapped/sway-config-nixos-paths.patch b/pkgs/by-name/sw/swayfx-unwrapped/sway-config-nixos-paths.patch
new file mode 100644
index 0000000000000..bbb0f722b8bc2
--- /dev/null
+++ b/pkgs/by-name/sw/swayfx-unwrapped/sway-config-nixos-paths.patch
@@ -0,0 +1,21 @@
+diff --git a/config.in b/config.in
+index 08703bef..f3872730 100644
+--- a/config.in
++++ b/config.in
+@@ -22,8 +22,8 @@ set $menu dmenu_path | dmenu | xargs swaymsg exec --
+ 
+ ### Output configuration
+ #
+-# Default wallpaper (more resolutions are available in @datadir@/backgrounds/sway/)
+-output * bg @datadir@/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
++# Default wallpaper (more resolutions are available in /run/current-system/sw/share/backgrounds/sway/)
++output * bg /run/current-system/sw/share/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
+ #
+ # Example configuration:
+ #
+@@ -214,4 +214,4 @@ bar {
+     }
+ }
+ 
+-include @sysconfdir@/sway/config.d/*
++include /etc/sway/config.d/*
diff --git a/pkgs/by-name/sw/swayfx-unwrapped/sway-config-no-nix-store-references.patch b/pkgs/by-name/sw/swayfx-unwrapped/sway-config-no-nix-store-references.patch
new file mode 100644
index 0000000000000..009c129594301
--- /dev/null
+++ b/pkgs/by-name/sw/swayfx-unwrapped/sway-config-no-nix-store-references.patch
@@ -0,0 +1,21 @@
+diff --git a/config.in b/config.in
+--- a/config.in
++++ b/config.in
+@@ -21,8 +21,8 @@ set $menu dmenu_path | dmenu | xargs swaymsg exec
+ 
+ ### Output configuration
+ #
+-# Default wallpaper (more resolutions are available in @datadir@/backgrounds/sway/)
+-output * bg @datadir@/backgrounds/sway/Sway_Wallpaper_Blue_1920x1080.png fill
++# Default wallpaper
++#output * bg ~/.config/sway/backgrounds/Sway_Wallpaper_Blue_1920x1080.png fill
+ #
+ # Example configuration:
+ #
+@@ -213,5 +213,3 @@ bar {
+         inactive_workspace #32323200 #32323200 #5c5c5c
+     }
+ }
+-
+-include @sysconfdir@/sway/config.d/*
+