A new start
This commit is contained in:
commit
f4e2368893
93 changed files with 7621 additions and 0 deletions
104
modules/nixos/user/default.nix
Normal file
104
modules/nixos/user/default.nix
Normal file
|
@ -0,0 +1,104 @@
|
|||
{ options
|
||||
, config
|
||||
, pkgs
|
||||
, lib
|
||||
, ...
|
||||
}:
|
||||
with lib;
|
||||
with lib.metacfg; let
|
||||
cfg = config.metacfg.user;
|
||||
defaultIconFileName = "profile.jpg";
|
||||
defaultIcon = pkgs.stdenvNoCC.mkDerivation {
|
||||
name = "default-icon";
|
||||
src = ./. + "/${defaultIconFileName}";
|
||||
|
||||
dontUnpack = true;
|
||||
|
||||
installPhase = ''
|
||||
cp $src $out
|
||||
'';
|
||||
|
||||
passthru = { fileName = defaultIconFileName; };
|
||||
};
|
||||
propagatedIcon =
|
||||
pkgs.runCommandNoCC "propagated-icon"
|
||||
{ passthru = { fileName = cfg.icon.fileName; }; }
|
||||
''
|
||||
local target="$out/share/metacfg-icons/user/${cfg.name}"
|
||||
mkdir -p "$target"
|
||||
|
||||
cp ${cfg.icon} "$target/${cfg.icon.fileName}"
|
||||
'';
|
||||
in
|
||||
{
|
||||
options.metacfg.user = with types; {
|
||||
name = mkOpt str "harald" "The name to use for the user account.";
|
||||
fullName = mkOpt str "Harald Hoyer" "The full name of the user.";
|
||||
email = mkOpt str "harald@hoyer.xyz" "The email of the user.";
|
||||
initialPassword =
|
||||
mkOpt str "password"
|
||||
"The initial password to use when the user is first created.";
|
||||
icon =
|
||||
mkOpt (nullOr package) defaultIcon
|
||||
"The profile picture to use for the user.";
|
||||
prompt-init = mkBoolOpt true "Whether or not to show an initial message when opening a new shell.";
|
||||
extraGroups = mkOpt (listOf str) [ ] "Groups for the user to be assigned.";
|
||||
sshKeys = mkOpt (listOf str) [
|
||||
"sk-ssh-ed25519@openssh.com AAAAGnNrLXNzaC1lZDI1NTE5QG9wZW5zc2guY29tAAAAIDsb/Tr69YN5MQLweWPuJaRGm+h2kOyxfD6sqKEDTIwoAAAABHNzaDo= harald@fedora.fritz.box"
|
||||
"sk-ecdsa-sha2-nistp256@openssh.com AAAAInNrLWVjZHNhLXNoYTItbmlzdHAyNTZAb3BlbnNzaC5jb20AAAAIbmlzdHAyNTYAAABBBACLgT81iB1iWWVuXq6PdQ5GAAGhaZhSKnveQCvcNnAOZ5WKH80bZShKHyAYzrzbp8IGwLWJcZQ7TqRK+qZdfagAAAAEc3NoOg== harald@hoyer.xyz"
|
||||
"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBAYbUTKpy4QR3s944/hjJ1UK05asFEs/SmWeUbtS0cdA660sT4xHnRfals73FicOoz+uIucJCwn/SCM804j+wtM="
|
||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMNsmP15vH8BVKo7bdvIiiEjiQboPGcRPqJK0+bH4jKD harald@lenovo.fritz.box"
|
||||
] "ssh keys";
|
||||
extraOptions =
|
||||
mkOpt attrs { }
|
||||
(mdDoc "Extra options passed to `users.users.<name>`.");
|
||||
};
|
||||
|
||||
config = {
|
||||
environment.systemPackages = with pkgs; [
|
||||
];
|
||||
|
||||
metacfg.home = {
|
||||
file = {
|
||||
"Desktop/.keep".text = "";
|
||||
"Documents/.keep".text = "";
|
||||
"Downloads/.keep".text = "";
|
||||
"Music/.keep".text = "";
|
||||
"Pictures/.keep".text = "";
|
||||
"Videos/.keep".text = "";
|
||||
"work/.keep".text = "";
|
||||
".face".source = cfg.icon;
|
||||
"Pictures/${
|
||||
cfg.icon.fileName or (builtins.baseNameOf cfg.icon)
|
||||
}".source =
|
||||
cfg.icon;
|
||||
};
|
||||
extraOptions.programs.bash.initExtra = ''
|
||||
[[ $WANT_BASH ]] || ${pkgs.fish}/bin/fish -l
|
||||
'';
|
||||
};
|
||||
|
||||
users.users.${cfg.name} =
|
||||
{
|
||||
isNormalUser = true;
|
||||
|
||||
# inherit (cfg) name initialPassword;
|
||||
|
||||
openssh.authorizedKeys.keys = cfg.sshKeys;
|
||||
home = "/home/${cfg.name}";
|
||||
group = "users";
|
||||
|
||||
shell = pkgs.bash;
|
||||
|
||||
# Arbitrary user ID to use for the user. Since I only
|
||||
# have a single user on my machines this won't ever collide.
|
||||
# However, if you add multiple users you'll need to change this
|
||||
# so each user has their own unique uid (or leave it out for the
|
||||
# system to select).
|
||||
uid = 1000;
|
||||
|
||||
extraGroups = [ ] ++ cfg.extraGroups;
|
||||
}
|
||||
// cfg.extraOptions;
|
||||
};
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue