Sudo not working inside a buildFHSUserEnv: "no new privileges" flag

Hi there. Does anyone know how to get sudo privileges inside a fhs?

Minimal example of a buildFHSUserEnv:

# shell.nix
{ pkgs ? import <nixpkgs> {} }:
(pkgs.buildFHSUserEnv {
  name = "example";
  targetPkgs = pkgs: (with pkgs; [ libgcc ]);
  runScript = "bash";
}).env

Start with nix-shell. But sudo is disabled:

$ sudo
sudo: The "no new privileges" flag is set, which prevents sudo from running as root.
sudo: If sudo is running in a container, you may need to adjust the container configuration to disable the flag.

Any help welcome, thanks!

1 Like