35 lines
660 B
Nix

{
options,
config,
lib,
...
}:
with lib;
with lib.frajul; let
cfg = config.system.security.doas;
in {
options.system.security.doas = {
enable = mkBoolOpt false "Whether or not to replace sudo with doas.";
};
config = mkIf cfg.enable {
# Disable sudo
security.sudo.enable = false;
# Enable and configure `doas`.
security.doas = {
enable = true;
extraRules = [
{
users = [config.user.name];
noPass = true;
keepEnv = true;
}
];
};
# Add an alias to the shell for backward-compat and convenience.
environment.shellAliases = {sudo = "doas";};
};
}