aboutsummaryrefslogtreecommitdiff
path: root/pkgs.nix
blob: 0f5b6a8f80774a7274e495346de5499fe4873669 (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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
{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 = ./.;
      nativeBuildInputs = [pkgs.installShellFiles];
      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 = ./.;
      nativeBuildInputs = [pkgs.installShellFiles];
      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 profile in \''${=NIX_PROFILES}; do
          for sh in \$profile/etc/shellrc.d/*; do
            [ -r "\$sh" ] && . "\$sh"
          done
        done
        EOF
        for comp in zsh-completion/*; do
          installShellCompletion --zsh --name "''${comp##*/}" "$comp"
        done
      '';
    };
    shellrc-setup = pkgs.writeScriptBin "shellrc-setup" ''
      #!/usr/bin/env bash
      cat >~/.bashrc <<EOF
      for sh in ~/.nix-profile/etc/bashrc.d/*; do
        [ -r "\$sh" ] || continue
        source "\$sh"
      done
      EOF
      cat >~/.zshrc <<EOF
      for sh in ~/.nix-profile/etc/zshrc.d/*; do
        [ -r "\$sh" ] || continue
        source "\$sh"
      done
      EOF
    '';
  };
in
  shellrcPkgs