summaryrefslogtreecommitdiff
path: root/modules/security/sudo.nix
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-09-04 19:57:20 -0700
committerFuwn <[email protected]>2024-09-04 19:57:20 -0700
commit8b5e5079e5fd00eadf2e3926c104e4ecf99a5779 (patch)
treed35acd86220ae3ffa521677d55acb37e9436ba64 /modules/security/sudo.nix
parentstyles (diff)
downloadnixos-config-8b5e5079e5fd00eadf2e3926c104e4ecf99a5779.tar.xz
nixos-config-8b5e5079e5fd00eadf2e3926c104e4ecf99a5779.zip
refac
Diffstat (limited to 'modules/security/sudo.nix')
-rw-r--r--modules/security/sudo.nix76
1 files changed, 72 insertions, 4 deletions
diff --git a/modules/security/sudo.nix b/modules/security/sudo.nix
index 5c79eaf..6623b71 100644
--- a/modules/security/sudo.nix
+++ b/modules/security/sudo.nix
@@ -1,7 +1,75 @@
+{ pkgs, lib, ... }:
+let
+ inherit (lib.modules) mkForce;
+in
{
- security.sudo = {
- enable = true;
- execWheelOnly = true;
- wheelNeedsPassword = false;
+ security = {
+ sudo-rs.enable = mkForce false;
+
+ sudo = {
+ enable = true;
+ execWheelOnly = mkForce true;
+ wheelNeedsPassword = lib.modules.mkDefault false;
+
+ extraConfig = ''
+ Defaults lecture = never
+ Defaults pwfeedback
+ Defaults env_keep += "EDITOR PATH DISPLAY"
+ Defaults timestamp_timeout = 300
+ '';
+
+ extraRules = [
+ {
+ groups = [ "wheel" ];
+ commands =
+ map
+ (rule: {
+ command = lib.meta.getExe' rule.package rule.command;
+ options = [ "NOPASSWD" ];
+ })
+ (
+ with pkgs;
+ [
+ {
+ package = coreutils;
+ command = "sync";
+ }
+ {
+ package = hdparm;
+ command = "hdparm";
+ }
+ {
+ package = nixos-rebuild;
+ command = "nixos-rebuild";
+ }
+ {
+ package = nvme-cli;
+ command = "nvme";
+ }
+ {
+ package = systemd;
+ command = "poweroff";
+ }
+ {
+ package = systemd;
+ command = "reboot";
+ }
+ {
+ package = systemd;
+ command = "shutdown";
+ }
+ {
+ package = systemd;
+ command = "systemctl";
+ }
+ {
+ package = util-linux;
+ command = "dmesg";
+ }
+ ]
+ );
+ }
+ ];
+ };
};
}