Skip to content

Conversation

mctrxw
Copy link

@mctrxw mctrxw commented Jun 19, 2025

Description

added extraSettings to obsidian module

Example

programs.obsidian.extraSettings = {
  frame = "native";
};

Checklist

  • Change is backwards compatible.

  • Code formatted with nix fmt or
    nix-shell -p treefmt nixfmt-rfc-style keep-sorted --run treefmt.

  • Code tested through nix-shell --pure tests -A run.all
    or nix build --reference-lock-file flake.lock ./tests#test-all using Flakes.

  • Test cases updated/added. See example.

  • Commit messages are formatted like

    {component}: {description}

    {long description}

    See CONTRIBUTING for more information and recent commit messages for examples.

  • If this PR adds a new module

    • Added myself as module maintainer. See example.

Maintainer CC

@rycee @karaolidis

@@ -385,6 +385,12 @@ in
);
default = { };
};

extraSettings = mkOption {
description = "Additional settings to include in obsidian.json.";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"include" would suggest this doesn't override the other options

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, cause it merged via //, or what are u talking about?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

// does override, for example

nix-repl> { vaults = { foo = "x"; }; } // { vaults = { foo = "y"; }; }
{
  vaults = {
    foo = "y";
  };
}

I'm suggesting either changing the description (probably the better option) or using mkMerge in the application. Usually extraSettings are just dumped at the end of the file, but that obviously doesn't work for json.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it overrides if you merging same name attribute, but in obsidian you can't set anything via built-in settings, only nix settings because obsidian.json read only, understood?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think what they're saying is that // is a shallow merge, which means that it'd be impossible to append a deeply-nested key. For example, let's say that you have:

{ a.b.c = 1; }

and you want to add a new attribute: { a.b.x = 2; }. With //, the previous value in a.b.c will not be preserved:

nix-repl> :p { a.b.c = 1; } // { a.b.x = 2; }
{
  a = {
    b = { x = 2; };
  };
}

This is surprising compared to the extra{Settings,Config} options in other modules. By using mkMerge, { a.b.c = 1; } and { a.b.x = 2; } will be merged so that:

{
  a = {
    b = { c = 1; x = 2; };
  };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants