fix(obsidian): pass --vault flag to open wiki vault on headless launch - #1457
Conversation
|
You do not have enough credits to review this pull request. Please purchase more credits to continue. |
📝 WalkthroughSummary by CodeRabbit
WalkthroughThis PR modifies the Obsidian service module to thread the Nix Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
Mesa DescriptionTL;DRFixed an issue where the Obsidian headless service didn't load the wiki vault and plugins by passing the What changed?
Description generated by Mesa. Update settings |
There was a problem hiding this comment.
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 "$@" | |||
There was a problem hiding this comment.
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.
| 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" "$@" |
There was a problem hiding this comment.
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
📒 Files selected for processing (3)
home-manager/services/default.nixhome-manager/services/obsidian/default.nixhome-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 "$@" | |||
There was a problem hiding this comment.
🧩 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.shRepository: shunkakinoki/dotfiles
Length of output: 243
🏁 Script executed:
cat -n home-manager/services/obsidian/obsidian-headless.shRepository: 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.shRepository: 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.shRepository: 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 -50Repository: shunkakinoki/dotfiles
Length of output: 326
🏁 Script executed:
cat home-manager/services/obsidian/default.nixRepository: 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 -A1Repository: shunkakinoki/dotfiles
Length of output: 326
🏁 Script executed:
# Check if other `@homeDir`@ usages in shell templates are quoted
rg "@homeDir@" --type shRepository: 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 -40Repository: 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 -60Repository: 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 -80Repository: shunkakinoki/dotfiles
Length of output: 4172
🏁 Script executed:
# Look for quoted patterns with @ variables
rg '"@[a-zA-Z]+@|'"'"'@[a-zA-Z]+@' --type shRepository: shunkakinoki/dotfiles
Length of output: 4187
🏁 Script executed:
# Check if there are tests for the obsidian script
cat spec/obsidian_headless_spec.shRepository: 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 -60Repository: 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 -5Repository: 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.shRepository: 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 -40Repository: 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 -10Repository: 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.
| 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.
Summary
--vaultflag to Obsidian headless service so the wiki vault actually opens and plugins (obsidian-git) loadconfig.home.homeDirectoryinstead of hardcoded pathconfigthrough to the obsidian service moduleWithout
--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
--vaultto the headless Obsidian wrapper so the wiki vault opens on launch and plugins likeobsidian-gitrun. Useconfig.home.homeDirectoryand wireconfiginto theobsidianservice to remove the hardcoded path.Written for commit ce2ff77. Summary will update on new commits.