diff --git a/pkgs/by-name/ni/niri/package.nix b/pkgs/by-name/ni/niri/package.nix index 3748f3dbf819c..c41c04dd5dd8e 100644 --- a/pkgs/by-name/ni/niri/package.nix +++ b/pkgs/by-name/ni/niri/package.nix @@ -1,22 +1,26 @@ -{ lib -, rustPlatform -, fetchFromGitHub -, nix-update-script -, pkg-config -, libdisplay-info -, libxkbcommon -, pango -, pipewire -, seatd -, stdenv -, wayland -, systemd -, libinput -, mesa -, fontconfig -, libglvnd -, autoPatchelfHook -, clang +{ + lib, + clang, + dbus, + eudev, + fetchFromGitHub, + libdisplay-info, + libglvnd, + libinput, + libxkbcommon, + mesa, + nix-update-script, + pango, + pipewire, + pkg-config, + rustPlatform, + seatd, + systemd, + wayland, + withDbus ? true, + withDinit ? false, + withScreencastSupport ? true, + withSystemd ? true, }: rustPlatform.buildRustPackage rec { @@ -26,10 +30,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 = { @@ -38,56 +48,79 @@ rustPlatform.buildRustPackage rec { }; }; + strictDeps = true; + nativeBuildInputs = [ + clang pkg-config rustPlatform.bindgenHook - autoPatchelfHook - clang - ]; - - buildInputs = [ - wayland - systemd # For libudev - seatd # For libseat - libdisplay-info - libxkbcommon - libinput - mesa # For libgbm - fontconfig - stdenv.cc.cc.lib - pipewire - pango ]; - runtimeDependencies = [ - wayland - mesa - libglvnd # For libEGL - ]; + 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 - passthru.providedSessions = [ "niri" ]; + buildFeatures = + lib.optional withDbus "dbus" + ++ lib.optional withDinit "dinit" + ++ lib.optional withScreencastSupport "xdp-gnome-screencast" + ++ lib.optional withSystemd "systemd"; + buildNoDefaultFeatures = true; - postPatch = '' - patchShebangs ./resources/niri-session - substituteInPlace ./resources/niri.service \ - --replace-fail '/usr/bin' "$out/bin" - ''; + 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 + ''; - 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 - ''; + 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 { }; + 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; [ iogamaster foo-dogsquared sodiboo ]; + changelog = "https://github.com/YaLTeR/niri/releases/tag/v${version}"; + license = lib.licenses.gpl3Only; + maintainers = with lib.maintainers; [ + iogamaster + foo-dogsquared + sodiboo + getchoo + ]; mainProgram = "niri"; - platforms = platforms.linux; + platforms = lib.platforms.linux; }; }