mirror of
https://github.com/zoriya/noctalia-shell.git
synced 2026-06-04 03:06:57 +00:00
feat(flake): deep merge settings with defaults
This commit is contained in:
@@ -110,6 +110,16 @@
|
|||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
cfg = config.programs.noctalia-shell;
|
cfg = config.programs.noctalia-shell;
|
||||||
|
defaultSettings = builtins.fromJSON (builtins.readFile ./Assets/settings-default.json);
|
||||||
|
|
||||||
|
# Deep merge user settings with defaults
|
||||||
|
mergedSettings =
|
||||||
|
if cfg.settings == null then
|
||||||
|
defaultSettings
|
||||||
|
else if builtins.isAttrs cfg.settings then
|
||||||
|
lib.recursiveUpdate defaultSettings cfg.settings
|
||||||
|
else
|
||||||
|
cfg.settings; # Pass through strings/paths as-is
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.programs.noctalia-shell = {
|
options.programs.noctalia-shell = {
|
||||||
@@ -144,6 +154,8 @@
|
|||||||
description = ''
|
description = ''
|
||||||
Noctalia shell configuration settings as an attribute set, string
|
Noctalia shell configuration settings as an attribute set, string
|
||||||
or filepath, to be written to ~/.config/noctalia/settings.json.
|
or filepath, to be written to ~/.config/noctalia/settings.json.
|
||||||
|
When provided as an attribute set, it will be deep-merged with
|
||||||
|
the default settings.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -189,18 +201,16 @@
|
|||||||
in
|
in
|
||||||
lib.mkIf cfg.enable {
|
lib.mkIf cfg.enable {
|
||||||
xdg.configFile = {
|
xdg.configFile = {
|
||||||
"noctalia/settings.json" = lib.mkIf (cfg.settings != null) (
|
"noctalia/settings.json" = {
|
||||||
{
|
onChange = restart;
|
||||||
onChange = restart;
|
}
|
||||||
}
|
// (
|
||||||
// (
|
if builtins.isAttrs mergedSettings then
|
||||||
if builtins.isAttrs cfg.settings then
|
{ text = builtins.toJSON mergedSettings + "\n"; }
|
||||||
{ text = builtins.toJSON cfg.settings; }
|
else if builtins.isString mergedSettings then
|
||||||
else if builtins.isString cfg.settings then
|
{ text = mergedSettings; }
|
||||||
{ text = cfg.settings; }
|
else
|
||||||
else
|
{ source = mergedSettings; }
|
||||||
{ source = cfg.settings; }
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
"noctalia/colors.json" = lib.mkIf (cfg.colors != null) (
|
"noctalia/colors.json" = lib.mkIf (cfg.colors != null) (
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user