let
  modulesPath = ./modules;

  importFolder = name: {"${name}" = import (modulesPath + "/${name}");};
  importFile = name: {"${name}" = import (modulesPath + "/${name}.nix");};
  importMisc = name: {"misc-${name}" = import (modulesPath + "/misc/${name}.nix");};

  modules =
    builtins.foldl' (
      emptySet: importedModules:
        emptySet // importedModules
    ) {} (map importFolder [
      "bat"
      "firefox"
      "obs-studio"
      "qbittorrent"
      "steam"
    ])
    // builtins.foldl' (
      emptySet: importedModules:
        emptySet // importedModules
    ) {} (map importFile [
      "bottom"
      "brave"
      "direnv"
      "freetube"
      "git"
      "helix"
      "home-manager"
      "lazygit"
      "mpv"
      "nextcloud"
      "nushell"
      "starship"
      "vscode"
      "wezterm"
      "yazi"
      "zellij"
      "zoxide"
    ])
    // builtins.foldl' (
      emptySet: importedModules:
        emptySet // importedModules
    ) {} (map importMisc [
      "android"
      "commandLine"
      "desktop"
      "entertainment"
      "internet"
      "productionArt"
      "productionAudio"
      "productionVideo"
      "productionWriting"
      "tracking"
      "virtualization"
    ]);
in {
  flake.homeModules = {
    desktop = {
      imports = with modules; [
        brave
        firefox
        misc-android
        misc-desktop
        misc-internet
        qbittorrent
        vscode
      ];
    };

    entertainment = {
      imports = with modules; [
        freetube
        misc-entertainment
        mpv
        steam
      ];
    };

    productionArt = {
      imports = with modules; [
        misc-productionArt
      ];
    };

    productionAudio = {
      imports = with modules; [
        misc-productionAudio
      ];
    };

    productionVideo = {
      imports = with modules; [
        misc-productionVideo
        obs-studio
      ];
    };

    productionWriting = {
      imports = with modules; [
        misc-productionWriting
      ];
    };

    shared = {
      imports = with modules; [
        bat
        bottom
        direnv
        git
        helix
        home-manager
        lazygit
        misc-commandLine
        misc-virtualization
        nushell
        starship
        wezterm
        # yazi
        zellij
        zoxide
      ];
    };
  };
}
