# vim: ts=2
{
  pkgs,
  sysLib,
  grades,
  snap-sync,
  ...
}:
with pkgs; let
  snap-sync-pkgs = pkgs.writeShellScriptBin "snap-sync" (builtins.readFile "${snap-sync}/bin/snap-sync");
  shell-scripts = (import ./scripts.nix) {inherit pkgs sysLib;};

  Gui = {
    Terminals = [
      # foot # wayland native terminal
      alacritty # default terminal
    ];
    Browsers = [
      ungoogled-chromium # web browser (only for web programming)
      brave
    ];

    ImageManipulation = [
      krita # new, and better (KDE)
      gimp # conservative, and old (GNOME)
    ];

    Social = [
      mumble # voice chat software (client)
      lutris # multiple game store clients
    ];

    Misc = [
      kalzium # Periodic Table of Elements
      keepassxc # password manager
      onlykey # OnlyKey Chrome Desktop App
      anki-bin # spaced repetition
    ];
  };

  TuiCli = {
    EyeCandy = [
      banner # Print large banners to ASCII terminals
      cmatrix # A curses-based scrolling 'Matrix'-like screen
      hyfetch # Neofetch with LGBTQ pride flags.
    ];

    Misc = [
      android-file-transfer # Android MTP client with minimalistic UI
      xdg-ninja # A shell script which checks your $HOME for unwanted files and directories.
      xdg-utils # open urls and such things
      yokadi # Command line oriented, sqlite powered, todo list
      killall # kill a application by name
    ];

    WM = {
      river = [river]; # A dynamic tiling wayland compositor

      CLITools = [
        lswt # List Wayland toplevels
        wl-clipboard # Command-line copy/paste utilities
        swaylock # lockscreen
      ];

      Media = [
        wf-recorder # Screen recorder
      ];
    };

    Media = {
      View = [
        imv # Image viewer
      ];

      Listen = [
        pulseaudio # set the volume with pactl
        ncmpc # mpd player client
        mpc-cli # a cli mpd client
      ];
    };

    Hardware = {
      Storage = [
        #        compsize # Calculate compression ratio of a set of files on Btrfs
        # TODO        smartmontools # Control and monitor S.M.A.R.T. enabled ATA and SCSI Hard Drives
      ];

      Input = [
        piper # GTK application to configure gaming mice
      ];

      Printer = [
        # TODO        sane-airscan # SANE - SANE backend for AirScan (eSCL) and WSD document scanners
      ];
    };

    FileListers = [
      tree # A directory listing program displaying a depth indented list of files
      fd # Simple, fast and user-friendly alternative to find
      ripgrep # A search tool that combines the usability of ag with the raw speed of grep
      fzf # used to quickly move around with its keybindings
    ];

    Editors = [
      ed # A POSIX-compliant line-oriented text editor
      #sed # GNU stream editor
      #vi # The original ex/vi text editor # TODO
      neovim # Fork of Vim aiming to improve user experience, plugins, and GUIs
    ];

    Programming = {
      GeneralTools = [
        git # the fast distributed version control system
        glow # Command-line markdown renderer

        # TODO ADD THESE TO A Shell-FLAKE        git-bug # Distributed, offline-first bug tracker embedded in git, with bridges
        # TODO ADD THESE TO A Shell-FLAKE        strace # A diagnostic, debugging and instructional userspace tracer
        # TODO ADD THESE TO A Shell-FLAKE        tokei # A blazingly fast CLOC (Count Lines Of Code) program
        # TODO ADD THESE TO A Shell-FLAKE        onefetch # TODO
      ];

      # TODO add to nix-shell      Rust = [
      # TODO add to nix-shell        rustup # The Rust toolchain installer
      # TODO add to nix-shell        rust-analyzer # Rust compiler front-end for IDEs
      # TODO add to nix-shell      ];

      # See above      Yaml = [
      # See above        yamllint # Linter for YAML files
      # See above      ];

      # TODO See above TeX = [
      # TODO See         zathura # Minimalistic document viewer
      # TODO See         #zathura-pdf-poppler # Adds pdf support to zathura by using the poppler engine
      # TODO See         ltex-ls # LTeX Language Server
      # TODO See         biber # A Unicode-capable BibTeX replacement for biblatex users
      # TODO See         pandoc # Conversion between markup formats
      # TODO See       ];
      # TODO See
      # TODO See       Web = [
      # TODO See         nodePackages_latest.vscode-langservers-extracted # Language servers extracted from VSCode.
      # TODO See         rsass # dart-sass # Sass makes CSS fun again
      # TODO See         nodePackages_latest.prettier # An opinionated code formatter for JS, JSON, CSS, YAML and much more
      # TODO See       ];
      # TODO See
      # TODO See       Shell = [
      # TODO See         dash # POSIX compliant shell that aims to be as small as possible
      # TODO See         shellcheck # Shell script analysis tool
      # TODO See       ];
      # TODO See
      # TODO See       Lua = [
      # TODO See         lua # Powerful lightweight programming language designed for extending applications
      # TODO See         luaformatter # lua-format # LuaFormatter - Code formatter for Lua
      # TODO See         sumneko-lua-language-server #lua-language-server # Lua Language Server coded by Lua
      # TODO See       ];
      # TODO See
      # TODO See       R = [
      # TODO See         R # Language and environment for statistical computing and graphics
      # TODO See       ];
    };
  };
  #expect # A tool for automating interactive applications
  #handlr # Powerful alternative to xdg-utils written in Rust
  #packagekit-qt5 # Qt5 bindings for PackageKit
  #vulkan-radeon # Radeon's Vulkan mesa driver
  #xorg-bdftopcf # Convert X font from Bitmap Distribution Format to Portable Compiled Format

  mapFun = x:
    if builtins.isAttrs x
    then
      if lib.isDerivation x
      then [x]
      else builtins.attrValues x
    else [x];
in {
  home.packages =
    [
      snap-sync-pkgs
      grades.outputs.packages.${system}.default
    ]
    ++ shell-scripts
    ++ (with builtins;
      concatLists
      (concatLists [
        (concatMap mapFun
          (concatMap mapFun
            (concatMap mapFun
              (concatMap mapFun
                (concatMap mapFun
                  (concatMap mapFun
                    (attrValues Gui)))))))

        (concatMap mapFun
          (concatMap mapFun
            (concatMap mapFun
              (concatMap mapFun
                (concatMap mapFun
                  (concatMap mapFun
                    (attrValues TuiCli)))))))
      ]));
}