2024-09-09 00:22:14 +00:00
|
|
|
{
|
2024-09-13 01:50:53 +00:00
|
|
|
config,
|
|
|
|
lib,
|
2024-12-07 01:44:03 +00:00
|
|
|
pkgs,
|
2024-09-13 01:50:53 +00:00
|
|
|
...
|
|
|
|
}:
|
|
|
|
with lib; let
|
|
|
|
cfg = config.custom.settings.security;
|
|
|
|
in {
|
|
|
|
options.custom.settings.security.enable = mkOption {default = false;};
|
2024-09-09 00:22:14 +00:00
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
|
|
|
# Bypass password prompts
|
|
|
|
security = {
|
|
|
|
sudo.wheelNeedsPassword = false;
|
|
|
|
|
|
|
|
# https://wiki.nixos.org/wiki/Sway#Using_Home_Manager
|
|
|
|
polkit = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
# https://wiki.archlinux.org/title/Polkit#Bypass_password_prompt
|
|
|
|
extraConfig = ''
|
|
|
|
polkit.addRule(function(action, subject) {
|
|
|
|
if (subject.isInGroup("wheel")) { return polkit.Result.YES; }
|
|
|
|
});
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
2024-12-07 01:44:03 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
'';
|
|
|
|
};
|
2024-09-09 00:22:14 +00:00
|
|
|
};
|
|
|
|
}
|