nix-community / home-manager

Manage a user environment using Nix [maintainer=@rycee]
https://nix-community.github.io/home-manager/
MIT License
6.28k stars 1.68k forks source link

bug: xdg.{cache,config,data,state}Home must be paths #5464

Open MithicSpirit opened 1 month ago

MithicSpirit commented 1 month ago

Are you following the right branch?

Is there an existing issue for this?

Issue description

The options xdg.cacheHome, xdg.configHome, xdg.dataHome, and xdg.stateHome are all listed as type = types.path in https://github.com/nix-community/home-manager/blob/master/modules/misc/xdg.nix, but actually using paths for them gives the error that it cannot be resolved in pure mode. I believe that they should have type = with types; nullOr (coercedTo path toString str); instead, like in https://github.com/nix-community/home-manager/blob/master/modules/misc/xdg-user-dirs.nix. Notably, the default value for those options is a string I believe, so it would make sense to at least allow that.

Maintainer CC

@rycee @oxalica (no maintainers; git blame)

System information

- system: `"x86_64-linux"`
- host os: `Linux 6.9.1-2-cachyos-lto, Arch Linux, noversion, rolling`
- multi-user?: `no`
- sandbox: `yes`
- version: `nix-env (Nix) 2.22.1`
- nixpkgs: `not found`

(Not yet on a NixOS system. Still building config)
MithicSpirit commented 1 month ago

N.B.: I would be happy to submit a PR with these changes if they are appropriate, but considering that I am new to Nix, I figured I report it as a bug first.

rycee commented 1 month ago

The path type simply asserts that the value should be "string like" and start with the letter "/". I would suspect that the issue is that you have put a path literal in your configuration instead of a string. I.e.,

xdg.configHome = /path/to/dir;

instead of

xdg.configHome = "/path/to/dir";
MithicSpirit commented 1 month ago

Ah, yeah, I was using ~. Still, it's weird that the type of these is different from the type of the ones in xdg.userDirs.