refactor: simplify shared config contracts
This commit is contained in:
@@ -6,6 +6,17 @@
|
||||
let
|
||||
homeModules = config.flake.modules.homeManager;
|
||||
metaLib = config.meta.lib;
|
||||
mkNoctaliaSettings =
|
||||
{
|
||||
lib,
|
||||
terminalPackage,
|
||||
}:
|
||||
import ./_noctalia-config.nix {
|
||||
inherit
|
||||
lib
|
||||
terminalPackage
|
||||
;
|
||||
};
|
||||
mkPortableSettings =
|
||||
baseSettings:
|
||||
lib.recursiveUpdate baseSettings {
|
||||
@@ -29,38 +40,56 @@ let
|
||||
};
|
||||
in
|
||||
{
|
||||
flake.modules.homeManager.noctalia =
|
||||
flake.modules.homeManager.noctalia-base =
|
||||
{
|
||||
inputs,
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
terminal = metaLib.resolveUserTerminal {
|
||||
terminal = metaLib.resolveRepoTerminal {
|
||||
inherit pkgs;
|
||||
user = config.meta.user;
|
||||
};
|
||||
baseSettings =
|
||||
if terminal.hasMainProgram then
|
||||
import ./_noctalia-config.nix {
|
||||
inherit
|
||||
lib
|
||||
;
|
||||
if terminal.hasPackage then
|
||||
mkNoctaliaSettings {
|
||||
inherit lib;
|
||||
terminalPackage = terminal.package;
|
||||
}
|
||||
else
|
||||
{ };
|
||||
in
|
||||
{
|
||||
imports = [ inputs.noctalia.homeModules.default ];
|
||||
|
||||
assertions = metaLib.mkTerminalAssertions {
|
||||
inherit terminal;
|
||||
user = config.meta.user;
|
||||
options.meta.lib.noctaliaBaseSettings = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
internal = true;
|
||||
readOnly = true;
|
||||
};
|
||||
|
||||
config = {
|
||||
meta.lib.noctaliaBaseSettings = baseSettings;
|
||||
|
||||
assertions = metaLib.mkTerminalAssertions {
|
||||
inherit terminal;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
flake.modules.homeManager.noctalia =
|
||||
{
|
||||
config,
|
||||
inputs,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
homeModules.noctalia-base
|
||||
inputs.noctalia.homeModules.default
|
||||
];
|
||||
|
||||
programs.noctalia-shell = {
|
||||
enable = true;
|
||||
package = lib.mkForce (
|
||||
@@ -69,7 +98,7 @@ in
|
||||
}
|
||||
);
|
||||
|
||||
settings = baseSettings;
|
||||
settings = config.meta.lib.noctaliaBaseSettings;
|
||||
};
|
||||
};
|
||||
|
||||
@@ -77,29 +106,15 @@ in
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
terminal = metaLib.resolveUserTerminal {
|
||||
inherit pkgs;
|
||||
user = config.meta.user;
|
||||
};
|
||||
baseSettings =
|
||||
if terminal.hasMainProgram then
|
||||
import ./_noctalia-config.nix {
|
||||
inherit
|
||||
lib
|
||||
;
|
||||
terminalPackage = terminal.package;
|
||||
}
|
||||
else
|
||||
{ };
|
||||
in
|
||||
{
|
||||
imports = [ homeModules.noctalia ];
|
||||
programs.noctalia-shell.settings = lib.mkForce (
|
||||
if terminal.hasMainProgram then mkPortableSettings baseSettings else { }
|
||||
if config.meta.lib.noctaliaBaseSettings == { } then
|
||||
{ }
|
||||
else
|
||||
mkPortableSettings config.meta.lib.noctaliaBaseSettings
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user