nix-community / impermanence

Modules to help you handle persistent state on systems with ephemeral root storage [maintainer=@talyz]
MIT License
1.09k stars 80 forks source link

Doesn't work with spaces #63

Closed a12l closed 2 years ago

a12l commented 2 years ago

I've added .config/Mullvad VPN/gui_settings.json to home.persistence."/persistent/home/a12l".files, I.e., home.persistence."/persistent/home/a12l".files = [ ".config/Mullvad VPN/gui_settings.json" ];. Impermanence creates a broken symlink. It creates an empty directory Mullvad in my persistent storage, and an empty VPN directory in my home directory. The configuration builds without any error messages.

$ ls -l ~/.config/Mullvad\ VPN/gui_settings.json 
lrwxrwxrwx 1 a12l users 100 Dec 29 22:31 '/home/a12l/.config/Mullvad VPN/gui_settings.json' -> '/nix/store/pyzav7b94vniqx2m55360vlpx5jjwnis-home-manager-files/.config/Mullvad VPN/gui_settings.json'

$ ls -l /nix/store/pyzav7b94vniqx2m55360vlpx5jjwnis-home-manager-files/.config/Mullvad\ VPN/gui_settings.json 
lrwxrwxrwx 1 root root 100 Jan  1  1970 '/nix/store/pyzav7b94vniqx2m55360vlpx5jjwnis-home-manager-files/.config/Mullvad VPN/gui_settings.json' -> /nix/store/3c7i5zzzv6pm5ar1l4y31da5ccz31ksh-persistent-home-a12l-config-Mullvad-VPN-gui_settingsjson

$ ls -l /nix/store/3c7i5zzzv6pm5ar1l4y31da5ccz31ksh-persistent-home-a12l-config-Mullvad-VPN-gui_settingsjson 
lrwxrwxrwx 1 root root 59 Jan  1  1970 /nix/store/3c7i5zzzv6pm5ar1l4y31da5ccz31ksh-persistent-home-a12l-config-Mullvad-VPN-gui_settingsjson -> '/persistent/home/a12l/.config/Mullvad VPN/gui_settings.json'

$ ls -l /persistent/home/a12l/.config/
total 99
[...]
drwxr-xr-x  2 a12l users  2 Dec 29 20:46 Mullvad
[...]

$ ls -l /persistent/home/a12l/.config/Mullvad/
total 0

$ ls -l ~/VPN/
total 0

If I add the directory with quotes, I.e., home.persistence."/persistent/home/a12l".files = [ ".config/Mullvad VPN/gui_settings.json" ];, a directory with the correct name is created in /persistent/home/a12l/.config/, but the directory is empty and no symlink is created

$ ls -l /persistent/home/a12l/.config/Mullvad\ VPN/
total 0

$ ls -l ~/.config/Mullvad\ VPN/gui_settings.json 
-rw-r--r-- 1 a12l users 193 Dec 30 14:02 '/home/a12l/.config/Mullvad VPN/gui_settings.json'

I haven't tested having spaces in environment.persistence."/persistent".{directories | files}, or in home.persistence."/persistent/home/a12l".directories.

a12l commented 2 years ago

It seems that it creates a directory in ~/.config with the quotes.

$ ls -l ~/.config/|rg Mullvad
drwxr-xr-x  2 a12l users     3 Dec 30 13:58 "Mullvad VPN"
drwx------ 10 a12l users    16 Dec 30 14:02 Mullvad VPN

$ ls -l ~/.config/\"Mullvad\ VPN\"/
total 1
lrwxrwxrwx 1 a12l users 102 Dec 30 13:58 gui_settings.json -> '/nix/store/5h1dxv8vkhw36ayn5ya81cq547wszym8-home-manager-files/.config/"Mullvad VPN"/gui_settings.json'