Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

niri: refactor & cleanup #347232

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}";
getchoo marked this conversation as resolved.
Show resolved Hide resolved
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 (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

toString of an array? i actually had to test this in nix repl now because that looks like it shouldn't be allowed. and indeed, toString (["a" "b"]) == "a b". that's... very unintuitive? please no

Suggested change
RUSTFLAGS = toString (
RUSTFLAGS = builtins.concatStringsSep " " (

map (arg: "-C link-arg=" + arg) [
"-Wl,--push-state,--no-as-needed"
"-lEGL"
"-lwayland-client"
"-Wl,--pop-state"
]
);
getchoo marked this conversation as resolved.
Show resolved Hide resolved
};

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;
};
}