{
  config,
  flake,
  pkgs,
  lib,
  ...
}:
let
  inherit (flake) self;
  inherit (flake.config.people) user0;
  inherit (flake.config.machines) devices;
  inherit (flake.config.people.users.${user0}) name paths;

  hostname = config.networking.hostName;
in
{

  sops.secrets = {
    "password-user0" = {
      neededForUsers = true;
      sopsFile = ../../secrets/secrets.yaml;
    };
  };

  users = {
    users = {
      "root" = {
        hashedPasswordFile = config.sops.secrets."password-user0".path;
      };
      ${user0} = {
        description = name;
        name = user0;
        isNormalUser = true;
        shell = pkgs.nushell;
        hashedPasswordFile = config.sops.secrets."password-user0".path;
        extraGroups = [
          "adbusers"
          "caddy"
          "disk"
          "jellyfin"
          "libvirtd"
          "minecraft"
          "netdev"
          "networkmanager"
          "ollama"
          "opencloud"
          "plugdev"
          "docker"
          "postgres"
          "redis-mastodon"
          "samba"
          "syncthing"
          "vaultwarden"
          "vboxusers"
          "wheel"
          "comfyui"
        ];
      };
    };
  };
  home-manager.users = {
    ${user0} = {
      home = {
        username = user0;
        homeDirectory = "/home/${user0}";
        file =
          if hostname == devices.ceres.name then
            { }
          else
            {
              "./justfile" = import ./files/misc/justfile.nix { inherit flake config lib; };
              "./.config/scripts/list.sh" = {
                source = ./files/scripts/list.sh;
                executable = true;
              };
              "./.config/scripts/loop.sh" = {
                source = ./files/scripts/loop.sh;
                executable = true;
              };
              "./.config/scripts/get_weather.sh" = {
                source = ./files/scripts/get_weather.sh;
                executable = true;
              };
              ".config/wallpaper" = {
                source = ./files/wallpaper;
                recursive = true;
              };
              "./.config/vesktop/themes/macchiato-theme.css" = {
                source = ./files/themes/vesktop/macchiato-theme.css;
              };
              "./.config/qBittorrent/themes/catppuccin-mocha.qbtheme" = {
                source = ./files/themes/qbittorrent/macchiato.qbtheme;
              };
            };
        sessionVariables = {
          VISUAL = lib.getExe pkgs.zed-editor;
          GTK_THEME = "catppuccin-macchiato-mauve-compact";
        };
      };
      imports = [
        {
          home.stateVersion = config.system.stateVersion;
        }
        {
          imports = [
            self.homeModules."${devices.${hostname}.name}-${user0}"
          ];
        }
      ];
    };
  };
  systemd.tmpfiles = {
    rules = [
      "d ${paths.path0} 0755 ${user0} users -"
    ]
    ++ (map (path: "d /home/${user0}/${path} 0755 ${user0} users -") [
      "projects"
      "downloads"
    ])
    ++ (map (path: "R /home/${user0}/${path} 0755 ${user0} users - -") [
      "Desktop"
      "Documents"
      "Downloads"
      "Music"
      "Pictures"
      "Public"
      "Templates"
      "Videos"
    ]);
  };
}
