Something went wrong. Try again.
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247# This flake file is community maintained{ description = "Niri: A scrollable-tiling Wayland compositor.";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs, }: let revision = self.shortRev or self.dirtyShortRev or "unknown"; niri-package = { lib, cairo, dbus, libGL, libdisplay-info_0_3, libinput, seatd, libxkbcommon, libgbm, pango, pipewire, pkg-config, rustPlatform, systemd, wayland, installShellFiles, withDbus ? true, withSystemd ? true, withScreencastSupport ? true, withDinit ? false, }:
rustPlatform.buildRustPackage { pname = "niri"; version = revision;
src = lib.fileset.toSource { root = ./.; fileset = lib.fileset.unions [ ./niri-config ./niri-ipc ./niri-visual-tests ./resources ./src ./Cargo.toml ./Cargo.lock ]; };
postPatch = '' patchShebangs resources/niri-session substituteInPlace resources/niri.service \ --replace-fail 'ExecStart=niri' "ExecStart=$out/bin/niri" '';
cargoLock = { # NOTE: This is only used for Git dependencies allowBuiltinFetchGit = true; lockFile = ./Cargo.lock; };
strictDeps = true;
nativeBuildInputs = [ rustPlatform.bindgenHook pkg-config installShellFiles ];
buildInputs = [ cairo dbus libGL libdisplay-info_0_3 libinput seatd libxkbcommon libgbm pango wayland ] ++ lib.optional (withDbus || withScreencastSupport || withSystemd) dbus ++ lib.optional withScreencastSupport pipewire # Also includes libudev ++ lib.optional withSystemd systemd;
buildFeatures = lib.optional withDbus "dbus" ++ lib.optional withDinit "dinit" ++ lib.optional withScreencastSupport "xdp-gnome-screencast" ++ lib.optional withSystemd "systemd"; buildNoDefaultFeatures = true;
# ever since this commit: # https://github.com/niri-wm/niri/commit/771ea1e81557ffe7af9cbdbec161601575b64d81 # niri now runs an actual instance of the real compositor (with a mock backend) during tests # and thus creates a real socket file in the runtime dir. # this is fine for our build, we just need to make sure it has a directory to write to. preCheck = '' export XDG_RUNTIME_DIR="$(mktemp -d)" '';
checkFlags = [ # These tests require the ability to access a "valid EGL Display", but that won't work # inside the Nix sandbox "--skip=::egl" ];
postInstall = '' installShellCompletion --cmd niri \ --bash <($out/bin/niri completions bash) \ --fish <($out/bin/niri completions fish) \ --nushell <($out/bin/niri completions nushell) \ --zsh <($out/bin/niri completions zsh)
install -Dm644 resources/niri.desktop -t $out/share/wayland-sessions install -Dm644 resources/niri-portals.conf -t $out/share/xdg-desktop-portal '' + lib.optionalString withSystemd '' install -Dm755 resources/niri-session $out/bin/niri-session install -Dm644 resources/niri{.service,-shutdown.target} -t $out/lib/systemd/user '';
env = { # Force linking with libEGL and libwayland-client so they end up in RPATH and # 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" ] ); NIRI_BUILD_COMMIT = revision; };
passthru = { providedSessions = [ "niri" ]; };
meta = { description = "Scrollable-tiling Wayland compositor"; homepage = "https://github.com/niri-wm/niri"; license = lib.licenses.gpl3Only; mainProgram = "niri"; platforms = lib.platforms.linux; }; };
inherit (nixpkgs) lib; # Support all Linux systems that the nixpkgs flake exposes systems = lib.intersectLists lib.systems.flakeExposed lib.platforms.linux;
forAllSystems = lib.genAttrs systems; nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system}); in { checks = forAllSystems (system: { # We use the debug build here to save a bit of time inherit (self.packages.${system}) niri-debug; });
devShells = forAllSystems ( system: let pkgs = nixpkgsFor.${system}; rustfmt' = pkgs.rustfmt.override { asNightly = true; }; inherit (self.packages.${system}) niri; in { default = pkgs.mkShell { packages = builtins.attrValues { inherit (pkgs) rustc cargo clippy cargo-insta ; inherit rustfmt'; };
nativeBuildInputs = [ pkgs.rustPlatform.bindgenHook pkgs.pkg-config pkgs.wrapGAppsHook4 # For `niri-visual-tests` ];
buildInputs = niri.buildInputs ++ [ pkgs.libadwaita # For `niri-visual-tests` ];
env = { # WARN: Do not overwrite this variable in your shell! # It is required for `dlopen()` to work on some libraries; see the comment # in the package expression # # This should only be set with `RUSTFLAGS="$RUSTFLAGS -C your-flags"` RUSTFLAGS = niri.RUSTFLAGS; }; }; } );
formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt-rfc-style);
packages = forAllSystems ( system: let niri = nixpkgsFor.${system}.callPackage niri-package { }; in { inherit niri;
# NOTE: This is for development purposes only # # It is primarily to help with quickly iterating on # changes made to the above expression - though it is # also not stripped in order to better debug niri itself niri-debug = niri.overrideAttrs ( newAttrs: oldAttrs: { pname = oldAttrs.pname + "-debug";
cargoBuildType = "debug"; cargoCheckType = newAttrs.cargoBuildType;
dontStrip = true; } );
default = niri; } );
overlays.default = final: _: { niri = final.callPackage niri-package { }; }; };}