Skip to content

nixos-rebuild(-ng): --upgrade doesn't respect --sudo/--use-remote-sudo #424749

@name-snrl

Description

@name-snrl

Nixpkgs version

  • Unstable (25.11)

Describe the bug

I was helping my friend install NixOS. I always use --sudo/--use-remote-sudo flag. I recommended that he use this flag as well, but when he tried to upgrade the system using a single command:

nixos-rebuild boot --sudo --upgrade

it didn’t work. In nixos-rebuild(-ng), the nix-channel --update is executed as the current user. However, I believe it should always be run as root, because the description of this option says:

Update the root user's channel named ‘nixos’ before rebuilding the system.

But it doesn't if nixos-rebuild(-ng) was run not from root, and --sudo/--use-remote-sudo doesn't nothing in such case.

But this doesn’t happen if nixos-rebuild(-ng) is not run as root, and in this case, --sudo/--use-remote-sudo flag doesn’t help either.

Steps to reproduce

install nixos, try to upgrade it using nixos-rebuild boot --sudo --upgrade

Expected behaviour

nix-channel --update is always run as root

Screenshots

No response

Relevant log output

Additional context

I'm not sure if this was discussed before, but I couldn't find an issue that directly describes it — only the first comment in #381814 mentions it

Notify maintainers

@thiagokokada @Mic92 @K900


Note for maintainers: Please tag this issue in your pull request description. (i.e. Resolves #ISSUE.)

I assert that this issue is relevant for Nixpkgs

Is this issue important to you?

Add a 👍 reaction 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