blob: 64040feb441cc5b04a1500f8c0bcf1018a963fd4 (
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
|
{
description = "Cynerd's shell configuration";
outputs = { self, nixpkgs }: {
nixosModule = { config, lib, pkgs, ... }:
with lib;
let
shellrc-completion = pkgs.stdenv.mkDerivation rec {
name = "shellrc-completion";
src = ./.;
nativeBuildInputs = [ pkgs.installShellFiles ];
installPhase = ''
for comp in bash-completion/*; do
installShellCompletion --bash --name "$${comp##*/}.bash" "$comp"
done
for comp in zsh-completion/*; do
installShellCompletion --zsh --name "$${comp##*/}" "$comp"
done
'';
};
in {
options = {
programs.shellrc = {
enable = mkOption {
type = types.bool;
default = true;
description = "If shellrc should be enabled.";
};
desktop = mkOption {
type = types.bool;
default = false;
description = "If shellrc's desktop specific files should be used.";
};
};
};
config = mkIf config.programs.shellrc.enable {
environment.interactiveShellInit = ''
for sh in ${./shellrc.d}/*; do
[ -r "$sh" ] && . "$sh"
done
'' + optionalString config.programs.shellrc.desktop ''
for sh in ${./shellrc-desktop.d}/*; do
[ -r "$sh" ] && . "$sh"
done
'';
programs.bash.interactiveShellInit = ''
for sh in ${./bashrc.d}/*; do
[ -r "$sh" ] && . "$sh"
done
'';
programs.bash.promptInit = ""; # Disable default prompt as we have our own
programs.zsh.interactiveShellInit = mkIf config.programs.zsh.enable ''
for sh in ${./zshrc.d}/*; do
[ -r "$sh" ] && . "$sh"
done
'';
programs.zsh.promptInit = ""; # Disable default prompt as we have our own
environment.systemPackages = [
shellrc-completion
];
};
};
};
}
|