# Custom package to quickly set up development environments for different
# programing languages

{ config, lib, pkgs, ... }:

let
  cfg = config.samfelag.modules.dev.devenv;
  i3Cfg = config.samfelag.modules.desktop.i3;
in
{
  options.samfelag.modules.dev.devenv = {
    enable = lib.mkEnableOption "devenv";
  };
  config = lib.mkIf cfg.enable {

    hm.xdg.dataFile."devenv/devenv.sh".source = ../../data/devenv/devenv.sh;
    hm.xdg.dataFile."devenv/templates".source = ../../data/devenv/templates;

    hm.programs.zsh.shellAliases = {
      devenv = "source $HOME/.local/share/devenv/devenv.sh";
    };

    # TODO: This assumes we have alacritty and a python39 devenv set up (may want to fix this at some point)
    samfelag.modules.desktop.i3.extraKeybindings = lib.mkIf i3Cfg.enable {
      "${i3Cfg.mod}+Shift+P" =  "exec ${pkgs.alacritty}/bin/alacritty -t floating-term -e zsh -c \"direnv exec ~/sandbox/python39 ipython\"";
    };

    # - Requirements -----------------------------
    samfelag.modules.dev.direnv.enable = true;

  };
}
