Files
nix-config-v2/home/obsidian.nix

54 lines
1.6 KiB
Nix
Raw Permalink Normal View History

{ config, home-manager-unstable, pkgs, ...}: {
home.packages = with pkgs; [
obsidian
obsidian-export
];
programs.obsidian = {
enable = true;
package =
vaults = {
"notes" = {
enable = true;
target = "${config.home.homeDirectory}/Documents/obsidian/notes";
};
"work-notes" = {
enable = true;
target = "${config.home.homeDirectory}/Documents/obsidian/work-notes";
};
};
# defaultSettings = {
# themes = [ "catppuccin" ];
# };
};
home.activation.obsidianRepos = config.lib.dag.entryAfter ["writeBoundary"] ''
REPOS_DIR="${config.home.homeDirectory}/Documents/obsidian"
# Create the repos directory if it doesn't exist
mkdir -p "$REPOS_DIR"
# Function to clone or update a repository
clone_or_update() {
local repo_url="$1"
local vault_name="$2"
local vault_path="$REPOS_DIR/$vault_name"
if [ -d "$vault_path/.git" ]; then
echo "Updating existing vault: $vault_name"
cd "$vault_path"
${pkgs.git}/bin/git pull origin main || ${pkgs.git}/bin/git pull origin master || true
else
echo "Cloning new vault: $vault_name"
rm -rf "$vault_path" # Remove if exists but not a git repo
${pkgs.git}/bin/git clone "$repo_url" "$vault_path" || true
fi
}
# Clone repositories
clone_or_update "https://scm.wyattjmiller.com/NoteFolio/notes.git" "notes"
clone_or_update "https://scm.wyattjmiller.com/NoteFolio/work-notes.git" "work-notes"
echo "Obsidian repository vaults setup complete in $REPOS_DIR"
'';
}