Skip to content

fix(obsidian): pass --vault flag to open wiki vault on headless launch - #1457

Merged
shunkakinoki merged 1 commit into
mainfrom
fix/obsidian-open-vault
Apr 12, 2026
Merged

fix(obsidian): pass --vault flag to open wiki vault on headless launch#1457
shunkakinoki merged 1 commit into
mainfrom
fix/obsidian-open-vault

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented Apr 12, 2026

Copy link
Copy Markdown
Owner

Summary

  • Pass --vault flag to Obsidian headless service so the wiki vault actually opens and plugins (obsidian-git) load
  • Use config.home.homeDirectory instead of hardcoded path
  • Pass config through to the obsidian service module

Without --vault, the headless Obsidian only opened the app shell but never loaded the vault, so obsidian-git auto-commit/push never ran.


Summary by cubic

Pass --vault to the headless Obsidian wrapper so the wiki vault opens on launch and plugins like obsidian-git run. Use config.home.homeDirectory and wire config into the obsidian service to remove the hardcoded path.

Written for commit ce2ff77. Summary will update on new commits.

@mesa-dot-dev

mesa-dot-dev Bot commented Apr 12, 2026

Copy link
Copy Markdown

You do not have enough credits to review this pull request. Please purchase more credits to continue.

@coderabbitai

coderabbitai Bot commented Apr 12, 2026

Copy link
Copy Markdown
📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • Fixed Obsidian service configuration to properly access the user's home directory.
    • Ensured explicit vault path specification when launching Obsidian, preventing reliance on default or fallback configuration.

Walkthrough

This PR modifies the Obsidian service module to thread the Nix config parameter through the service definition and extracts the home directory, which is then passed into the headless wrapper script template via variable substitution. The wrapper script uses this to explicitly specify a vault path when launching Obsidian.

Changes

Cohort / File(s) Summary
Obsidian Service Module Configuration
home-manager/services/default.nix, home-manager/services/obsidian/default.nix
Updated module signature to accept config parameter; extracted config.home.homeDirectory and passed it to the headless script template via pkgs.replaceVars.
Obsidian Headless Wrapper
home-manager/services/obsidian/obsidian-headless.sh
Added explicit --vault @homedir@/ghq/github.com/shunkakinoki/wiki argument to the Obsidian binary invocation, replacing reliance on default vault selection.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

🐰 A hop through config, homeDir found,
Vault paths now clearly bound,
No more guessing where to roam,
Obsidian knows its home! 📚✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: passing the --vault flag to Obsidian's headless launch to open the wiki vault.
Description check ✅ Passed The description is directly related to the changeset, explaining the motivation and what changes were made across the three modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/obsidian-open-vault

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@mesa-dot-dev

mesa-dot-dev Bot commented Apr 12, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Fixed an issue where the Obsidian headless service didn't load the wiki vault and plugins by passing the --vault flag and using a configurable home directory.

What changed?

  • Passed --vault flag to Obsidian headless service to ensure proper vault loading and plugin execution (e.g., obsidian-git).
  • Replaced hardcoded path with config.home.homeDirectory for improved flexibility.
  • Passed config through to the obsidian service module.

Description generated by Mesa. Update settings

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request updates the Obsidian service configuration to include a default vault path in the headless execution script. It passes the user's home directory from the Nix configuration into the shell script template. A review comment suggests quoting the vault path in the shell script to prevent potential word-splitting issues if the home directory path contains spaces.

@@ -1,2 +1,2 @@
#!/usr/bin/env bash
exec @xvfbRun@/bin/xvfb-run -a @obsidian@/bin/obsidian --no-sandbox --disable-gpu "$@"
exec @xvfbRun@/bin/xvfb-run -a @obsidian@/bin/obsidian --no-sandbox --disable-gpu --vault @homeDir@/ghq/github.com/shunkakinoki/wiki "$@"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

The vault path should be enclosed in double quotes to prevent word splitting if the home directory path contains spaces. While standard Linux home paths typically do not contain spaces, quoting is a best practice for shell script robustness and portability.

Suggested change
exec @xvfbRun@/bin/xvfb-run -a @obsidian@/bin/obsidian --no-sandbox --disable-gpu --vault @homeDir@/ghq/github.com/shunkakinoki/wiki "$@"
exec @xvfbRun@/bin/xvfb-run -a @obsidian@/bin/obsidian --no-sandbox --disable-gpu --vault "@homeDir@/ghq/github.com/shunkakinoki/wiki" "$@"

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@home-manager/services/obsidian/obsidian-headless.sh`:
- Line 2: The exec line passes the templated vault path unquoted to --vault
which can cause word-splitting; update the exec command that invokes
`@xvfbRun`@/bin/xvfb-run and `@obsidian`@/bin/obsidian so the --vault argument wraps
the expanded path in quotes (e.g. quote the `@homeDir`@/ghq/... template value)
while preserving the existing quoting of "$@" and other flags to prevent
argument-splitting.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3f27d4bd-3e90-4877-a242-1fff4a94ea8e

📥 Commits

Reviewing files that changed from the base of the PR and between d1124b7 and ce2ff77.

📒 Files selected for processing (3)
  • home-manager/services/default.nix
  • home-manager/services/obsidian/default.nix
  • home-manager/services/obsidian/obsidian-headless.sh

@@ -1,2 +1,2 @@
#!/usr/bin/env bash
exec @xvfbRun@/bin/xvfb-run -a @obsidian@/bin/obsidian --no-sandbox --disable-gpu "$@"
exec @xvfbRun@/bin/xvfb-run -a @obsidian@/bin/obsidian --no-sandbox --disable-gpu --vault @homeDir@/ghq/github.com/shunkakinoki/wiki "$@"

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

# Verify whether --vault currently uses an unquoted `@homeDir`@ expansion.
rg -n -C2 -- '--vault[[:space:]]+@homeDir@/|--vault[[:space:]]+"\@homeDir\@/' home-manager/services/obsidian/obsidian-headless.sh

Repository: shunkakinoki/dotfiles

Length of output: 243


🏁 Script executed:

cat -n home-manager/services/obsidian/obsidian-headless.sh

Repository: shunkakinoki/dotfiles

Length of output: 236


🏁 Script executed:

# Check if this is a Nix file or similar template system
file home-manager/services/obsidian/obsidian-headless.sh
head -20 home-manager/services/obsidian/obsidian-headless.sh

Repository: shunkakinoki/dotfiles

Length of output: 282


🏁 Script executed:

# Search for the vault line more carefully without problematic regex
grep -n "vault" home-manager/services/obsidian/obsidian-headless.sh

Repository: shunkakinoki/dotfiles

Length of output: 204


🏁 Script executed:

# Find related Nix files for obsidian service
fd -e nix home-manager/services/obsidian/

Repository: shunkakinoki/dotfiles

Length of output: 494


🏁 Script executed:

# Look for the Nix file that generates this shell script
rg -l "obsidian-headless" --type nix home-manager/

Repository: shunkakinoki/dotfiles

Length of output: 107


🏁 Script executed:

# Check how `@homeDir`@ is used in similar scripts in the repo
rg "@homeDir@" --type sh -B2 -A2 | head -50

Repository: shunkakinoki/dotfiles

Length of output: 326


🏁 Script executed:

cat home-manager/services/obsidian/default.nix

Repository: shunkakinoki/dotfiles

Length of output: 1344


🏁 Script executed:

# Check other usages of `@homeDir`@ in shell scripts to see if they are quoted
rg "@homeDir@" --type sh -B1 -A1

Repository: shunkakinoki/dotfiles

Length of output: 326


🏁 Script executed:

# Check if other `@homeDir`@ usages in shell templates are quoted
rg "@homeDir@" --type sh

Repository: shunkakinoki/dotfiles

Length of output: 254


🏁 Script executed:

# Check the Nix replaceVars function to understand how it handles escaping
rg "replaceVars" -A5 --type nix | head -40

Repository: shunkakinoki/dotfiles

Length of output: 2569


🏁 Script executed:

# Check if there are other path variables substituted via replaceVars in shell scripts
rg "inherit.*homeDir|inherit.*home" --type nix -B5 -A5 | head -60

Repository: shunkakinoki/dotfiles

Length of output: 2586


🏁 Script executed:

# Check how other `@variable`@ substitutions are handled in templates
rg '@[a-zA-Z]+@' --type sh -B1 -A1 | head -80

Repository: shunkakinoki/dotfiles

Length of output: 4172


🏁 Script executed:

# Look for quoted patterns with @ variables
rg '"@[a-zA-Z]+@|'"'"'@[a-zA-Z]+@' --type sh

Repository: shunkakinoki/dotfiles

Length of output: 4187


🏁 Script executed:

# Check if there are tests for the obsidian script
cat spec/obsidian_headless_spec.sh

Repository: shunkakinoki/dotfiles

Length of output: 1230


🏁 Script executed:

# Look for how home directory paths are typically handled in Nix scripts
rg 'home.homeDirectory|homeDir' --type nix -B2 -A2 | head -60

Repository: shunkakinoki/dotfiles

Length of output: 4673


🏁 Script executed:

# Check what homeDir typically expands to in this config
grep -r "homeDirectory.*=" named-hosts/kyber/default.nix hosts/linux/default.nix | head -5

Repository: shunkakinoki/dotfiles

Length of output: 276


🏁 Script executed:

# Check if the test file includes any test for `@homeDir`@ or vault argument
grep -i "vault\|homeDir" spec/obsidian_headless_spec.sh

Repository: shunkakinoki/dotfiles

Length of output: 47


🏁 Script executed:

# Check if pkgs.replaceVars is documented or if there's guidance on escaping
rg "replaceVars|writeShellScriptBin" --type nix -B3 -A3 | grep -E "replaceVars|writeShellScriptBin|inherit|{$" | head -40

Repository: shunkakinoki/dotfiles

Length of output: 3480


🏁 Script executed:

# Verify the actual username for kyber to understand the expanded path
grep -A5 "username.*=" named-hosts/kyber/default.nix | head -10

Repository: shunkakinoki/dotfiles

Length of output: 47


Quote the vault path argument.

The templated home directory is passed unquoted to --vault, which can cause argument splitting if the expanded path contains spaces or special characters.

Suggested patch
-exec `@xvfbRun`@/bin/xvfb-run -a `@obsidian`@/bin/obsidian --no-sandbox --disable-gpu --vault `@homeDir`@/ghq/github.com/shunkakinoki/wiki "$@"
+vault_path="@homeDir@/ghq/github.com/shunkakinoki/wiki"
+exec `@xvfbRun`@/bin/xvfb-run -a `@obsidian`@/bin/obsidian --no-sandbox --disable-gpu --vault "$vault_path" "$@"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
exec @xvfbRun@/bin/xvfb-run -a @obsidian@/bin/obsidian --no-sandbox --disable-gpu --vault @homeDir@/ghq/github.com/shunkakinoki/wiki "$@"
vault_path="@homeDir@/ghq/github.com/shunkakinoki/wiki"
exec `@xvfbRun`@/bin/xvfb-run -a `@obsidian`@/bin/obsidian --no-sandbox --disable-gpu --vault "$vault_path" "$@"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@home-manager/services/obsidian/obsidian-headless.sh` at line 2, The exec line
passes the templated vault path unquoted to --vault which can cause
word-splitting; update the exec command that invokes `@xvfbRun`@/bin/xvfb-run and
`@obsidian`@/bin/obsidian so the --vault argument wraps the expanded path in
quotes (e.g. quote the `@homeDir`@/ghq/... template value) while preserving the
existing quoting of "$@" and other flags to prevent argument-splitting.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 3 files

@shunkakinoki
shunkakinoki merged commit 2504d73 into main Apr 12, 2026
28 of 29 checks passed
@shunkakinoki
shunkakinoki deleted the fix/obsidian-open-vault branch April 12, 2026 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant