Skip to content

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

@YoshiRulz

Description

@YoshiRulz

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


Add 👍 to issues you find important.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions