refactor: use terminal package attr paths with shared resolver
This commit is contained in:
@@ -1,4 +1,11 @@
|
||||
{ inputs, ... }:
|
||||
{
|
||||
inputs,
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
metaLib = config.meta.lib;
|
||||
in
|
||||
{
|
||||
flake.modules.nixos.niri =
|
||||
{ pkgs, ... }:
|
||||
@@ -43,13 +50,10 @@
|
||||
inherit (display) mode;
|
||||
}
|
||||
) config.meta.host.displays;
|
||||
rawTerminalAttrPath = lib.splitString "." config.meta.user.terminalPackageAttr;
|
||||
terminalAttrPath =
|
||||
if rawTerminalAttrPath != [ ] && builtins.head rawTerminalAttrPath == "pkgs" then
|
||||
builtins.tail rawTerminalAttrPath
|
||||
else
|
||||
rawTerminalAttrPath;
|
||||
terminalPackage = lib.attrByPath terminalAttrPath null pkgs;
|
||||
terminalPackage = metaLib.resolvePackagePath {
|
||||
inherit pkgs;
|
||||
path = config.meta.user.terminalPackagePath;
|
||||
};
|
||||
hasMainProgram = terminalPackage != null && terminalPackage ? meta.mainProgram;
|
||||
|
||||
mouseSettings = lib.filterAttrs (_: value: value != null) {
|
||||
@@ -77,11 +81,11 @@
|
||||
assertions = [
|
||||
{
|
||||
assertion = terminalPackage != null;
|
||||
message = "Unknown terminal package `${config.meta.user.terminalPackageAttr}` for user `${config.meta.user.name}`.";
|
||||
message = "Unknown terminal package `${lib.showAttrPath config.meta.user.terminalPackagePath}` for user `${config.meta.user.name}`.";
|
||||
}
|
||||
{
|
||||
assertion = hasMainProgram;
|
||||
message = "Terminal package `${config.meta.user.terminalPackageAttr}` must define `meta.mainProgram`.";
|
||||
message = "Terminal package `${lib.showAttrPath config.meta.user.terminalPackagePath}` must define `meta.mainProgram`.";
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user