re-add sway-im while waiting for it to be released

+18
flake.nix
···
neovim-unwrapped = final.overlay-unstable.neovim-unwrapped;
stig = final.overlay-unstable.stig;
pantalaimon = prev.callPackage ./pkgs/pantalaimon.nix { };
})
];
in {
···
neovim-unwrapped = final.overlay-unstable.neovim-unwrapped;
stig = final.overlay-unstable.stig;
pantalaimon = prev.callPackage ./pkgs/pantalaimon.nix { };
+
sway-unwrapped = prev.callPackage ./pkgs/sway-im/package.nix {
+
libdrm = final.overlay-unstable.libdrm;
+
wlroots = prev.callPackage ./pkgs/wlroots/default.nix {
+
# for libdrm >=2.4.120
+
mesa = final.overlay-unstable.mesa;
+
wayland-protocols = prev.wayland-protocols.overrideAttrs
+
(old: rec {
+
pname = "wayland-protocols";
+
version = "1.33";
+
src = prev.fetchurl {
+
url =
+
"https://gitlab.freedesktop.org/wayland/${pname}/-/releases/${version}/downloads/${pname}-${version}.tar.xz";
+
hash =
+
"sha256-lPDFCwkNbmGgP2IEhGexmrvoUb5OEa57NvZfi5jDljo=";
+
};
+
});
+
};
+
};
})
];
in {
+11
pkgs/sway-im/fix-paths.patch
···
···
+
--- 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;
+48
pkgs/sway-im/load-configuration-from-etc.patch
···
···
+
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
+93
pkgs/sway-im/package.nix
···
···
+
{ lib, stdenv, fetchFromGitHub, fetchpatch, substituteAll, swaybg, meson, ninja
+
, pkg-config, wayland-scanner, scdoc, libGL, wayland, libxkbcommon, pcre2
+
, json_c, libevdev, pango, cairo, libinput, gdk-pixbuf, librsvg, wlroots
+
, wayland-protocols, libdrm, nixosTests
+
# Used by the NixOS module:
+
, isNixOS ? false, enableXWayland ? true, xorg
+
, systemdSupport ? lib.meta.availableOn stdenv.hostPlatform systemd, systemd
+
, trayEnabled ? systemdSupport }:
+
+
stdenv.mkDerivation (finalAttrs: {
+
pname = "sway-unwrapped";
+
version = "im";
+
+
inherit enableXWayland isNixOS systemdSupport trayEnabled;
+
src = fetchFromGitHub {
+
owner = "Decodetalkers";
+
repo = "sway";
+
rev = "2c5bf7c4447df67c32a4ee9c8347ce1848901da2";
+
sha256 = "sha256-UqmdwCTV5LgAQ6z94ZrHBX/QPmBi29fruUzeQk5Vhto=";
+
};
+
+
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 [ xorg.xcbutilwm ];
+
+
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}" ] ++ [ "-Dwerror=false" ]
+
++ lib.optional (!finalAttrs.enableXWayland) "-Dxwayland=disabled"
+
++ lib.optional (!finalAttrs.trayEnabled) "-Dtray=disabled";
+
+
passthru.tests.basic = nixosTests.sway;
+
+
meta = with lib; {
+
description = "An i3-compatible tiling Wayland compositor";
+
longDescription = ''
+
Sway is a tiling Wayland compositor and a drop-in replacement for the i3
+
window manager for X11. It works with your existing i3 configuration and
+
supports most of i3's features, plus a few extras.
+
Sway allows you to arrange your application windows logically, rather
+
than spatially. Windows are arranged into a grid by default which
+
maximizes the efficiency of your screen and can be quickly manipulated
+
using only the keyboard.
+
'';
+
homepage = "https://swaywm.org";
+
changelog = "https://github.com/swaywm/sway/releases/tag/${version}";
+
license = licenses.mit;
+
platforms = platforms.linux;
+
maintainers = with maintainers; [ primeos synthetica ];
+
mainProgram = "sway";
+
};
+
})
+21
pkgs/sway-im/sway-config-nixos-paths.patch
···
···
+
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/*
+21
pkgs/sway-im/sway-config-no-nix-store-references.patch
···
···
+
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/*
+
+83
pkgs/wlroots/default.nix
···
···
+
{ lib, stdenv, fetchFromGitLab, fetchpatch, meson, ninja, pkg-config
+
, wayland-scanner, libGL, wayland, wayland-protocols, libinput, libxkbcommon
+
, pixman, libcap, mesa, xorg, libpng, ffmpeg_4, ffmpeg, hwdata, seatd
+
, vulkan-loader, glslang, libliftoff, libdisplay-info, nixosTests
+
+
, enableXWayland ? true, xwayland ? null }:
+
+
stdenv.mkDerivation (finalAttrs: rec {
+
pname = "wlroots";
+
version = "0.18.0";
+
+
inherit enableXWayland;
+
+
src = fetchFromGitLab {
+
domain = "gitlab.freedesktop.org";
+
owner = "wlroots";
+
repo = "wlroots";
+
rev = "b80337a8f2bb5d032f533ed5e0feb6292670528f";
+
hash = "sha256-EOkgmjRe4v7HtHjJRFplxPZRUzC9N8KgU72BU2JKqKo=";
+
};
+
+
# $out for the library and $examples for the example programs (in examples):
+
outputs = [ "out" "examples" ];
+
+
strictDeps = true;
+
depsBuildBuild = [ pkg-config ];
+
+
nativeBuildInputs = [ meson ninja pkg-config wayland-scanner glslang ];
+
+
buildInputs = [
+
libGL
+
libcap
+
libinput
+
libpng
+
libxkbcommon
+
mesa
+
pixman
+
seatd
+
vulkan-loader
+
wayland
+
wayland-protocols
+
xorg.libX11
+
xorg.xcbutilerrors
+
xorg.xcbutilimage
+
xorg.xcbutilrenderutil
+
xorg.xcbutilwm
+
ffmpeg
+
hwdata
+
libliftoff
+
libdisplay-info
+
] ++ lib.optional finalAttrs.enableXWayland xwayland;
+
+
mesonFlags = lib.optional (!finalAttrs.enableXWayland) "-Dxwayland=disabled";
+
+
postFixup = ''
+
# Install ALL example programs to $examples:
+
# screencopy dmabuf-capture input-inhibitor layer-shell idle-inhibit idle
+
# screenshot output-layout multi-pointer rotation tablet touch pointer
+
# simple
+
mkdir -p $examples/bin
+
cd ./examples
+
for binary in $(find . -executable -type f -printf '%P\n' | grep -vE '\.so'); do
+
cp "$binary" "$examples/bin/wlroots-$binary"
+
done
+
'';
+
+
# Test via TinyWL (the "minimum viable product" Wayland compositor based on wlroots):
+
passthru.tests.tinywl = nixosTests.tinywl;
+
+
meta = {
+
description = "A modular Wayland compositor library";
+
longDescription = ''
+
Pluggable, composable, unopinionated modules for building a Wayland
+
compositor; or about 50,000 lines of code you were going to write anyway.
+
'';
+
inherit (finalAttrs.src.meta) homepage;
+
changelog =
+
"https://gitlab.freedesktop.org/wlroots/wlroots/-/tags/${version}";
+
license = lib.licenses.mit;
+
platforms = lib.platforms.linux;
+
maintainers = with lib.maintainers; [ primeos synthetica rewine ];
+
};
+
})
+43
pkgs/wlroots/protocols.nix
···
···
+
{ lib, stdenv, fetchFromGitLab, wayland-scanner }:
+
+
stdenv.mkDerivation rec {
+
pname = "wlr-protocols";
+
version = "unstable-2022-09-05";
+
+
src = fetchFromGitLab {
+
domain = "gitlab.freedesktop.org";
+
owner = "wlroots";
+
repo = "wlr-protocols";
+
rev = "4264185db3b7e961e7f157e1cc4fd0ab75137568";
+
sha256 = "Ztc07RLg+BZPondP/r6Jo3Fw1QY/z1QsFvdEuOqQshA=";
+
};
+
+
strictDeps = true;
+
nativeBuildInputs = [ wayland-scanner ];
+
+
patchPhase = ''
+
substituteInPlace wlr-protocols.pc.in \
+
--replace '=''${pc_sysrootdir}' "=" \
+
--replace '=@prefix@' "=$out"
+
'';
+
+
doCheck = true;
+
checkTarget = "check";
+
+
installFlags = [ "DESTDIR=$(out)" "PREFIX=" ];
+
+
meta = with lib; {
+
description = "Wayland roots protocol extensions";
+
longDescription = ''
+
wlr-protocols contains Wayland protocols that add functionality not
+
available in the Wayland core protocol, and specific to wlroots-based
+
compositors. Such protocols either add completely new functionality, or
+
extend the functionality of some other protocol either in Wayland core,
+
or some other protocol in wayland-protocols.
+
'';
+
homepage = "https://gitlab.freedesktop.org/wlroots/wlr-protocols";
+
license = licenses.mit; # See file headers
+
platforms = platforms.linux;
+
maintainers = with maintainers; [ twitchyliquid64 ];
+
};
+
}