{ config, pkgs, lib, ... }:
let
    profile = import ./profile.nix;
    home-directory = "/home/${profile.username}";
    ssh-filename = "${home-directory}/.ssh/id_ed25519";
in
{

    imports = [
        ./desktop-environment/config.nix
        ./terminal-environment/config.nix
        ./system-environment/config.nix
    ];

    users.users.${profile.username} = {
        isNormalUser = true;
        description = "Nina Chlóe Kassandra";
        extraGroups = ["disks" "storage" "networkmanager" "wheel" "docker" "scanner" "lp" "uucp" "dialout"];
        packages = with pkgs; [];
        shell = pkgs.zsh;
	    hashedPassword = profile.hashed-password;
    };

    systemd.services.generate-ssh-key = {
    	description = "Generate SSH key if missing";
    	wantedBy = [ "multi-user.target" ];
    	after = [ "network.target" ];
    	serviceConfig = {
		Type = "oneshot";
      		User = profile.username;
    };

    script = ''
      if [ ! -f ${ssh-filename} ]; then
        mkdir -p ${home-directory}/.ssh
        chmod 700 ${home-directory}/.ssh
        ${pkgs.openssh}/bin/ssh-keygen -t ed25519 -N "" -f ${ssh-filename}
      fi
    '';
  };
}
