System/modules/linux/user.nix

66 lines
2.5 KiB
Nix
Raw Normal View History

2022-06-23 02:57:41 -04:00
{ config, lib, pkgs, ... }:
let nc = config.nathan.config;
in with lib; {
2022-10-09 21:43:38 -04:00
config = mkMerge [
{
users = {
# If we install the user and the system is hardended, then disable mutable users
mutableUsers = !(nc.installUser && nc.harden);
# Configure our user, if enabled
users."${nc.user}" = mkMerge [
(mkIf nc.installUser {
# Darwin is special
home = if pkgs.stdenv.isDarwin then
"/Users/${nc.user}"
else
"/home/${nc.user}";
description = "Nathan McCarty";
shell = pkgs.fish;
# Linux specific configuration next
})
2022-10-09 21:43:38 -04:00
(mkIf (nc.installUser && pkgs.stdenv.isLinux) {
isNormalUser = true;
extraGroups = [
"wheel"
"networkmanager"
"audio"
"docker"
"libvirtd"
"uinput"
"adbusers"
"plugdev"
];
hashedPassword =
"$6$ShBAPGwzKZuB7eEv$cbb3erUqtVGFo/Vux9UwT2NkbVG9VGCxJxPiZFYL0DIc3t4GpYxjkM0M7fFnh.6V8MoSKLM/TvOtzdWbYwI58.";
2022-10-09 21:43:38 -04:00
openssh.authorizedKeys.keys = [
# yubikey ssh key
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILRs6zVljIlQEZ8F+aEBqqbpeFJwCw3JdveZ8TQWfkev cardno:000615938515"
2023-02-25 22:06:32 -05:00
# WSL key
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIGXEV5lvLQ1CcPuJANv5AiYxtcRFEYXD5nODCazWnYC5 nathan@mccarty.io"
2022-10-09 21:43:38 -04:00
# Phone key
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFR0zpmBCb0iEOeeI6SBwgucddNzccfQ5Zmdgib5iSmF nix-on-droid@localhost"
# Tablet key
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKltqneJjfdLjOvnWQC2iP7hP7aTYkURPiR8LFjB7z87 nix-on-droid@localhost"
2023-03-27 17:19:13 -04:00
# Macbook key
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPLIZC4A4OhpTvfoL5jeMb1Ong9CwZ/URCYZL6y4Gp7b nathan@extremophile.local"
2022-10-09 21:43:38 -04:00
];
2022-07-02 02:44:43 -04:00
})
2022-10-09 21:43:38 -04:00
];
};
# If we install the user, enable sudo
security.sudo.enable = mkDefault nc.installUser;
# If we isntall the user, make them trusted
2022-11-22 22:16:10 -05:00
nix.settings.trusted-users =
if nc.installUser then [ "${nc.user}" ] else [ ];
2022-10-09 21:43:38 -04:00
# If we setup the user, install the shell as well
environment.systemPackages =
if nc.installUser then [ pkgs.fish ] else [ ];
2022-10-09 21:43:38 -04:00
# Configure the timezone
time.timeZone = "America/New_York";
}
2022-10-10 23:03:38 -04:00
(mkIf config.nathan.hardware.amdPassthrough {
2022-10-09 21:43:38 -04:00
users.users."${nc.user}".extraGroups = [ "libvirtd" ];
})
];
2022-06-23 02:57:41 -04:00
}