NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.49k stars 13.67k forks source link

Doas with nixos-rebuild --use-remote-sudo #275018

Open thechubbypanda opened 9 months ago

thechubbypanda commented 9 months ago

Describe the bug

nixos-rebuild --use-remote-sudo doesn't work with doas

Steps To Reproduce

On remote:

  1. Disable sudo
  2. Add doas nopasswd
  3. Add wheel user

On local:

  1. nixos-rebuild --target-host user@remote --use-remote-sudo
  2. Observe missing sudo executable error

Suggested solutions

  1. Add --use-remote-doas
  2. Replace --use-remote-sudo with --use-remote-elevation and have it automatically pick one

Notify maintainers

@lheckemann

Metadata

 - system: `"x86_64-linux"`
 - host os: `Linux 6.1.64, NixOS, 23.11 (Tapir), 23.11.1115.5de0b32be6e8`
 - multi-user?: `yes`
 - sandbox: `yes`
 - version: `nix-env (Nix) 2.18.1`
 - nixpkgs: `/nix/var/nix/profiles/per-user/root/channels/nixos`

Add a :+1: reaction to issues you find important.

MrHamel commented 7 months ago

It also does not help when this config is used.

{
  environment.systemPackages = [
    pkgs.doas
    pkgs.doas-sudo-shim
  ];

  security.doas.enable = true;
  security.sudo.enable = false;
}
-> # nixos-rebuild switch --upgrade-all --impure --flake /etc/nixos#(flake) --target-host (user)@(ip) --use-remote-sudo
building the system configuration...
(user@ip) Password: 
copying 0 paths...
sudo: unrecognized option '--preserve-env=NIXOS_INSTALL_BOOTLOADER'
Usage:
  sudo (-i | -s) [-n] [-u <user>] [<command> [--] [<args>...]]
  sudo [-ins] [-u <user>] <command> [--] [<args>...]
  sudo [-h]

Execute a command as another user using doas(1).

This is not the original sudo, but the doas shim for sudo. It supports only
a subset of the sudo options (both short and long) that have an equivalent in
doas, plus option -i (--login). Refer to sudo(1) for more information.

Please report bugs at <https://github.com/jirutka/doas-sudo-shim/issues>.
Shared connection to (ip) closed.
zendo commented 6 months ago

https://github.com/NixOS/nixpkgs/pull/289680 fix the issue, now it works if doas-sudo-shim installed.

thechubbypanda commented 6 months ago

While that helps, I'd still like to not need the shim. Everything else I use works fine without.