
Signed-off-by: faukah <fau@faukah.com> Change-Id: I6a6a6964cffaba7ce75488a48739398758d49363
172 lines
3.8 KiB
Nix
172 lines
3.8 KiB
Nix
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
sources,
|
|
...
|
|
}:
|
|
let
|
|
inherit (lib.modules) mkForce mkIf;
|
|
inherit (lib.options) mkEnableOption;
|
|
inherit (config.modules.system) isGraphical;
|
|
inherit (config.meta.mainUser) username;
|
|
|
|
cfg = config.modules.desktops.niri;
|
|
|
|
niri = pkgs.callPackage (
|
|
_:
|
|
pkgs.rustPlatform.buildRustPackage {
|
|
pname = "niri";
|
|
version = "unstable";
|
|
|
|
src = sources.niri;
|
|
postPatch = ''
|
|
patchShebangs resources/niri-session
|
|
substituteInPlace resources/niri.service \
|
|
--replace-fail '/usr/bin' "$out/bin"
|
|
'';
|
|
|
|
cargoLock = {
|
|
allowBuiltinFetchGit = true;
|
|
lockFile = "${sources.niri}/Cargo.lock";
|
|
};
|
|
doCheck = false;
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
rustPlatform.bindgenHook
|
|
pkg-config
|
|
installShellFiles
|
|
];
|
|
|
|
buildInputs = with pkgs; [
|
|
cairo
|
|
dbus
|
|
libGL
|
|
libdisplay-info
|
|
libinput
|
|
seatd
|
|
libxkbcommon
|
|
libgbm
|
|
pango
|
|
wayland
|
|
dbus
|
|
pipewire
|
|
# Also includes libudev
|
|
systemd
|
|
];
|
|
|
|
buildFeatures = [
|
|
"dbus"
|
|
"dinit"
|
|
"xdp-gnome-screencast"
|
|
"systemd"
|
|
];
|
|
buildNoDefaultFeatures = true;
|
|
|
|
postInstall = ''
|
|
installShellCompletion --cmd niri \
|
|
--bash <($out/bin/niri completions bash) \
|
|
--fish <($out/bin/niri completions fish) \
|
|
--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
|
|
install -Dm755 resources/niri-session $out/bin/niri-session
|
|
install -Dm644 resources/niri{.service,-shutdown.target} -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"
|
|
]
|
|
++ [
|
|
"-Ctarget-cpu=native"
|
|
"-Cpanic=abort"
|
|
"-Clto=thin"
|
|
"-Cembed-bitcode=yes"
|
|
]
|
|
);
|
|
};
|
|
|
|
passthru = {
|
|
providedSessions = [ "niri" ];
|
|
};
|
|
|
|
meta.mainProgram = "niri";
|
|
|
|
}
|
|
) { };
|
|
|
|
kdl = pkgs.callPackage ./kdl.nix { };
|
|
|
|
node = name: args: children: {
|
|
inherit name;
|
|
inherit
|
|
(lib.foldl
|
|
(
|
|
self: arg:
|
|
if lib.isAttrs arg then
|
|
self // { properties = self.properties // arg; }
|
|
else
|
|
self // { arguments = self.arguments ++ [ arg ]; }
|
|
)
|
|
{
|
|
arguments = [ ];
|
|
properties = { };
|
|
}
|
|
(lib.toList args)
|
|
)
|
|
arguments
|
|
properties
|
|
;
|
|
inherit children;
|
|
};
|
|
|
|
plain = name: node name [ ];
|
|
leaf = name: args: node name args [ ];
|
|
flag = name: node name [ ] [ ];
|
|
|
|
niri-config = kdl.generate "niri-config.kdl" (
|
|
import ./config.nix {
|
|
inherit
|
|
node
|
|
plain
|
|
leaf
|
|
flag
|
|
lib
|
|
pkgs
|
|
;
|
|
}
|
|
);
|
|
in
|
|
{
|
|
options.modules.desktops.niri.enable = mkEnableOption "Niri, a scolling tiling wayland compositor";
|
|
|
|
config = mkIf (cfg.enable || isGraphical) {
|
|
programs.niri = {
|
|
enable = true;
|
|
package = niri;
|
|
};
|
|
# The niri module auto enables the gnome keyring,
|
|
# which is something I direly want to avoid.
|
|
services.gnome.gnome-keyring.enable = mkForce false;
|
|
|
|
hjem.users.${username}.files.".config/niri/config.kdl".source = niri-config;
|
|
|
|
environment.systemPackages = builtins.attrValues {
|
|
inherit (pkgs)
|
|
xwayland-satellite
|
|
avizo
|
|
playerctl
|
|
wl-clipboard
|
|
fuzzel
|
|
;
|
|
};
|
|
};
|
|
}
|