From c5b7187c109dc85dee6a8478bd4ab6c0bcbac726 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sat, 10 Jun 2023 15:17:10 +0200 Subject: [PATCH 1/3] sway-unwrapped: rename wlroots_0_16 argument to wlroots --- pkgs/applications/window-managers/sway/default.nix | 4 ++-- pkgs/top-level/all-packages.nix | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/pkgs/applications/window-managers/sway/default.nix b/pkgs/applications/window-managers/sway/default.nix index d1192e700c50..9991fcc75ff4 100644 --- a/pkgs/applications/window-managers/sway/default.nix +++ b/pkgs/applications/window-managers/sway/default.nix @@ -2,7 +2,7 @@ , meson, ninja, pkg-config, wayland-scanner, scdoc , wayland, libxkbcommon, pcre2, json_c, libevdev , pango, cairo, libinput, gdk-pixbuf, librsvg -, wlroots_0_16, wayland-protocols, libdrm +, wlroots, wayland-protocols, libdrm , nixosTests # Used by the NixOS module: , isNixOS ? false @@ -65,7 +65,7 @@ stdenv.mkDerivation rec { wayland libxkbcommon pcre2 json_c libevdev pango cairo libinput gdk-pixbuf librsvg wayland-protocols libdrm - (wlroots_0_16.override { inherit enableXWayland; }) + (wlroots.override { inherit enableXWayland; }) ] ++ lib.optionals enableXWayland [ xorg.xcbutilwm ]; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index fcfbf2c27ec0..3f7eb76d0a80 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -31634,7 +31634,9 @@ with pkgs; wlroots_0_16 wlroots; - sway-unwrapped = callPackage ../applications/window-managers/sway { }; + sway-unwrapped = callPackage ../applications/window-managers/sway { + wlroots = wlroots_0_16; + }; sway = callPackage ../applications/window-managers/sway/wrapper.nix { }; swaybg = callPackage ../applications/window-managers/sway/bg.nix { }; swayidle = callPackage ../applications/window-managers/sway/idle.nix { }; From c892be9f5808a0ad01284f330affa412390b5608 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sat, 10 Jun 2023 15:41:33 +0200 Subject: [PATCH 2/3] wlroots: pass enableXWayland as derivation attribute makes it easier to change. --- pkgs/development/libraries/wlroots/default.nix | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pkgs/development/libraries/wlroots/default.nix b/pkgs/development/libraries/wlroots/default.nix index 8e0ebab220af..dbb2fa03d4e5 100644 --- a/pkgs/development/libraries/wlroots/default.nix +++ b/pkgs/development/libraries/wlroots/default.nix @@ -28,15 +28,17 @@ let generic = { version, hash, extraBuildInputs ? [ ], extraNativeBuildInputs ? [ ], extraPatch ? "" }: - stdenv.mkDerivation rec { + stdenv.mkDerivation (finalAttrs: { pname = "wlroots"; inherit version; + inherit enableXWayland; + src = fetchFromGitLab { domain = "gitlab.freedesktop.org"; owner = "wlroots"; repo = "wlroots"; - rev = version; + rev = finalAttrs.version; inherit hash; }; @@ -70,11 +72,11 @@ let xorg.xcbutilrenderutil xorg.xcbutilwm ] - ++ lib.optional enableXWayland xwayland + ++ lib.optional finalAttrs.enableXWayland xwayland ++ extraBuildInputs; mesonFlags = - lib.optional (!enableXWayland) "-Dxwayland=disabled" + lib.optional (!finalAttrs.enableXWayland) "-Dxwayland=disabled" ; postFixup = '' @@ -98,13 +100,13 @@ let Pluggable, composable, unopinionated modules for building a Wayland compositor; or about 50,000 lines of code you were going to write anyway. ''; - inherit (src.meta) homepage; + inherit (finalAttrs.src.meta) homepage; changelog = "https://gitlab.freedesktop.org/wlroots/wlroots/-/tags/${version}"; license = licenses.mit; platforms = platforms.linux; maintainers = with maintainers; [ primeos synthetica ]; }; - }; + }); in rec { From 898559e730be1fc6a10d0e720b88a13fa940ea60 Mon Sep 17 00:00:00 2001 From: Matthieu Coudron Date: Sat, 10 Jun 2023 15:58:45 +0200 Subject: [PATCH 3/3] sway: move enableXWayland to derivation attribute it's easier to use overrideAttrs than override IMO, and for the home-manager module I would like to be able to configure sway forks the same way as the original sway which is not possible currently see https://github.com/nix-community/home-manager/pull/4039 --- .../window-managers/sway/default.nix | 36 ++++++++++--------- .../window-managers/sway/wrapper.nix | 2 +- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/pkgs/applications/window-managers/sway/default.nix b/pkgs/applications/window-managers/sway/default.nix index 9991fcc75ff4..f8efab159c28 100644 --- a/pkgs/applications/window-managers/sway/default.nix +++ b/pkgs/applications/window-managers/sway/default.nix @@ -11,21 +11,15 @@ , trayEnabled ? systemdSupport }: -# 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; -let sd-bus-provider = if systemdSupport then "libsystemd" else "basu"; in - -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "sway-unwrapped"; version = "1.8.1"; + inherit enableXWayland isNixOS systemdSupport trayEnabled; src = fetchFromGitHub { owner = "swaywm"; repo = "sway"; - rev = version; + rev = finalAttrs.version; hash = "sha256-WxnT+le9vneQLFPz2KoBduOI+zfZPhn1fKlaqbPL6/g="; }; @@ -42,11 +36,11 @@ stdenv.mkDerivation rec { url = "https://github.com/swaywm/sway/commit/dee032d0a0ecd958c902b88302dc59703d703c7f.diff"; hash = "sha256-dx+7MpEiAkxTBnJcsT3/1BO8rYRfNLecXmpAvhqGMD0="; }) - ] ++ lib.optionals (!isNixOS) [ + ] ++ 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 isNixOS [ + ] ++ lib.optionals finalAttrs.isNixOS [ # Use /run/current-system/sw/share and /etc instead of /nix/store # references: ./sway-config-nixos-paths.patch @@ -65,15 +59,23 @@ stdenv.mkDerivation rec { wayland libxkbcommon pcre2 json_c libevdev pango cairo libinput gdk-pixbuf librsvg wayland-protocols libdrm - (wlroots.override { inherit enableXWayland; }) - ] ++ lib.optionals enableXWayland [ + (wlroots.override { inherit (finalAttrs) enableXWayland; }) + ] ++ lib.optionals finalAttrs.enableXWayland [ xorg.xcbutilwm ]; - mesonFlags = + mesonFlags = let + # 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 [ "-Dsd-bus-provider=${sd-bus-provider}" ] - ++ lib.optional (!enableXWayland) "-Dxwayland=disabled" - ++ lib.optional (!trayEnabled) "-Dtray=disabled" + ++ lib.optional (!finalAttrs.enableXWayland) "-Dxwayland=disabled" + ++ lib.optional (!finalAttrs.trayEnabled) "-Dtray=disabled" ; passthru.tests.basic = nixosTests.sway; @@ -95,4 +97,4 @@ stdenv.mkDerivation rec { platforms = platforms.linux; maintainers = with maintainers; [ primeos synthetica ]; }; -} +}) diff --git a/pkgs/applications/window-managers/sway/wrapper.nix b/pkgs/applications/window-managers/sway/wrapper.nix index 42384fa06ae2..b4e9289f19a5 100644 --- a/pkgs/applications/window-managers/sway/wrapper.nix +++ b/pkgs/applications/window-managers/sway/wrapper.nix @@ -16,7 +16,7 @@ assert extraSessionCommands != "" -> withBaseWrapper; with lib; let - sway = sway-unwrapped.override { inherit isNixOS enableXWayland; }; + sway = sway-unwrapped.overrideAttrs (oa: { inherit isNixOS enableXWayland; }); baseWrapper = writeShellScriptBin "sway" '' set -o errexit if [ ! "$_SWAY_WRAPPER_ALREADY_EXECUTED" ]; then