mirror of
				https://github.com/nmasur/dotfiles
				synced 2025-11-04 11:43:16 +00:00 
			
		
		
		
	
		
			
				
	
	
		
			43 lines
		
	
	
		
			716 B
		
	
	
	
		
			Nix
		
	
	
	
	
	
			
		
		
	
	
			43 lines
		
	
	
		
			716 B
		
	
	
	
		
			Nix
		
	
	
	
	
	
{
 | 
						|
  config,
 | 
						|
  lib,
 | 
						|
  ...
 | 
						|
}:
 | 
						|
 | 
						|
let
 | 
						|
  cfg = config.nmasur.presets.programs.doas;
 | 
						|
in
 | 
						|
 | 
						|
{
 | 
						|
 | 
						|
  options.nmasur.presets.programs.doas.enable = lib.mkEnableOption "doas sudo alternative";
 | 
						|
 | 
						|
  config = lib.mkIf cfg.enable {
 | 
						|
 | 
						|
    security = {
 | 
						|
 | 
						|
      # Remove sudo
 | 
						|
      sudo.enable = false;
 | 
						|
 | 
						|
      # Add doas
 | 
						|
      doas = {
 | 
						|
        enable = true;
 | 
						|
 | 
						|
        # No password required for trusted users
 | 
						|
        wheelNeedsPassword = false;
 | 
						|
 | 
						|
        # Pass environment variables from user to root
 | 
						|
        # Also requires specifying that we are removing password here
 | 
						|
        extraRules = [
 | 
						|
          {
 | 
						|
            groups = [ "wheel" ];
 | 
						|
            noPass = true;
 | 
						|
            keepEnv = true;
 | 
						|
          }
 | 
						|
        ];
 | 
						|
      };
 | 
						|
    };
 | 
						|
 | 
						|
  };
 | 
						|
}
 |