JonathanReeve/dotfiles

Using strings as .source considered harmful ๐Ÿ™‚

Closed this issue ยท 1 comments

rycee commented

Hi, came here from the reddit thread and noticed you in some cases are using strings as file source. For example

dotfiles/dotfiles/home.nix

Lines 358 to 360 in 77e45eb

"sxhkd/sxhkdrc".source = "${dots}/sxhkdrc";
"polybar/config".source = "${dots}/polybar";
"bspwm/bspwmrc".source = "${dots}/bspwmrc";

This may not be what you want, in most cases you'd want this to be a Nix path literal since only then will the file be copied to the Nix store and immutability maintained. Right now, if you run, for example,

$ readlink ~/.config/sxhkd/sxhkdrc

I suspect you'll find that it is a symbolic link to the file within your Git repo. So editing the file in the repo will change the "live" configuration as well.

If instead you change the code line to read

"sxhkd/sxhkdrc".source = ./sxhkdrc;

and rerun the readlink command it should show a file within the Nix store and this file's content will be immutable.

Thanks for this! I didn't know about that way to specify paths. I just fixed this above.