From 6521bf431833332e68708220562d469792b3d39a Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 8 Oct 2024 00:27:41 -0400 Subject: [PATCH 1/7] niri: format with nixfmt --- pkgs/by-name/ni/niri/package.nix | 45 ++++++++++++++++++-------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/pkgs/by-name/ni/niri/package.nix b/pkgs/by-name/ni/niri/package.nix index 3748f3dbf819..d5bcb5ef987b 100644 --- a/pkgs/by-name/ni/niri/package.nix +++ b/pkgs/by-name/ni/niri/package.nix @@ -1,22 +1,23 @@ -{ lib -, rustPlatform -, fetchFromGitHub -, nix-update-script -, pkg-config -, libdisplay-info -, libxkbcommon -, pango -, pipewire -, seatd -, stdenv -, wayland -, systemd -, libinput -, mesa -, fontconfig -, libglvnd -, autoPatchelfHook -, clang +{ + lib, + rustPlatform, + fetchFromGitHub, + nix-update-script, + pkg-config, + libdisplay-info, + libxkbcommon, + pango, + pipewire, + seatd, + stdenv, + wayland, + systemd, + libinput, + mesa, + fontconfig, + libglvnd, + autoPatchelfHook, + clang, }: rustPlatform.buildRustPackage rec { @@ -86,7 +87,11 @@ rustPlatform.buildRustPackage rec { description = "Scrollable-tiling Wayland compositor"; homepage = "https://github.com/YaLTeR/niri"; license = licenses.gpl3Only; - maintainers = with maintainers; [ iogamaster foo-dogsquared sodiboo ]; + maintainers = with maintainers; [ + iogamaster + foo-dogsquared + sodiboo + ]; mainProgram = "niri"; platforms = platforms.linux; }; From d9aecbc3e0dca3d3ce34161473469d24c56f9660 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 8 Oct 2024 00:32:37 -0400 Subject: [PATCH 2/7] niri: cleanup dependencies Some of these were not required, not explicitly listed, or shouldn't always be added to the rpath --- pkgs/by-name/ni/niri/package.nix | 50 +++++++++++++++----------------- 1 file changed, 24 insertions(+), 26 deletions(-) diff --git a/pkgs/by-name/ni/niri/package.nix b/pkgs/by-name/ni/niri/package.nix index d5bcb5ef987b..ea3c2ed972ba 100644 --- a/pkgs/by-name/ni/niri/package.nix +++ b/pkgs/by-name/ni/niri/package.nix @@ -1,23 +1,22 @@ { lib, - rustPlatform, - fetchFromGitHub, - nix-update-script, - pkg-config, - libdisplay-info, - libxkbcommon, - pango, - pipewire, - seatd, - stdenv, - wayland, - systemd, - libinput, - mesa, - fontconfig, - libglvnd, autoPatchelfHook, clang, + dbus, + fetchFromGitHub, + libdisplay-info, + libglvnd, + libinput, + libxkbcommon, + mesa, + nix-update-script, + pango, + pipewire, + pkg-config, + rustPlatform, + seatd, + systemd, + wayland, }: rustPlatform.buildRustPackage rec { @@ -39,30 +38,29 @@ rustPlatform.buildRustPackage rec { }; }; + strictDeps = true; + nativeBuildInputs = [ - pkg-config - rustPlatform.bindgenHook autoPatchelfHook clang + pkg-config + rustPlatform.bindgenHook ]; buildInputs = [ - wayland - systemd # For libudev - seatd # For libseat + dbus libdisplay-info - libxkbcommon libinput + libxkbcommon mesa # For libgbm - fontconfig - stdenv.cc.cc.lib - pipewire pango + pipewire + seatd + systemd # Also includes libudev ]; runtimeDependencies = [ wayland - mesa libglvnd # For libEGL ]; From f1cf61e2bf1db1ff6a3343717406fecc34089d0e Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 8 Oct 2024 00:34:51 -0400 Subject: [PATCH 3/7] niri: force linking with linker args instead of patchelf We don't need to be patching an already built binary here --- pkgs/by-name/ni/niri/package.nix | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/pkgs/by-name/ni/niri/package.nix b/pkgs/by-name/ni/niri/package.nix index ea3c2ed972ba..2519fe313489 100644 --- a/pkgs/by-name/ni/niri/package.nix +++ b/pkgs/by-name/ni/niri/package.nix @@ -1,6 +1,5 @@ { lib, - autoPatchelfHook, clang, dbus, fetchFromGitHub, @@ -41,7 +40,6 @@ rustPlatform.buildRustPackage rec { strictDeps = true; nativeBuildInputs = [ - autoPatchelfHook clang pkg-config rustPlatform.bindgenHook @@ -50,6 +48,7 @@ rustPlatform.buildRustPackage rec { buildInputs = [ dbus libdisplay-info + libglvnd # For libEGL libinput libxkbcommon mesa # For libgbm @@ -57,11 +56,7 @@ rustPlatform.buildRustPackage rec { pipewire seatd systemd # Also includes libudev - ]; - - runtimeDependencies = [ - wayland - libglvnd # For libEGL + wayland # For libwayland-client ]; passthru.providedSessions = [ "niri" ]; @@ -79,6 +74,19 @@ rustPlatform.buildRustPackage rec { install -Dm0644 resources/niri{-shutdown.target,.service} -t $out/share/systemd/user ''; + env = { + # Force linking with libEGL and libwayland-client + # so they can be discovered by `dlopen()` + RUSTFLAGS = toString ( + map (arg: "-C link-arg=" + arg) [ + "-Wl,--push-state,--no-as-needed" + "-lEGL" + "-lwayland-client" + "-Wl,--pop-state" + ] + ); + }; + passthru.updateScript = nix-update-script { }; meta = with lib; { From f03374e375faaf5fe3511b4ec1283dada1fda6af Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 8 Oct 2024 00:38:20 -0400 Subject: [PATCH 4/7] niri: cleanup This reorders some of the attributes to be a bit more sensible, as well as adopts some "best practices" --- pkgs/by-name/ni/niri/package.nix | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/pkgs/by-name/ni/niri/package.nix b/pkgs/by-name/ni/niri/package.nix index 2519fe313489..2fe758bf2225 100644 --- a/pkgs/by-name/ni/niri/package.nix +++ b/pkgs/by-name/ni/niri/package.nix @@ -25,10 +25,16 @@ rustPlatform.buildRustPackage rec { src = fetchFromGitHub { owner = "YaLTeR"; repo = "niri"; - rev = "v${version}"; + rev = "refs/tags/v${version}"; hash = "sha256-4YDrKMwXGVOBkeaISbxqf24rLuHvO98TnqxWYfgiSeg="; }; + postPatch = '' + patchShebangs resources/niri-session + substituteInPlace resources/niri.service \ + --replace-fail '/usr/bin' "$out/bin" + ''; + cargoLock = { lockFile = ./Cargo.lock; outputHashes = { @@ -59,14 +65,6 @@ rustPlatform.buildRustPackage rec { wayland # For libwayland-client ]; - passthru.providedSessions = [ "niri" ]; - - postPatch = '' - patchShebangs ./resources/niri-session - substituteInPlace ./resources/niri.service \ - --replace-fail '/usr/bin' "$out/bin" - ''; - postInstall = '' install -Dm0755 ./resources/niri-session -t $out/bin install -Dm0644 resources/niri.desktop -t $out/share/wayland-sessions @@ -87,18 +85,21 @@ rustPlatform.buildRustPackage rec { ); }; - passthru.updateScript = nix-update-script { }; + passthru = { + providedSessions = [ "niri" ]; + updateScript = nix-update-script { }; + }; - meta = with lib; { + meta = { description = "Scrollable-tiling Wayland compositor"; homepage = "https://github.com/YaLTeR/niri"; - license = licenses.gpl3Only; - maintainers = with maintainers; [ + license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [ iogamaster foo-dogsquared sodiboo ]; mainProgram = "niri"; - platforms = platforms.linux; + platforms = lib.platforms.linux; }; } From 6a2a50845c5f163f2abcc2fd0e2cae94aeb2f46a Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 8 Oct 2024 00:39:32 -0400 Subject: [PATCH 5/7] niri: add `meta.changelog` --- pkgs/by-name/ni/niri/package.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/by-name/ni/niri/package.nix b/pkgs/by-name/ni/niri/package.nix index 2fe758bf2225..79e80486d4bc 100644 --- a/pkgs/by-name/ni/niri/package.nix +++ b/pkgs/by-name/ni/niri/package.nix @@ -93,6 +93,7 @@ rustPlatform.buildRustPackage rec { meta = { description = "Scrollable-tiling Wayland compositor"; homepage = "https://github.com/YaLTeR/niri"; + changelog = "https://github.com/YaLTeR/niri/releases/tag/v${version}"; license = lib.licenses.gpl3Only; maintainers = with lib.maintainers; [ iogamaster From 0c5d185ad706ca2a6479fe72b3b5d9e3514995dd Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 8 Oct 2024 00:43:01 -0400 Subject: [PATCH 6/7] niri: allow configuration of build features --- pkgs/by-name/ni/niri/package.nix | 57 +++++++++++++++++++++----------- 1 file changed, 38 insertions(+), 19 deletions(-) diff --git a/pkgs/by-name/ni/niri/package.nix b/pkgs/by-name/ni/niri/package.nix index 79e80486d4bc..e0d0a0fa4e62 100644 --- a/pkgs/by-name/ni/niri/package.nix +++ b/pkgs/by-name/ni/niri/package.nix @@ -2,6 +2,7 @@ lib, clang, dbus, + eudev, fetchFromGitHub, libdisplay-info, libglvnd, @@ -16,6 +17,10 @@ seatd, systemd, wayland, + withDbus ? true, + withDinit ? false, + withScreencastSupport ? true, + withSystemd ? true, }: rustPlatform.buildRustPackage rec { @@ -51,26 +56,40 @@ rustPlatform.buildRustPackage rec { rustPlatform.bindgenHook ]; - buildInputs = [ - dbus - libdisplay-info - libglvnd # For libEGL - libinput - libxkbcommon - mesa # For libgbm - pango - pipewire - seatd - systemd # Also includes libudev - wayland # For libwayland-client - ]; + buildInputs = + [ + libdisplay-info + libglvnd # For libEGL + libinput + libxkbcommon + mesa # For libgbm + pango + seatd + wayland # For libwayland-client + ] + ++ lib.optional (withDbus || withScreencastSupport || withSystemd) dbus + ++ lib.optional withScreencastSupport pipewire + ++ lib.optional withSystemd systemd # Includes libudev + ++ lib.optional (!withSystemd) eudev; # Use an alternative libudev implementation when building w/o systemd - postInstall = '' - install -Dm0755 ./resources/niri-session -t $out/bin - install -Dm0644 resources/niri.desktop -t $out/share/wayland-sessions - install -Dm0644 resources/niri-portals.conf -t $out/share/xdg-desktop-portal - install -Dm0644 resources/niri{-shutdown.target,.service} -t $out/share/systemd/user - ''; + buildFeatures = + lib.optional withDbus "dbus" + ++ lib.optional withDinit "dinit" + ++ lib.optional withScreencastSupport "xdp-gnome-screencast" + ++ lib.optional withSystemd "systemd"; + buildNoDefaultFeatures = true; + + postInstall = + '' + install -Dm0644 resources/niri.desktop -t $out/share/wayland-sessions + '' + + lib.optionalString withDbus '' + install -Dm0644 resources/niri-portals.conf -t $out/share/xdg-desktop-portal + '' + + lib.optionalString withSystemd '' + install -Dm0755 resources/niri-session -t $out/bin + install -Dm0644 resources/niri{-shutdown.target,.service} -t $out/share/systemd/user + ''; env = { # Force linking with libEGL and libwayland-client From 9b12b98033391f685d5ff5c225f5d69485154a77 Mon Sep 17 00:00:00 2001 From: seth Date: Tue, 8 Oct 2024 00:53:44 -0400 Subject: [PATCH 7/7] niri: add getchoo as maintainer --- pkgs/by-name/ni/niri/package.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/by-name/ni/niri/package.nix b/pkgs/by-name/ni/niri/package.nix index e0d0a0fa4e62..c41c04dd5dd8 100644 --- a/pkgs/by-name/ni/niri/package.nix +++ b/pkgs/by-name/ni/niri/package.nix @@ -118,6 +118,7 @@ rustPlatform.buildRustPackage rec { iogamaster foo-dogsquared sodiboo + getchoo ]; mainProgram = "niri"; platforms = lib.platforms.linux;