dotfiles

My PC Dotfiles & Website

modules/apps/notes.nix (2833B)


 1## Obsidian Configuration ##
 2{config, ...}: let
 3  inherit (config.flake) files;
 4in {
 5  flake.modules.homeManager.notes = {
 6    lib,
 7    pkgs,
 8    osConfig ? {},
 9    ...
10  }: let
11    vault = "${files.path.sync}/Notes";
12    target = "Documents/Notes";
13
14    isGnome = osConfig.services.desktopManager.gnome.enable or false;
15    isWM = (osConfig.programs.hyprland.enable or false) || (osConfig.programs.niri.enable or false);
16    theme =
17      if isGnome
18      then pkgs.custom.obsidian-adwaita
19      else if isWM
20      then pkgs.custom.obsidian-catppuccin
21      else null;
22  in {
23    config = {
24      home = {
25        persist.directories = [".config/obsidian"];
26        activation.obsidianVault = lib.hm.dag.entryBetween ["linkGeneration"] ["writeBoundary"] ''
27          run mkdir -p ${vault} "$HOME/$(dirname ${target})"
28          run ln -sfn ${vault} "$HOME/${target}"
29
30          stignore="${files.path.sync}/.stignore"
31          if ! { [ -e "$stignore" ] && ${pkgs.gnugrep}/bin/grep -qxF "/Notes/.obsidian" "$stignore"; }
32          then
33            echo "/Notes/.obsidian" >> "$stignore"
34          fi
35        '';
36      };
37
38      programs.obsidian = {
39        enable = true;
40        vaults.${target} = {};
41        defaultSettings = {
42          appearance.theme = "obsidian";
43          corePlugins = [
44            "file-explorer"
45            "global-search"
46            "switcher"
47            "graph"
48            "backlink"
49            "outgoing-link"
50            "tag-pane"
51            "page-preview"
52            "daily-notes"
53            "templates"
54            "note-composer"
55            "command-palette"
56            "outline"
57            "word-count"
58            "file-recovery"
59            "bookmarks"
60            "properties"
61            "canvas"
62          ];
63
64          communityPlugins = [
65            {
66              pkg = pkgs.custom.obsidian-git;
67              settings = {
68                commitMessage = "feat: Notes {{date}}";
69                autoCommitMessage = "feat: Notes {{date}}";
70                commitDateFormat = "YYYY-MM-DD HH:mm:ss";
71                autoSaveInterval = 0;
72                autoPushInterval = 0;
73                autoPullInterval = 0;
74                disablePush = false;
75                pullBeforePush = true;
76                showStatusBar = true;
77              };
78            }
79            pkgs.custom.obsidian-calendar
80            pkgs.custom.obsidian-outliner
81            {
82              pkg = pkgs.custom.obsidian-style-settings;
83              settings = lib.mkIf isWM {
84                "catppuccin-theme-settings@@catppuccin-theme-dark" = "ctp-macchiato";
85                "catppuccin-theme-settings@@catppuccin-theme-accents" = "ctp-accent-blue";
86              };
87            }
88          ];
89          themes = lib.optional (theme != null) {pkg = theme;};
90        };
91      };
92    };
93  };
94}