refactor: centralize workstation HM base and derive terminal from user metadata
This commit is contained in:
@@ -5,26 +5,59 @@
|
||||
}:
|
||||
let
|
||||
homeModules = config.flake.modules.homeManager;
|
||||
baseSettings = import ./_noctalia-config.nix;
|
||||
portableSettings = lib.recursiveUpdate baseSettings {
|
||||
bar.widgets.right = baseSettings.bar.widgets.right ++ [
|
||||
{
|
||||
id = "Battery";
|
||||
}
|
||||
];
|
||||
};
|
||||
mkPortableSettings =
|
||||
baseSettings:
|
||||
lib.recursiveUpdate baseSettings {
|
||||
bar.widgets.right = baseSettings.bar.widgets.right ++ [
|
||||
{
|
||||
id = "Battery";
|
||||
}
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
flake.modules.homeManager.noctalia =
|
||||
{
|
||||
inputs,
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
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;
|
||||
hasMainProgram = terminalPackage != null && terminalPackage ? meta.mainProgram;
|
||||
baseSettings =
|
||||
if hasMainProgram then
|
||||
import ./_noctalia-config.nix {
|
||||
inherit
|
||||
lib
|
||||
terminalPackage
|
||||
;
|
||||
}
|
||||
else
|
||||
{ };
|
||||
in
|
||||
{
|
||||
imports = [ inputs.noctalia.homeModules.default ];
|
||||
|
||||
assertions = [
|
||||
{
|
||||
assertion = terminalPackage != null;
|
||||
message = "Unknown terminal package `${config.meta.user.terminalPackageAttr}` for user `${config.meta.user.name}`.";
|
||||
}
|
||||
{
|
||||
assertion = hasMainProgram;
|
||||
message = "Terminal package `${config.meta.user.terminalPackageAttr}` must define `meta.mainProgram`.";
|
||||
}
|
||||
];
|
||||
|
||||
programs.noctalia-shell = {
|
||||
enable = true;
|
||||
package = lib.mkForce (
|
||||
@@ -37,9 +70,37 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
flake.modules.homeManager.noctalia-portable = {
|
||||
imports = [ homeModules.noctalia ];
|
||||
|
||||
programs.noctalia-shell.settings = lib.mkForce portableSettings;
|
||||
};
|
||||
flake.modules.homeManager.noctalia-portable =
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
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;
|
||||
hasMainProgram = terminalPackage != null && terminalPackage ? meta.mainProgram;
|
||||
baseSettings =
|
||||
if hasMainProgram then
|
||||
import ./_noctalia-config.nix {
|
||||
inherit
|
||||
lib
|
||||
terminalPackage
|
||||
;
|
||||
}
|
||||
else
|
||||
{ };
|
||||
in
|
||||
{
|
||||
imports = [ homeModules.noctalia ];
|
||||
programs.noctalia-shell.settings = lib.mkForce (
|
||||
if hasMainProgram then mkPortableSettings baseSettings else { }
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user