aboutsummaryrefslogtreecommitdiff
path: root/pkgs.nix
blob: f171859e21bc2797ff9ebd88175e45526391d74c (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
54
55
56
57
58
59
60
61
{pkgs}: let
  shellrcPkgs = {
    shellrc-generic = pkgs.stdenvNoCC.mkDerivation {
      name = "shellrc-generic";
      src = ./.;
      installPhase = ''
        mkdir -p "$out/etc/shellrc.d"
        cp -r ./shellrc.d/. "$out/etc/shellrc.d/"
      '';
    };
    shellrc-desktop = pkgs.stdenvNoCC.mkDerivation {
      name = "shellrc-desktop";
      src = ./.;
      installPhase = ''
        mkdir -p "$out/etc/shellrc.d"
        cp -r ./shellrc-desktop.d/. "$out/etc/shellrc.d/"
      '';
    };
    shellrc-bash = pkgs.stdenvNoCC.mkDerivation {
      name = "shellrc-bash";
      src = ./.;
      propagatedBuildInputs = [shellrcPkgs.shellrc-generic];
      installPhase = ''
        mkdir -p "$out/etc/bashrc.d"
        cp -r ./bashrc.d/. "$out/etc/bashrc.d/"
        cat >"$out/etc/bashrc.d/shellrc" <<EOF
        # Load ShellRC files
        for p in $NIX_PROFILES; do
          for sh in $p/etc/shellrc.d/*; do
            [ -r "\$sh" ] && . "\$sh"
          done
        done
        EOF
        for comp in bash-completion/*; do
          installShellCompletion --bash --name "''${comp##*/}.bash" "$comp"
        done
      '';
    };
    shellrc-zsh = pkgs.stdenvNoCC.mkDerivation {
      name = "shellrc-zsh";
      src = ./.;
      propagatedBuildInputs = [shellrcPkgs.shellrc-generic];
      installPhase = ''
        mkdir -p "$out/etc/zshrc.d"
        cp -r ./zshrc.d/. "$out/etc/zshrc.d/"
        cat >"$out/etc/zshrc.d/shellrc" <<EOF
        # Load ShellRC files
        for p in $NIX_PROFILES; do
          for sh in $p/etc/shellrc.d/*; do
            [ -r "\$sh" ] && . "\$sh"
          done
        done
        EOF
        for comp in zsh-completion/*; do
          installShellCompletion --zsh --name "''${comp##*/}" "$comp"
        done
      '';
    };
  };
in
  shellrcPkgs