The title (embarassing as it is) says it all. Some context first:

I'm running NixOS using a custom ISO on Vultr.

Timeframe of attempts:

  • which sudo shows no sudo
  • Installed sudo using nix-env -i sudo
  • Then, when I tried to sudo ..., I see sudo: /home/agam/.nix-profile/bin/sudo must be owned by uid 0 and have the setuid bit set
  • sudo su didn't work for the same reason
  • Okay, I uninstalled it (nix-env --uninstall sudo)
  • Thought hmm, maybe I'm supposed to install it as root?
  • So, su and then repeat the install
  • Now when I try to sudo ..., I see sudo: /nix/var/nix/profiles/default/bin/sudo must be owned by uid 0 and have the setuid bit set (so the same error as before, with a different path)
  • As a last resort, try a hammer, and kudos to NixOS for stopping me:
[root@nixos:/home/agam]# chmod 4755 /nix/var/nix/profiles/default/bin/sudo
chmod: changing permissions of '/nix/var/nix/profiles/default/bin/sudo': Read-only file system

Any clues on what's going on here?

Some possible options I see here are: 1. The custom ISO that Vultr provided was ... missing something 2. Some fundamentally different ways that sudo is supposed to work in NixOS 3. I'm missing something very basic in how to go about using Nix (most likely!)

Some details:

[agam@nixos:~]$ nixos-version
18.09.1534.d45a0d7a4f5 (Jellyfish)

[agam@nixos:~]$ which sudo

[agam@nixos:~]$ nix-channel --list
nixos https://nixos.org/channels/nixos-18.09

(Note: originally posted at StackOverflow, was recommended to ask here instead!)


As NixOS is configured completely declaritiveley, there should be only one place where sudo is switched on and off: Your NixOS config (which probably lives in /etc/nixos/configuration.nix).

The option security.sudo.enable should be true by default, but maybe you import a module, that overrides the default? Setting it to true explicitly should shine some light on this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.