prism-save
prism-save is Prism’s built-in dotfile persistence manager. It bridges the gap between your live home directory and the immutable nature of NixOS. Since Prism configurations are reset on reboot, prism-save allows you to "track" specific local files or folders and back them up into your Prism repository, which will override the standard Prism configuration.
How it works
- Repository Detection: The script automatically looks for your Prism configuration repository at
/etc/prismor~/.config/prism. - Tracking Mechanism: It maintains a hidden list at
~/.prismsave. Any file added here is remembered for future syncs. - Override Mirroring: When a file is "saved," the script calculates its path relative to your
$HOMEand mirrors that exact structure inside the Prism repository underoverrides/[your-username]/. - Idempotency: It ensures that files are safely copied and that empty parent directories are cleaned up when a file is removed from tracking.
Dependencies
coreutils: For path resolution (realpath) and file operations (cp,mkdir).findutils: For directory management.gnugrep: For managing the tracking list.
Usage
| Command | Action |
|---|---|
prism-save <file> | Starts tracking a file/folder and copies it to overrides immediately. |
prism-save | Synchronizes all currently tracked files to the repository. |
prism-save delete <file> | Stops tracking a file and deletes its copy from the repository. |
Example Scenario
If you want to persist your Neovim configuration:
prism-save ~/.config/nvim
This will copy your Neovim folder to /etc/prism/overrides/user/.config/nvim. When you eventually rebuild your system, move to a new machine or just reboot, these overrides can be linked back into place.
The persistence workflow
- Modify: You change a config file in your home directory.
- Save: You run
prism-save. - Persist: The script mirrors the file into the
/etc/prismrepository. - Commit: You can now commit your
/etc/prismchanges to Git, making your custom tweaks permanent and portable.