nix-community / impermanence

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

Empty list for home.persistence directories does not build #180

Closed matdibu closed 1 month ago

matdibu commented 2 months ago

Passing an empty list to home.persistence.<path>.directories leads to this error:

error: A definition for option
 `home-manager.users.mateidibu.home.persistence."/mnt/persist".directories."[definition 1-entry 1]"'
is not of type `string or (submodule)'. Definition values:
 - In `<nix store path to my config>': [ ]
Misterio77 commented 1 month ago

Can you show what your config looks like? The error message makes me think you might have a [[]] perhaps.

matdibu commented 1 month ago

you're right!

for reference, this was the broken config snippet

home.persistence."${osConfig.modules.impermanence.mountpoint}/home/mateidibu" = {
  directories = [
    (lib.optional osConfig.programs.steam.enable ".local/share/Steam")
  ];
};

(everything under config.modules.* is one of my own modules)

the mistake was that I was using lib.optional, which returns a list

I fixed it now by using

directories = lib.optional osConfig.programs.steam.enable ".local/share/Steam";

or alternatively

directories = lib.optionals osConfig.programs.steam.enable [ ".local/share/Steam" ];
matdibu commented 1 month ago

do you think it would be worth it to add an example of this kind of usage to the README ?