ITADN
NixOS/nix/Issues

`nix-env` warns that `--option use-xdg-base-directories` is ignored but it is in fact applied

#15988OpenYoshiRulz 创建于 2026-06-06
bug
Y
YoshiRulzcommented
## Describe the bug When passing `--option use-xdg-base-directories` to certain `nix-env` subcommands like `--install`, a warning is erroneously printed. ## Steps To Reproduce Running a WIP of my script with `set -x`: ``` + /nix/store/23zk8sgzamrbmj1fday15szf7f2279s8-nix-2.34.7/bin/nix-env --version nix-env (Nix) 2.34.7 + /nix/store/23zk8sgzamrbmj1fday15szf7f2279s8-nix-2.34.7/bin/nix-env --query [buncha stuff from my actual profile; the script has already overridden XDG_STATE_HOME but use-xdg-base-directories is false] + env + fgrep XDG_STATE_HOME XDG_STATE_HOME=/home/yoshi/example + /nix/store/23zk8sgzamrbmj1fday15szf7f2279s8-nix-2.34.7/bin/nix-env --option use-xdg-base-directories true --query [empty] + /nix/store/23zk8sgzamrbmj1fday15szf7f2279s8-nix-2.34.7/bin/nix-env --option use-xdg-base-directories true --install --file /home/yoshi/Documents/myEnv/binutils.nix warning: ignoring the client-specified setting 'use-xdg-base-directories', because it is a restricted setting and you are not a trusted user installing 'binutils-wrapper-2.41' + /nix/store/23zk8sgzamrbmj1fday15szf7f2279s8-nix-2.34.7/bin/nix-env --option use-xdg-base-directories true --query binutils-wrapper-2.41 ``` ## Expected behavior `nix-env --install` doesn't produce a warning, like `nix-env --query`. ## Metadata nix-env (Nix) 2.34.7 ## Additional context I'm trying to use Nix from within a script as a sort of file download cache, but rather than wrangling GC roots, I figured I could just set a custom `XDG_STATE_HOME` and "install" to that profile, separate from the user's actual profile. It seems to work correctly, but requires `--option use-xdg-base-directories true` since I can't assume the user has that set. ## Checklist <!-- make sure this issue is not redundant or obsolete --> - [ ] checked [latest Nix manual] \([source]) - [x] checked [open bug issues and pull requests] for possible duplicates [latest Nix manual]: https://nix.dev/manual/nix/development/ [source]: https://github.com/NixOS/nix/tree/master/doc/manual/source [open bug issues and pull requests]: https://github.com/NixOS/nix/labels/bug --- Add :+1: to [issues you find important](https://github.com/NixOS/nix/issues?q=is%3Aissue+is%3Aopen+sort%3Areactions-%2B1-desc).
0 条评论