2023-10-06 12:11:50 +08:00
|
|
|
|
{ pkgs, username, ... }:
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
nix.settings.trusted-users = [ username ];
|
|
|
|
|
|
|
|
|
|
|
|
# Define a user account. Don't forget to set a password with ‘passwd’.
|
|
|
|
|
|
users = {
|
|
|
|
|
|
users."${username}" = {
|
|
|
|
|
|
# the hashed password with salt is generated by run `mkpasswd`.
|
|
|
|
|
|
hashedPassword = "$y$j9T$inkrp6FuM46uoPFVrOlbz1$igJed6pECf4AENVaLT4mk.Q4z02MmxjWnGo.OVvCyC.";
|
|
|
|
|
|
home = "/home/${username}";
|
|
|
|
|
|
isNormalUser = true;
|
|
|
|
|
|
description = username;
|
|
|
|
|
|
extraGroups = [
|
|
|
|
|
|
"users"
|
|
|
|
|
|
"wheel"
|
|
|
|
|
|
"networkmanager"
|
|
|
|
|
|
"audio"
|
2025-04-21 23:24:10 +08:00
|
|
|
|
"nixbld"
|
2023-10-06 12:11:50 +08:00
|
|
|
|
];
|
|
|
|
|
|
openssh.authorizedKeys.keys = [
|
|
|
|
|
|
];
|
|
|
|
|
|
};
|
|
|
|
|
|
};
|
|
|
|
|
|
|
2025-04-21 23:24:10 +08:00
|
|
|
|
binPath = "${pkgs.nix}/bin";
|
|
|
|
|
|
|
2023-10-06 12:11:50 +08:00
|
|
|
|
# DO NOT promote the specified user to input password for `nix-store` and `nix-copy-closure`
|
|
|
|
|
|
security.sudo = {
|
|
|
|
|
|
# wheelNeedsPassword = false;
|
|
|
|
|
|
extraRules = [
|
|
|
|
|
|
{
|
|
|
|
|
|
users = [ username ];
|
|
|
|
|
|
commands =
|
|
|
|
|
|
[
|
|
|
|
|
|
{
|
2025-04-21 23:24:10 +08:00
|
|
|
|
command = "${binPath}/nix-store";
|
2023-10-06 12:11:50 +08:00
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
|
|
}
|
|
|
|
|
|
{
|
|
|
|
|
|
command = "/run/current-system/sw/bin/nixos-rebuild";
|
|
|
|
|
|
options = [ "NOPASSWD" "SETENV" ];
|
|
|
|
|
|
}
|
|
|
|
|
|
{
|
2025-04-21 23:24:10 +08:00
|
|
|
|
command = "${binPath}/reboot";
|
2023-10-06 12:11:50 +08:00
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
|
|
}
|
|
|
|
|
|
{
|
2025-04-21 23:24:10 +08:00
|
|
|
|
command = "${binPath}/bin/poweroff";
|
2023-10-06 12:11:50 +08:00
|
|
|
|
options = [ "NOPASSWD" ];
|
|
|
|
|
|
}
|
|
|
|
|
|
];
|
|
|
|
|
|
}
|
|
|
|
|
|
];
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|