nixos/modules/users/default.nix

179 lines
4.1 KiB
Nix
Raw Normal View History

2023-07-27 21:14:39 +08:00
inputs:
{
config =
let
inherit (inputs.lib) listToAttrs mkMerge;
inherit (builtins) map;
inherit (inputs.localLib) stripeTabs;
in mkMerge
[
{
users =
{
users =
{
root =
{
shell = inputs.pkgs.zsh;
hashedPassword = "$y$j9T$.UyKKvDnmlJaYZAh6./rf/$65dRqishAiqxCE6LEMjqruwJPZte7uiyYLVKpzdZNH5";
2023-08-01 11:22:30 +08:00
openssh.authorizedKeys.keys =
[
("sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIPLByi05vCA95EfpgrCIXzkuyUWsyh"
+ "+Vso8FsUNFwPXFAAAABHNzaDo= chn@chn.moe")
];
};
2023-07-27 21:14:39 +08:00
chn =
{
isNormalUser = true;
extraGroups = inputs.lib.intersectLists
[ "adbusers" "networkmanager" "wheel" "wireshark" "libvirtd" "video" "audio" ]
(builtins.attrNames inputs.config.users.groups);
shell = inputs.pkgs.zsh;
autoSubUidGidRange = true;
hashedPassword = "$y$j9T$xJwVBoGENJEDSesJ0LfkU1$VEExaw7UZtFyB4VY1yirJvl7qS7oiF49KbEBrV0.hhC";
2023-07-27 21:14:39 +08:00
};
};
mutableUsers = false;
};
}
# (mkMerge (map (user:
# {
# sops.secrets."password/${user}".neededForUsers = true;
# users.users.${user}.passwordFile = inputs.config.sops.secrets."password/${user}".path;
# }) [ "root" "chn" ]))
2023-07-27 21:14:39 +08:00
{
home-manager =
{
useGlobalPkgs = true;
useUserPackages = true;
users =
let
2023-07-27 21:28:57 +08:00
normal = { pkgs, ...}:
2023-07-27 21:14:39 +08:00
{
home.stateVersion = "22.11";
programs.zsh =
{
enable = true;
initExtraBeforeCompInit = stripeTabs
''
# p10k instant prompt
2023-07-29 13:29:36 +08:00
typeset -g POWERLEVEL9K_INSTANT_PROMPT=off
2023-07-27 21:14:39 +08:00
P10K_INSTANT_PROMPT="$XDG_CACHE_HOME/p10k-instant-prompt-''${(%):-%n}.zsh"
[[ ! -r "$P10K_INSTANT_PROMPT" ]] || source "$P10K_INSTANT_PROMPT"
HYPHEN_INSENSITIVE="true"
export PATH=~/bin:$PATH
function br
{
local cmd cmd_file code
cmd_file=$(mktemp)
if broot --outcmd "$cmd_file" "$@"; then
cmd=$(<"$cmd_file")
command rm -f "$cmd_file"
eval "$cmd"
else
code=$?
command rm -f "$cmd_file"
return "$code"
fi
}
alias todo="todo.sh"
'';
plugins =
[
{
file = "powerlevel10k.zsh-theme";
name = "powerlevel10k";
2023-07-27 21:28:57 +08:00
src = "${pkgs.zsh-powerlevel10k}/share/zsh-powerlevel10k";
2023-07-27 21:14:39 +08:00
}
{
file = "p10k.zsh";
name = "powerlevel10k-config";
src = ./p10k-config;
}
{
name = "zsh-lsd";
2023-07-27 21:28:57 +08:00
src = pkgs.fetchFromGitHub
2023-07-27 21:14:39 +08:00
{
owner = "z-shell";
repo = "zsh-lsd";
rev = "029a9cb0a9b39c9eb6c5b5100dd9182813332250";
sha256 = "sha256-oWjWnhiimlGBMaZlZB+OM47jd9hporKlPNwCx6524Rk=";
};
}
# {
# name = "zsh-exa";
# src = pkgs.fetchFromGitHub
# {
# owner = "ptavares";
# repo = "zsh-exa";
# rev = "0.2.3";
# sha256 = "0vn3iv9d3c1a4rigq2xm52x8zjaxlza1pd90bw9mbbkl9iq8766r";
# };
# }
];
2023-07-28 15:08:08 +08:00
history =
{
extended = true;
save = 100000000;
size = 100000000;
share = true;
};
2023-07-27 21:14:39 +08:00
};
programs.direnv = { enable = true; nix-direnv.enable = true; };
};
in
{
root = normal;
chn = normal;
};
};
}
];
}
# environment.persistence."/impermanence".users.chn =
# {
# directories =
# [
# "Desktop"
# "Documents"
# "Downloads"
# "Music"
# "repo"
# "Pictures"
# "Videos"
# ".cache"
# ".config"
# ".gnupg"
# ".local"
# ".ssh"
# ".android"
# ".exa"
# ".gnome"
# ".Mathematica"
# ".mozilla"
# ".pki"
# ".steam"
# ".tcc"
# ".vim"
# ".vscode"
# ".Wolfram"
# ".zotero"
# ];
# files =
# [
# ".bash_history"
# ".cling_history"
# ".gitconfig"
# ".gtkrc-2.0"
# ".root_hist"
# ".viminfo"
# ".zsh_history"
# ];
# };