Skip to content

Commit aff7476

Browse files
authored
niri: refactor & cleanup (#347232)
2 parents ed65c2d + 9b12b98 commit aff7476

File tree

1 file changed

+91
-58
lines changed

1 file changed

+91
-58
lines changed

pkgs/by-name/ni/niri/package.nix

Lines changed: 91 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,26 @@
1-
{ lib
2-
, rustPlatform
3-
, fetchFromGitHub
4-
, nix-update-script
5-
, pkg-config
6-
, libdisplay-info
7-
, libxkbcommon
8-
, pango
9-
, pipewire
10-
, seatd
11-
, stdenv
12-
, wayland
13-
, systemd
14-
, libinput
15-
, mesa
16-
, fontconfig
17-
, libglvnd
18-
, autoPatchelfHook
19-
, clang
1+
{
2+
lib,
3+
clang,
4+
dbus,
5+
eudev,
6+
fetchFromGitHub,
7+
libdisplay-info,
8+
libglvnd,
9+
libinput,
10+
libxkbcommon,
11+
mesa,
12+
nix-update-script,
13+
pango,
14+
pipewire,
15+
pkg-config,
16+
rustPlatform,
17+
seatd,
18+
systemd,
19+
wayland,
20+
withDbus ? true,
21+
withDinit ? false,
22+
withScreencastSupport ? true,
23+
withSystemd ? true,
2024
}:
2125

2226
rustPlatform.buildRustPackage rec {
@@ -26,10 +30,16 @@ rustPlatform.buildRustPackage rec {
2630
src = fetchFromGitHub {
2731
owner = "YaLTeR";
2832
repo = "niri";
29-
rev = "v${version}";
33+
rev = "refs/tags/v${version}";
3034
hash = "sha256-4YDrKMwXGVOBkeaISbxqf24rLuHvO98TnqxWYfgiSeg=";
3135
};
3236

37+
postPatch = ''
38+
patchShebangs resources/niri-session
39+
substituteInPlace resources/niri.service \
40+
--replace-fail '/usr/bin' "$out/bin"
41+
'';
42+
3343
cargoLock = {
3444
lockFile = ./Cargo.lock;
3545
outputHashes = {
@@ -38,56 +48,79 @@ rustPlatform.buildRustPackage rec {
3848
};
3949
};
4050

51+
strictDeps = true;
52+
4153
nativeBuildInputs = [
54+
clang
4255
pkg-config
4356
rustPlatform.bindgenHook
44-
autoPatchelfHook
45-
clang
46-
];
47-
48-
buildInputs = [
49-
wayland
50-
systemd # For libudev
51-
seatd # For libseat
52-
libdisplay-info
53-
libxkbcommon
54-
libinput
55-
mesa # For libgbm
56-
fontconfig
57-
stdenv.cc.cc.lib
58-
pipewire
59-
pango
6057
];
6158

62-
runtimeDependencies = [
63-
wayland
64-
mesa
65-
libglvnd # For libEGL
66-
];
59+
buildInputs =
60+
[
61+
libdisplay-info
62+
libglvnd # For libEGL
63+
libinput
64+
libxkbcommon
65+
mesa # For libgbm
66+
pango
67+
seatd
68+
wayland # For libwayland-client
69+
]
70+
++ lib.optional (withDbus || withScreencastSupport || withSystemd) dbus
71+
++ lib.optional withScreencastSupport pipewire
72+
++ lib.optional withSystemd systemd # Includes libudev
73+
++ lib.optional (!withSystemd) eudev; # Use an alternative libudev implementation when building w/o systemd
6774

68-
passthru.providedSessions = [ "niri" ];
75+
buildFeatures =
76+
lib.optional withDbus "dbus"
77+
++ lib.optional withDinit "dinit"
78+
++ lib.optional withScreencastSupport "xdp-gnome-screencast"
79+
++ lib.optional withSystemd "systemd";
80+
buildNoDefaultFeatures = true;
6981

70-
postPatch = ''
71-
patchShebangs ./resources/niri-session
72-
substituteInPlace ./resources/niri.service \
73-
--replace-fail '/usr/bin' "$out/bin"
74-
'';
82+
postInstall =
83+
''
84+
install -Dm0644 resources/niri.desktop -t $out/share/wayland-sessions
85+
''
86+
+ lib.optionalString withDbus ''
87+
install -Dm0644 resources/niri-portals.conf -t $out/share/xdg-desktop-portal
88+
''
89+
+ lib.optionalString withSystemd ''
90+
install -Dm0755 resources/niri-session -t $out/bin
91+
install -Dm0644 resources/niri{-shutdown.target,.service} -t $out/share/systemd/user
92+
'';
7593

76-
postInstall = ''
77-
install -Dm0755 ./resources/niri-session -t $out/bin
78-
install -Dm0644 resources/niri.desktop -t $out/share/wayland-sessions
79-
install -Dm0644 resources/niri-portals.conf -t $out/share/xdg-desktop-portal
80-
install -Dm0644 resources/niri{-shutdown.target,.service} -t $out/share/systemd/user
81-
'';
94+
env = {
95+
# Force linking with libEGL and libwayland-client
96+
# so they can be discovered by `dlopen()`
97+
RUSTFLAGS = toString (
98+
map (arg: "-C link-arg=" + arg) [
99+
"-Wl,--push-state,--no-as-needed"
100+
"-lEGL"
101+
"-lwayland-client"
102+
"-Wl,--pop-state"
103+
]
104+
);
105+
};
82106

83-
passthru.updateScript = nix-update-script { };
107+
passthru = {
108+
providedSessions = [ "niri" ];
109+
updateScript = nix-update-script { };
110+
};
84111

85-
meta = with lib; {
112+
meta = {
86113
description = "Scrollable-tiling Wayland compositor";
87114
homepage = "https://github.com/YaLTeR/niri";
88-
license = licenses.gpl3Only;
89-
maintainers = with maintainers; [ iogamaster foo-dogsquared sodiboo ];
115+
changelog = "https://github.com/YaLTeR/niri/releases/tag/v${version}";
116+
license = lib.licenses.gpl3Only;
117+
maintainers = with lib.maintainers; [
118+
iogamaster
119+
foo-dogsquared
120+
sodiboo
121+
getchoo
122+
];
90123
mainProgram = "niri";
91-
platforms = platforms.linux;
124+
platforms = lib.platforms.linux;
92125
};
93126
}

0 commit comments

Comments
 (0)