refactor: simplify module composition
This commit is contained in:
@@ -30,8 +30,6 @@ in
|
||||
...
|
||||
}:
|
||||
let
|
||||
hostInput = config.meta.host.input;
|
||||
|
||||
outputs = lib.mapAttrs (
|
||||
_: display:
|
||||
{
|
||||
@@ -50,44 +48,17 @@ in
|
||||
inherit (display) mode;
|
||||
}
|
||||
) config.meta.host.displays;
|
||||
terminalPackage = metaLib.resolvePackagePath {
|
||||
inputProfiles = metaLib.mkInputProfiles config.meta.host.input;
|
||||
terminal = metaLib.resolveUserTerminal {
|
||||
inherit pkgs;
|
||||
path = config.meta.user.terminalPackagePath;
|
||||
};
|
||||
hasMainProgram = terminalPackage != null && terminalPackage ? meta.mainProgram;
|
||||
|
||||
mouseSettings = lib.filterAttrs (_: value: value != null) {
|
||||
accel-profile = hostInput.mouse.accelProfile;
|
||||
accel-speed = hostInput.mouse.accelSpeed;
|
||||
left-handed = hostInput.mouse.leftHanded;
|
||||
middle-emulation = hostInput.mouse.middleEmulation;
|
||||
natural-scroll = hostInput.mouse.naturalScrolling;
|
||||
scroll-method = hostInput.mouse.scrollMethod;
|
||||
};
|
||||
|
||||
touchpadSettings = lib.filterAttrs (_: value: value != null) {
|
||||
accel-profile = hostInput.touchpad.accelProfile;
|
||||
accel-speed = hostInput.touchpad.accelSpeed;
|
||||
click-method = hostInput.touchpad.clickMethod;
|
||||
dwt = hostInput.touchpad.disableWhileTyping;
|
||||
left-handed = hostInput.touchpad.leftHanded;
|
||||
middle-emulation = hostInput.touchpad.middleEmulation;
|
||||
natural-scroll = hostInput.touchpad.naturalScrolling;
|
||||
scroll-method = hostInput.touchpad.scrollMethod;
|
||||
tap = hostInput.touchpad.tapping;
|
||||
user = config.meta.user;
|
||||
};
|
||||
in
|
||||
{
|
||||
assertions = [
|
||||
{
|
||||
assertion = terminalPackage != null;
|
||||
message = "Unknown terminal package `${lib.showAttrPath config.meta.user.terminalPackagePath}` for user `${config.meta.user.name}`.";
|
||||
}
|
||||
{
|
||||
assertion = hasMainProgram;
|
||||
message = "Terminal package `${lib.showAttrPath config.meta.user.terminalPackagePath}` must define `meta.mainProgram`.";
|
||||
}
|
||||
];
|
||||
assertions = metaLib.mkTerminalAssertions {
|
||||
inherit terminal;
|
||||
user = config.meta.user;
|
||||
};
|
||||
|
||||
home.sessionVariables.NIXOS_OZONE_WL = "1";
|
||||
|
||||
@@ -167,20 +138,20 @@ in
|
||||
xkb.options = "caps:escape";
|
||||
};
|
||||
}
|
||||
// lib.optionalAttrs (mouseSettings != { }) {
|
||||
mouse = mouseSettings;
|
||||
// lib.optionalAttrs (inputProfiles.niri.mouse != { }) {
|
||||
mouse = inputProfiles.niri.mouse;
|
||||
}
|
||||
// lib.optionalAttrs (touchpadSettings != { }) {
|
||||
touchpad = touchpadSettings;
|
||||
// lib.optionalAttrs (inputProfiles.niri.touchpad != { }) {
|
||||
touchpad = inputProfiles.niri.touchpad;
|
||||
};
|
||||
|
||||
binds =
|
||||
if hasMainProgram then
|
||||
if terminal.hasMainProgram then
|
||||
import ./_bindings.nix {
|
||||
inherit
|
||||
lib
|
||||
terminalPackage
|
||||
;
|
||||
terminalPackage = terminal.package;
|
||||
}
|
||||
else
|
||||
{ };
|
||||
|
||||
Reference in New Issue
Block a user