DEVELOPMENT ENVIRONMENT

~liljamo/nix-arta

ref: 8c36e1a019c5bde84a09768918dd4d3ff2432db5 nix-arta/modules/shell.nix -rw-r--r-- 1.7 KiB
8c36e1a0Jonni Liljamo feat: alice initial a day ago
                                                                                
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/*
Opinionated shell environment.
*/
{
  flake.modules.nixos.shell = {pkgs, ...}: {
    environment.systemPackages = with pkgs; [
      btop
      carapace
      elvish
      fd
      ripgrep
      silicon
      sl
    ];

    programs.direnv = {
      enable = true;
      nix-direnv.enable = true;
      silent = true;
    };
  };

  flake.modules.homeManager.shell = {...}: {
    home.file = {
      ".config/elvish/lib/direnv.elv" = {
        executable = true;
        text = ''
          ## Hook for direnv as of direnv 2.34.0
          set @edit:before-readline = $@edit:before-readline {
            try {
              var m = [("direnv" export elvish | from-json)]
              if (> (count $m) 0) {
                set m = (all $m)
                keys $m | each { |k|
                  if $m[$k] {
                    set-env $k $m[$k]
                  } else {
                    unset-env $k
                  }
                }
              }
            } catch e {
              echo $e
            }
          }
        '';
      };
      ".config/elvish/rc.elv" = {
        executable = true;
        text = ''
          #!/usr/bin/env elvish
          use direnv
          eval (starship init elvish)
          eval (carapace _carapace|slurp)
        '';
      };
    };
    programs.bash = {
      enable = true;
      bashrcExtra = ''
        eval "$(direnv hook bash)"
        eval "$(starship init bash)"
      '';
    };
    programs.starship = {
      enable = true;
      settings = {
        add_newline = false;
        scan_timeout = 10;
        shell = {
          disabled = false;
          bash_indicator = "bsh";
          elvish_indicator = "elv";
        };
      };
    };
  };
}