summaryrefslogtreecommitdiffstats
path: root/modules/programs/devenv.nix
blob: 4452b2aad1870fb7bb5f7b1168278b6266e6c6c1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
{
  config,
  lib,
  pkgs,
  ...
}:

let
  cfg = config.programs.devenv;

  hook = shell: "${lib.getExe cfg.package} hook ${shell}";
in
{
  meta.maintainers = [
    lib.maintainers.domenkozar or "domenkozar"
    lib.maintainers.sandydoo or "sandydoo"
    lib.maintainers.anish or "anish"
  ];

  options.programs.devenv = {
    enable = lib.mkEnableOption "devenv, fast, declarative, reproducible and composable developer environments";

    package = lib.mkPackageOption pkgs "devenv" { };

    enableBashIntegration = lib.mkEnableOption "auto-activation of devenv environments in Bash" // {
      default = true;
    };

    enableFishIntegration = lib.mkEnableOption "auto-activation of devenv environments in Fish" // {
      default = true;
    };

    enableZshIntegration = lib.mkEnableOption "auto-activation of devenv environments in Zsh" // {
      default = true;
    };
  };

  config = lib.mkIf cfg.enable {
    environment.systemPackages = [ cfg.package ];

    programs.bash.interactiveShellInit = lib.mkIf cfg.enableBashIntegration ''
      eval "$(${hook "bash"})"
    '';

    programs.fish.interactiveShellInit = lib.mkIf cfg.enableFishIntegration ''
      ${hook "fish"} | source
    '';

    programs.zsh.interactiveShellInit = lib.mkIf cfg.enableZshIntegration ''
      eval "$(${hook "zsh"})"
    '';
  };
}