Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion home-manager/services/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ let
gasTown = import ./gas-town { inherit pkgs; };
makeUpdater = import ./make-updater { inherit pkgs; };
neversslKeepalive = import ./neverssl-keepalive { inherit pkgs; };
obsidian = import ./obsidian { inherit pkgs inputs; };
obsidian = import ./obsidian { inherit config pkgs inputs; };
ollama = import ./ollama { inherit pkgs inputs; };
qmd = ./qmd;
openclaw = ./openclaw;
Expand Down
4 changes: 4 additions & 0 deletions home-manager/services/obsidian/default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
config,
pkgs,
inputs,
...
Expand All @@ -12,11 +13,14 @@ let
# full Electron asar, so they need a display server. We wrap the real
# binary in `xvfb-run` so each invocation gets an ephemeral virtual X
# server, letting the CLI run on a headless host.
homeDir = config.home.homeDirectory;

obsidianHeadless = pkgs.writeShellScriptBin "obsidian" (
builtins.readFile (
pkgs.replaceVars ./obsidian-headless.sh {
xvfbRun = pkgs.xvfb-run;
inherit (pkgs) obsidian;
inherit homeDir;
}
)
);
Expand Down
2 changes: 1 addition & 1 deletion home-manager/services/obsidian/obsidian-headless.sh
Original file line number Diff line number Diff line change
@@ -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" "$@"

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.

Loading