summaryrefslogtreecommitdiff
path: root/modules/desktop/security/sudo.nix
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-09-22 15:23:35 -0700
committerFuwn <[email protected]>2024-09-22 15:23:35 -0700
commit5658bb7f8bf3522c501864ea73024f544b14de3a (patch)
tree0436b387e6e815997da89cea46f2deb6984fb8ab /modules/desktop/security/sudo.nix
parentcore: move kansai networking to desktop (diff)
downloadnixos-config-5658bb7f8bf3522c501864ea73024f544b14de3a.tar.xz
nixos-config-5658bb7f8bf3522c501864ea73024f544b14de3a.zip
core: move kansai security to desktop
Diffstat (limited to 'modules/desktop/security/sudo.nix')
-rw-r--r--modules/desktop/security/sudo.nix75
1 files changed, 75 insertions, 0 deletions
diff --git a/modules/desktop/security/sudo.nix b/modules/desktop/security/sudo.nix
new file mode 100644
index 0000000..6623b71
--- /dev/null
+++ b/modules/desktop/security/sudo.nix
@@ -0,0 +1,75 @@
+{ pkgs, lib, ... }:
+let
+ inherit (lib.modules) mkForce;
+in
+{
+ 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";
+ }
+ ]
+ );
+ }
+ ];
+ };
+ };
+}