1
0
Fork 0
nixos-config/home-manager/roles/state.nix
2021-07-05 17:45:47 +02:00

35 lines
1.5 KiB
Nix

{ lib, config, ... }:
let
# Persistent means that files get snapshoted and kept for a month
# Volatile means that files just lay on the disk
# Backups are organized independently on this system
home = config.home.homeDirectory;
persistentStateDirs = [ "git" "media" "Maildir" ".ssh" ".task" ".gnupg" ".calendars" ".contacts" ".wallpapers" ".local/share/direnv" ".vdirsyncer" ];
persistentStateFiles = [ ".chpwd-recent-dirs" ".zsh_history" ];
volatileStateFiles = [ ];
volatileStateDirs = [ ".steam" ".local/share/Steam" ];
mkLine = type: to: from: "${type} ${to} - - - - ${from}";
mkEntry = type: persistence: name:
let
target = "/disk/${persistence}/maralorn/${name}";
in
[ (mkLine "L+" "${home}/${name}" target) (mkLine type target "") ];
in
{
systemd.user.tmpfiles.rules = lib.concatLists
(
map (mkEntry "f" "volatile") volatileStateFiles ++
map (mkEntry "d" "volatile") volatileStateDirs ++
map (mkEntry "f" "persist") persistentStateFiles ++
map (mkEntry "d" "persist") persistentStateDirs
) ++ [
(mkLine "L+" "${home}/.password-store" "git/password-store")
(mkLine "f" "${home}/documents/orga/listen/checklisten/orga-pre.md" "")
(mkLine "f" "${home}/tmp/today.md" "")
(mkLine "L+" "${home}/.volatile" "/disk/volatile/maralorn")
(mkLine "L+" "${home}/.config/nixpkgs/home.nix" "${home}/git/config/home.nix")
(mkLine "L+" "${home}/.persist" "/disk/persist/maralorn")
(mkLine "f" "/disk/volatile/maralorn/mode" "default")
];
}