blob: 1f0147078346cf1fb02c02f4565a17b5ba922b83 (
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
|
{pkgs}: let
shellrcPkgs = {
shellrc-bash = pkgs.stdenvNoCC.mkDerivation {
name = "shellrc-bash";
src = ./.;
nativeBuildInputs = [pkgs.installShellFiles];
installPhase = ''
mkdir -p "$out/bin"
cat >"$out/bin/shellrc-bash" <<"EOF"
#!/usr/bin/env bash
for file in ${./bashrc.d}/* ${./shellrc.d}/*; do
echo "source $file;"
done
EOF
chmod +x "$out/bin/shellrc-bash"
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/bin"
cat >"$out/bin/shellrc-zsh" <<"EOF"
#!/usr/bin/env zsh
for file in ${./zshrc.d}/* ${./shellrc.d}/*; do
echo "source $file;"
done
EOF
chmod +x "$out/bin/shellrc-zsh"
for comp in zsh-completion/*; do
installShellCompletion --zsh --name "''${comp##*/}" "$comp"
done
'';
};
shellrc-user-setup = pkgs.writeScriptBin "shellrc-user-setup" ''
#!/usr/bin/env bash
cmdbash='eval $(shellrc-bash)'
cmdzsh='eval $(shellrc-zsh)'
if command -v shellrc-bash 2>/dev/null >&2 \
&& ! grep -qxF "$cmdbash" ~/.bashrc 2>/dev/null; then
echo "$cmdbash" >>~/.bashrc
fi
if command -v shellrc-zsh 2>/dev/null >&2 \
&& ! grep -qxF "$cmdzsh" ~/.zshrc 2>/dev/null; then
echo "$cmdzsh" >>~/.zshrc
fi
'';
};
in
shellrcPkgs
|