1
1
Fork 0
nixos/options/custom/settings/security.nix

49 lines
1 KiB
Nix
Raw Normal View History

{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.custom.settings.security;
in {
options.custom.settings.security.enable = mkOption {default = false;};
config = mkIf cfg.enable {
# Bypass password prompts
security = {
sudo = {
enable = true;
wheelNeedsPassword = false;
};
# https://wiki.nixos.org/wiki/Sway#Using_Home_Manager
# https://wiki.archlinux.org/title/Polkit#Bypass_password_prompt
polkit = {
enable = true;
extraConfig = ''
polkit.addRule(function(action, subject) {
if (subject.isInGroup("wheel")) { return polkit.Result.YES; }
});
'';
};
};
environment.shellAliases = {
# Sudo confirmation prompt
sudo = pkgs.writeShellScript "sudo" ''
read -p "Execute as root? [Y/n] "
case "$REPLY" in
"" | [Yy])
command sudo "$@"
;;
*)
exit 1
;;
esac
'';
};
};
}