#
# Our various packages; generated for each system.
#
{
  flake-utils,
  deprekages,
  nixpkgs,
}:

flake-utils.lib.eachDefaultSystem (
  system:
  let
    pkgs = import nixpkgs {
      inherit system;
      config.allowUnfree = true;
    };
    callPackage = pkgs.callPackage;
  in
  {
    # The packages themselves,
    packages = rec {
      # fonts
      font-monolisa = callPackage ./fonts/monolisa.nix { };
      font-codicon = callPackage ./fonts/codicon.nix { };
      font-manrope = callPackage ./fonts/manrope.nix { };

      # scientific things
      ffts = callPackage ./packages/scopehal-apps/ffts.nix { };
      libsigrok4DSL = callPackage ./packages/scopehal-apps/libsigrok4DSL.nix { };
      vulkan-sdk = callPackage ./packages/scopehal-apps/vulkan-sdk.nix { };
      scopehal-apps = callPackage ./packages/scopehal-apps { deprekages = deprekages.${system}; };
      scopehal-sigrok-bridge = callPackage ./packages/scopehal-apps/sigrok-bridge.nix {
        deprekages = deprekages.${system};
      };

      # apps
      navit = callPackage ./packages/navit.nix { };
      navit-with-maps = callPackage ./packages/navit.nix { with_maps = true; };
      binary-ninja = callPackage ./packages/binary-ninja.nix { };
      argos = callPackage ./packages/argos.nix { };
      todoist-electron = callPackage ./packages/todoist-electron.nix { };
      home-assistant-desktop = callPackage ./packages/home-assistant-desktop/x86_64-linux.nix { };
      flexbv = callPackage ./packages/flexbv.nix { };
      glowing-bear-desktop = callPackage ./packages/glowing-bear-desktop.nix { };
      hrvst-cli = callPackage ./packages/hrvst-cli { };
      notion-app = callPackage ./packages/notion-app { inherit _7zz; };
      gfn-electron = callPackage ./packages/geforce-now { };

      # utilities
      ykush = callPackage ./packages/ykush.nix { };
      wsl-gpg-forward = callPackage ./windows/gpg-forward.nix { };
      oxfs = callPackage ./packages/oxfs.nix { };
      pcsclite = callPackage ./packages/pcsclite.nix { };
      age-plugin-yubikey = callPackage ./packages/age-plugin-yubikey.nix { inherit pcsclite; };
      humanfx = callPackage ./packages/humanfx { };
      clipboard-sync = callPackage ./packages/clipboard-sync.nix { };
      vsmartcard = callPackage ./packages/vsmartcard.nix { };
      pcsc-relay = callPackage ./packages/pcsc-relay.nix { };
      neard = callPackage ./packages/neard.nix { };
      libnfc = callPackage ./packages/libnfc.nix { inherit libnfc-nci; };
      jadx = callPackage ./packages/jadx { };
      firefox-webserial = callPackage ./packages/firefox-webserial { inherit ws-server; };
      ryzen-ppd = callPackage ./packages/ryzen-ppd { };
      avbroot = callPackage ./packages/avbroot { };
      okc-agents = callPackage ./packages/okc-agents.nix { };
      _7zz = pkgs._7zz.override { useUasm = true; };
      mergiraf = callPackage ./packages/mergiraf.nix { };

      # libraries
      libnfc-nci = callPackage ./packages/libnfc-nci { };
      ws-server = callPackage ./packages/ws-server { };
      rubyPackages = callPackage ./packages/ruby-gems.nix { };

      # jetbrains products
      jetbrains-jdk = callPackage ./packages/jetbrains-jdk.nix { };
      jetbrains = import ./packages/jetbrains.nix {
        inherit pkgs;
        jdk = jetbrains-jdk;
      };

      # kernel modules
      linuxPackages_i915-sriov = callPackage ./packages/i915-sriov/kernel.nix { };
      i915-sriov = callPackage ./packages/i915-sriov { linuxPackages = linuxPackages_i915-sriov; };
      linux-nfc-lenovo = callPackage ./packages/linux-nfc-lenovo { };

      # hw support
      dell = callPackage ./packages/dell { };

      # udev rules~
      t5-udev-rules = callPackage ./packages/t5-udev-rules { };
      ykush-udev-rules = callPackage ./packages/ykush-udev-rules { };
      dreamsource-udev-rules = callPackage ./packages/dreamsource-udev-rules { };
      hantek-udev-rules = callPackage ./packages/hantek-udev-rules { };
      linux-nfc-lenovo-udev-rules = callPackage ./packages/linux-nfc-lenovo/udev.nix { };

      # weechat
      weechat-discord = callPackage ./packages/weechat-discord { };

      # kakoune
      kak-tree-sitter = callPackage ./packages/kak-tree-sitter { };

      # vscode
      vscode-extensions = callPackage ./packages/vscode-extensions.nix { };

      # xonsh and xontribs
      xonsh-with-xontribs = pkgs.xonsh.override {
        extraPackages = pythonPackages: [
          (callPackage ./packages/xontrib-whole-word-jumping.nix { })
          (callPackage ./packages/xontrib-term-integrations.nix { })
          (callPackage ./packages/xontrib-sh.nix { })
        ];
      };
    };
  }
)
