Skip to content

Commit d641562

Browse files
committed
feat(wealthfolio): add gocryptfs wrapper with vault mount/unmount
Restructure wealthfolio module to directory with wrapper script that prompts for password via zenity, mounts gocryptfs vault, creates symlinks from XDG paths, and unmounts on exit. Remove impermanence dirs (now handled by nixos-secrets vault persistence). Add desktop entry pointing to the wrapper.
1 parent 1ed4d80 commit d641562

3 files changed

Lines changed: 64 additions & 11 deletions

File tree

flake.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

parts/features/apps/wealthfolio.nix renamed to parts/features/apps/wealthfolio/default.nix

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
{...}: {
22
flake.modules.homeManager.wealthfolio = {
3-
lib,
4-
osConfig,
53
pkgs,
64
...
75
}: let
@@ -42,15 +40,22 @@
4240
| sponge apps/tauri/tauri.conf.json
4341
'';
4442
});
45-
in {
46-
home.persistence."/persist" = lib.mkIf osConfig.dendrix.isImpermanent {
47-
directories = [
48-
".local/share/com.teymz.wealthfolio"
49-
".local/share/Wealthfolio"
50-
".config/com.teymz.wealthfolio"
51-
];
43+
44+
wealthfolio-wrapper = pkgs.writeShellApplication {
45+
name = "wealthfolio-wrapper";
46+
runtimeInputs = [wealthfolio pkgs.gocryptfs pkgs.zenity pkgs.util-linux pkgs.coreutils pkgs.procps];
47+
text = builtins.readFile ./wealthfolio-wrapper.sh;
5248
};
49+
in {
50+
home.packages = [wealthfolio wealthfolio-wrapper];
5351

54-
home.packages = [wealthfolio];
52+
xdg.desktopEntries.Wealthfolio = {
53+
name = "Wealthfolio";
54+
exec = "wealthfolio-wrapper";
55+
terminal = false;
56+
type = "Application";
57+
categories = ["Office" "Finance"];
58+
icon = "com.teymz.wealthfolio";
59+
};
5560
};
5661
}
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
#!/usr/bin/env bash
2+
# Wrapper that mounts a gocryptfs vault before launching Wealthfolio
3+
# and unmounts it on exit. Provides encryption-at-rest for financial data.
4+
#
5+
# Mounts the vault directly at the XDG data path so Wealthfolio
6+
# reads/writes through the FUSE mount transparently.
7+
8+
VAULT_DIR="$HOME/.wealthfolio-vault"
9+
MOUNT_DIR="$HOME/.local/share/com.teymz.wealthfolio"
10+
11+
cleanup() {
12+
if mountpoint -q "$MOUNT_DIR"; then
13+
/run/wrappers/bin/fusermount -u "$MOUNT_DIR"
14+
fi
15+
# Remove plaintext leftovers from the underlying directory
16+
rm -rf "${MOUNT_DIR:?}"/*
17+
}
18+
19+
trap cleanup EXIT INT TERM
20+
21+
if mountpoint -q "$MOUNT_DIR"; then
22+
if pgrep -x Wealthfolio > /dev/null; then
23+
exec Wealthfolio
24+
fi
25+
# Stale mount from a crashed session — clean it up
26+
/run/wrappers/bin/fusermount -u "$MOUNT_DIR"
27+
fi
28+
29+
password=$(zenity --password --title="Wealthfolio Vault") || exit 0
30+
31+
mkdir -p "$VAULT_DIR" "$MOUNT_DIR"
32+
33+
# First-run: initialize the vault
34+
if [ ! -f "$VAULT_DIR/gocryptfs.conf" ]; then
35+
echo "$password" | gocryptfs -init -q "$VAULT_DIR"
36+
fi
37+
38+
echo "$password" | gocryptfs -q -nonempty "$VAULT_DIR" "$MOUNT_DIR"
39+
unset password
40+
41+
Wealthfolio &
42+
WEALTHFOLIO_PID=$!
43+
wait "$WEALTHFOLIO_PID" || true
44+
45+
# Also wait for any forked children
46+
while pgrep -x Wealthfolio > /dev/null; do
47+
sleep 1
48+
done

0 commit comments

Comments
 (0)