{
  inputs,
  lib,
  pkgs,
  ...
}: let
  inherit (lib) getExe;
in {
  home.stateVersion = "22.11";

  imports = [
    ./modules/cli.nix
    ./modules/desktop.nix
    ./modules/dev.nix
    ./modules/theming.nix
    ./util/ez.nix
    ./util/flatpak.nix
    ./util/cosmic.nix
    ./util/murex.nix
    ./util/name.nix
    inputs.nix-index-database.hmModules.nix-index
  ];

  nix.gc = {
    automatic = true;
    frequency = "daily";
    options = "--delete-older-than 3d";
  };

  xdg = {
    enable = true;
    portal = let
      cosmic = pkgs.xdg-desktop-portal-cosmic;
      gtk = pkgs.xdg-desktop-portal-gtk;
    in {
      enable = true;
      config = {
        common = {
          default = [
            "cosmic"
          ];
        };
      };
      configPackages = [
        cosmic
        gtk
      ];
      extraPortals = [
        cosmic
        gtk
      ];
    };
  };

  home.packages = let
    inherit (pkgs.rice) icons fonts;
  in
    fonts.pkgs
    ++ icons.pkgs;

  systemd.user.targets.tray = {
    Unit = {
      Description = "Home Manager System Tray";
      Requires = ["graphical-session-pre.target"];
    };
  };

  services.syncthing = {
    enable = true;
  };

  services.udiskie.enable = true;
  # fix reliance on nonexistent graphical-session-pre.target
  systemd.user.services.udiskie = lib.mkForce {
    Unit = {
      Description = "udiskie mount daemon";
      After = [];
      PartOf = ["graphical-session.target"];
    };

    Service.ExecStart = ["${pkgs.udiskie}/bin/udiskie --appindicator"];

    Install.WantedBy = ["graphical-session.target"];
  };

  # programs.nix-index-database.comma.enable = true;
  # programs.nix-index = {
  #   enable = true;
  #   enableZshIntegration = false;
  #   enableBashIntegration = false;
  # };
  # programs.command-not-found.enable = false;
  # programs.nix-index.enable = true;

  systemd.user.startServices = "sd-switch";
  ezServices = {
    ckb-next = "${getExe pkgs.ckb-next} -c -b";
  };
}
