dotfiles/modules/nixos/system/doas.nix

49 lines
891 B
Nix
Raw Normal View History

2022-04-26 01:54:53 +00:00
# Replace sudo with doas
2024-04-20 13:42:06 +00:00
{
config,
pkgs,
lib,
...
}:
{
2022-04-26 01:54:53 +00:00
2022-12-21 21:18:03 +00:00
config = lib.mkIf pkgs.stdenv.isLinux {
2022-04-26 01:54:53 +00:00
2022-12-21 21:18:03 +00:00
security = {
2022-04-26 01:54:53 +00:00
2022-12-21 21:18:03 +00:00
# Remove sudo
sudo.enable = false;
2022-04-26 01:54:53 +00:00
2022-12-21 21:18:03 +00:00
# Add doas
doas = {
enable = true;
2022-04-26 01:54:53 +00:00
2023-07-31 00:26:23 +00:00
# No password required for trusted users
2022-12-21 21:18:03 +00:00
wheelNeedsPassword = false;
# Pass environment variables from user to root
2023-07-31 00:26:23 +00:00
# Also requires specifying that we are removing password here
2024-04-20 13:42:06 +00:00
extraRules = [
{
groups = [ "wheel" ];
noPass = true;
keepEnv = true;
}
];
2022-12-21 21:18:03 +00:00
};
};
home-manager.users.${config.user}.programs = {
# Alias sudo to doas for convenience
2024-04-20 13:42:06 +00:00
fish.shellAliases = {
sudo = "doas";
};
# Disable overriding our sudo alias with a TERMINFO alias
kitty.settings.shell_integration = "no-sudo";
2022-04-26 01:54:53 +00:00
};
2022-04-30 16:07:58 +00:00
};
2022-04-26 01:54:53 +00:00
}