nixos-config/modules/nixos/shared/primary-as-admin.nix
2024-10-22 16:07:50 -04:00

26 lines
653 B
Nix

# Make flake.config.peope.myself the admin of the machine
{ flake, pkgs, lib, ... }:
{
# Login via SSH with mmy SSH key
users.users =
let
me = flake.config.me;
myKeys = [ me.sshKey ];
in
{
root.openssh.authorizedKeys.keys = myKeys;
${me.username} = {
openssh.authorizedKeys.keys = myKeys;
} // lib.optionalAttrs pkgs.stdenv.isLinux {
isNormalUser = true;
extraGroups = [ "networkmanager" "wheel" ];
};
};
# Make me a sudoer without password
security = lib.optionalAttrs pkgs.stdenv.isLinux {
sudo.execWheelOnly = true;
sudo.wheelNeedsPassword = false;
};
}