Skip to content

Commit

Permalink
niri: refactor & cleanup (#347232)
Browse files Browse the repository at this point in the history
  • Loading branch information
r-vdp authored Oct 12, 2024
2 parents ed65c2d + 9b12b98 commit aff7476
Showing 1 changed file with 91 additions and 58 deletions.
149 changes: 91 additions & 58 deletions pkgs/by-name/ni/niri/package.nix
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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 = {
Expand All @@ -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;
};
}

0 comments on commit aff7476

Please sign in to comment.