Nix: Does nix has a plan to comply with XDG Base Directory Spec?

Created on 2 Oct 2016  路  14Comments  路  Source: NixOS/nix

Written here, @svanderburg said that Nix try to comply as close as possible with standard (well, with FHS). Whilst, it is failed to fully comply with FHS, why we don't try to comply with _XDG Base Directory Spec_, which more make sense to users?

Nix programs create three directories at my $HOME. Honestly, it looks very bad for me (by far no complaints on the Internet sadly).

I wanted to create a patch for this if granted.

Best,
Abdillah

Most helpful comment

@edolstra well we could do what git does to maintain backwards compatibility. Use $XDG_CONFIG_HOME if it exists but if not, use ~/.nix-whatever. And when creating new files, always use $XDG_CONFIG_HOME.

All 14 comments

I assume you're referring to ~/.nix-defexpr, ~/.nix-channels etc. Those are very old and they may even predate the XDG. We can't change them since that would break compatibility with existing installations. However, most of these files will become obsolete with the new Nix command line interface.

New files do respect the XDG. For example, Nix stores various cache files in ~/.cache/nix.

However, most of these files will become obsolete with the new Nix command line interface.

Hmm.. I just install nix & nixos a week ago, so it should be "new" right :smile:
And what do you mean obsolete? Honestly, I haven't seen any sign of it. Can you point me some?

I found three files, and yes, those are,
.nix-defexpr -> /nix/store/some-nixpkgs still used by nix-env
.nix-profile -> /nix/var/nix/profiles/.../default not sure who use this, myself?
.nix-channels file used by nix-channel
I thought in early nix, are there more so you said "most of these files"?

Then, how can I help on this? I love nix and my clean ~ :smile_cat:

@edolstra used past tense when he said "However, most of these files will become obsolete with the new Nix command line interface.", so perhaps you could assume it's either not developed yet or isn't released yet.

@SShrike okay then.
Hope we get chance to resolve this.

@edolstra well we could do what git does to maintain backwards compatibility. Use $XDG_CONFIG_HOME if it exists but if not, use ~/.nix-whatever. And when creating new files, always use $XDG_CONFIG_HOME.

Are there any plans to introduce something like @nhooyr described?

I don't think anyone is working on this project, or working on a plan for this project. It might be possible that a PR implementing that behavior + docs would be accepted.

I'm not opposed to it, but I'm not sure it's really worth it. It's likely to cause all sorts of confusion (e.g. when ~/.nix-channels and ~/.local/share/nix/channels both exist).

@edolstra Your fist comment in this thread mentioned new Nix command line interface. Is this currently being worked on?

Yes, the new nix command in Nix >= 2.0 uses ~/.config/nix. However it doesn't have replacements for nix-channel and nix-env yet. Hopefully soon.

So the plan is that new nix command will no longer use .nix-profile, .nix-channels and .nix-defexpr and keep necessary information in ~/.config/nix?
Is it described somewhere?

Are there any updates here? Would definitely appreciate this.

Yeah, it would be good to try some new directories for the old stuff, c.f. Git supporting /.gitconfig and /.config/git/... Even if flakes is stabilized, I still imagine people will not all stop using channels and what-not instantly, so I think this is worth it.

4 years ago, it was stated that these would become obsolete. What's going on? My home being cluttered is so incredibly annoying...
Why not migrate softly like @nhooyr suggested?

Was this page helpful?
0 / 5 - 0 ratings