blob: 77b272c6e8e1727410d4e3d6f3254c37deb6d74b (
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
|
overlays: {
config,
lib,
pkgs,
...
}:
with lib; let
cnf = config.programs.shellrc;
zshEnable = config.programs.zsh.enable;
# Source all files in an appropriate shell directory in every profile
shellInit = dir: ''
for p in $NIX_PROFILES; do
for file in $p/etc/${dir}/*; do
[ -f "$file" ] || continue
. "$file"
done
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 = mkMerge [
{
nixpkgs.overlays = overlays;
programs.bash.interactiveShellInit = shellInit "bashrc.d";
programs.zsh.interactiveShellInit = mkIf zshEnable (shellInit "zshrc.d");
}
(mkIf cnf.enable {
environment.systemPackages =
[pkgs.shellrc-bash]
++ optional cnf.desktop pkgs.shellrc-desktop
++ optional zshEnable pkgs.shellrc-zsh;
# Disable default prompt as we have our own
programs.bash.promptInit = "";
programs.zsh.promptInit = ""; # Disable default prompt as we have our own
})
];
}
|