Obsidian: Difference between revisions

Railwhale (talk | contribs)
m Add links to some terms
Nyxar77 (talk | contribs)
No edit summary
 
(One intermediate revision by the same user not shown)
Line 2: Line 2:
| name = Obsidian
| name = Obsidian
| type = Native
| type = Native
| image = 2023 Obsidian logo.svg
| image = https://obsidian.md/favicon.svg
| website = [https://obsidian.md obsidian.md]
| website = [https://obsidian.md obsidian.md]
| documentation = [https://help.obsidian.md/ Obsidian Help]
| github = obsidianmd
| documentation = [https://help.obsidian.md Obsidian Help]
| initialRelease = 10 March 2020
| initialRelease = 10 March 2020
| latestRelease = 1.8.10; 22 April 2025
| os = Linux, macOS, Windows, iOS, Android
| os = Linux, macOS, Windows, iOS, Android
}}
}}
Line 12: Line 12:
{{Tip/unfree}}
{{Tip/unfree}}


[https://obsidian.md '''Obsidian'''] is a proprietary closed-source note-taking app and text editor, that supports [[Wikipedia:Markdown|Markdown]] and [[Wikipedia:LaTeX|LaTeX]]. It is the more popular equivalent to the open-source [[Logseq]].
[https://obsidian.md '''Obsidian'''] is a proprietary note-taking application and Markdown editor. Notes are stored as regular files inside directories called ''vaults''.


== Installation ==
== Installation ==


Obsidian can be installed from nixpkgs:
=== NixOS ===


<syntaxhighlight lang="nix">
<syntaxhighlight lang="nix">
environment.systemPackages = with pkgs; [
{
   obsidian
  nixpkgs.config.allowUnfree = true;
];
 
  environment.systemPackages = with pkgs; [
    obsidian
  ];
}
</syntaxhighlight>
 
=== Home Manager ===
 
[[Home Manager]] can install Obsidian and manage settings for individual vaults.
 
<syntaxhighlight lang="nix">
{
  programs.obsidian = {
    enable = true;
 
    vaults.notes.target = "Documents/Obsidian";
 
    defaultSettings.app = {
      alwaysUpdateLinks = true;
      spellcheck = true;
    };
  };
}
</syntaxhighlight>
 
The vault path is relative to the user's home directory. The example above manages <code>~/Documents/Obsidian</code>.
 
The <code>notes</code> attribute is only an internal Home Manager name.
 
{{Note|Without a declared vault, Home Manager installs Obsidian but does not manage vault-specific settings, plugins or themes.}}
 
== Core plugins ==
 
Core plugins are included with Obsidian and can be enabled declaratively:
 
<syntaxhighlight lang="nix">
{
  programs.obsidian.defaultSettings.corePlugins = [
    "backlink"
    "bookmarks"
    "daily-notes"
    "file-explorer"
    "global-search"
    "templates"
  ];
}
</syntaxhighlight>
 
{{Warning|This list is exhaustive. Core plugins omitted from it are disabled. Leave the option unset to manage core plugins through Obsidian.}}
 
Plugin-specific settings can also be declared:
 
<syntaxhighlight lang="nix">
{
   programs.obsidian.defaultSettings.corePlugins = [
    {
      name = "daily-notes";
      settings = {
        folder = "Daily";
        format = "YYYY-MM-DD";
      };
    }
    {
      name = "templates";
      settings.folder = "Templates";
    }
  ];
}
</syntaxhighlight>
</syntaxhighlight>
== Community plugins and themes ==
Home Manager supports packaged plugins and themes, but does not provide a package collection for them.
The third-party [https://github.com/karaolidis/nix-obsidian-extensions nix-obsidian-extensions] flake provides packages from the official Obsidian registries.
{{Warning|This flake is not part of Nixpkgs, Home Manager, nix-community or the NixOS project.}}
=== Flake input ===
Add the input to <code>flake.nix</code>:
<syntaxhighlight lang="nix">
{
  inputs = {
    # ...
    obsidian-extensions = {
      url = "github:karaolidis/nix-obsidian-extensions";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };
  # ...
}
</syntaxhighlight>
=== Overlay ===
Apply the overlay to the package set used by Home Manager:
<syntaxhighlight lang="nix">
{
  nixpkgs.overlays = [
    inputs.obsidian-extensions.overlays.default
  ];
}
</syntaxhighlight>
This adds:
* <code>pkgs.obsidianPlugins</code>
* <code>pkgs.obsidianThemes</code>
When Home Manager is used as a NixOS module with <code>home-manager.useGlobalPkgs = true</code>, apply the overlay in the NixOS configuration.
Standalone Home Manager supports the same <code>nixpkgs.overlays</code> option.
=== Installing plugins and themes ===
<syntaxhighlight lang="nix">
{ pkgs, ... }:
{
  programs.obsidian = {
    enable = true;
    vaults.notes.target = "Documents/Obsidian";
    defaultSettings = {
      communityPlugins = with pkgs.obsidianPlugins; [
        dataview
        obsidian-git
        obsidian-importer
        vim-yank-highlight
      ];
      themes = with pkgs.obsidianThemes; [
        catppuccin
      ];
    };
  };
}
</syntaxhighlight>
Plugin attributes use the IDs from the official Obsidian plugin registry. They do not always match the display names shown in Obsidian.
Available extensions can be listed with:
<syntaxhighlight lang="console">
# Plugins
$ nix eval \
    --json \
    github:karaolidis/nix-obsidian-extensions#legacyPackages.x86_64-linux.obsidianPlugins \
    --apply builtins.attrNames
# Themes
$ nix eval \
    --json \
    github:karaolidis/nix-obsidian-extensions#legacyPackages.x86_64-linux.obsidianThemes \
    --apply builtins.attrNames
</syntaxhighlight>
Plugin settings can be written to their <code>data.json</code> files:
<syntaxhighlight lang="nix">
{
  programs.obsidian.defaultSettings.communityPlugins = [
    {
      pkg = pkgs.obsidianPlugins.example-plugin;
      settings = {
        exampleOption = true;
      };
    }
  ];
}
</syntaxhighlight>
== Declarative and manual management ==
Declaratively managed plugins and themes are linked from the immutable Nix store.
Therefore:
* they generally cannot be updated from Obsidian;
* manual changes may be replaced on the next activation;
* removing them from the Nix configuration removes them from the managed vault.
To manage plugins and themes manually, leave their options unset:
<syntaxhighlight lang="nix">
{
  programs.obsidian = {
    enable = true;
    vaults.notes.target = "Documents/Obsidian";
    defaultSettings = {
      communityPlugins = null;
      themes = null;
    };
  };
}
</syntaxhighlight>
Both options are <code>null</code> by default.
== Applying the configuration ==
<syntaxhighlight lang="console">
# NixOS
$ sudo nixos-rebuild switch --flake .
# Standalone Home Manager
$ home-manager switch --flake .
</syntaxhighlight>
== See also ==
* [https://help.obsidian.md Obsidian documentation]
* [https://nix-community.github.io/home-manager/options.xhtml#opt-programs.obsidian.enable Home Manager options]
* [https://github.com/karaolidis/nix-obsidian-extensions nix-obsidian-extensions]
* [[Home Manager]]
* [[Logseq]]


[[Category:Applications]]
[[Category:Applications]]
[[Category:Note taking]]
[[Category:Note taking]]