refactor: simplify module composition
This commit is contained in:
@@ -11,38 +11,22 @@ in
|
||||
...
|
||||
}:
|
||||
let
|
||||
terminalPackage = metaLib.resolvePackagePath {
|
||||
terminal = metaLib.resolveUserTerminal {
|
||||
inherit pkgs;
|
||||
path = config.meta.user.terminalPackagePath;
|
||||
user = config.meta.user;
|
||||
};
|
||||
hasTerminalPackage = terminalPackage != null;
|
||||
hasMainProgram = hasTerminalPackage && terminalPackage ? meta.mainProgram;
|
||||
terminalDesktopId = if hasMainProgram then "${terminalPackage.meta.mainProgram}.desktop" else null;
|
||||
in
|
||||
{
|
||||
assertions = [
|
||||
{
|
||||
assertion = hasTerminalPackage;
|
||||
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`.";
|
||||
}
|
||||
{
|
||||
assertion =
|
||||
hasMainProgram && builtins.pathExists "${terminalPackage}/share/applications/${terminalDesktopId}";
|
||||
message = "Terminal package `${lib.showAttrPath config.meta.user.terminalPackagePath}` must provide `${terminalDesktopId}`.";
|
||||
}
|
||||
{
|
||||
assertion = hasMainProgram && terminalPackage.meta.mainProgram == "kitty";
|
||||
message = "The terminal feature currently only supports kitty-specific Home Manager configuration.";
|
||||
}
|
||||
];
|
||||
assertions = metaLib.mkTerminalAssertions {
|
||||
inherit terminal;
|
||||
user = config.meta.user;
|
||||
requireDesktopEntry = true;
|
||||
requireKitty = true;
|
||||
};
|
||||
|
||||
xdg.terminal-exec = {
|
||||
enable = true;
|
||||
settings.default = lib.optional (terminalDesktopId != null) terminalDesktopId;
|
||||
settings.default = lib.optional (terminal.desktopId != null) terminal.desktopId;
|
||||
};
|
||||
|
||||
programs.kitty = {
|
||||
|
||||
Reference in New Issue
Block a user