summary refs log tree commit diff
path: root/modules/programs/bash/bash.nix
blob: f7ac48ccb28e0c86e90ebb2742f22b2017d7f5b6 (plain) (blame)
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
# This module defines global configuration for the Bash shell, in
# particular /etc/bashrc and /etc/profile.

{config, pkgs, ...}:

let

  options = {

    environment.shellInit = pkgs.lib.mkOption {
        default = "";
        example = ''export PATH=/godi/bin/:$PATH'';
        description = "
          Script used to initialized user shell environments.
        ";
        merge = pkgs.lib.mergeStringOption;
      };

  };

in    
   
{
  require = [options];

  environment.etc =
    [ { # /etc/bashrc: script executed when the shell starts as a
        # non-login shell.  /etc/profile also sources this file, so
        # most global configuration (such as environment variables)
        # should go into this script.
        source = pkgs.substituteAll {
          src = ./bashrc.sh;
          systemPath = config.system.path;
          wrapperDir = config.security.wrapperDir;
          modulesTree = config.system.modulesTree;
          shellInit = config.environment.shellInit;
        };
        target = "bashrc";      
      }

      { # Script executed when the shell starts as a login shell.
        source = ./profile.sh;
        target = "profile";
      }

      { # Template for ~/.bashrc: script executed when the shell
        # starts as a non-login shell.
        source = ./bashrc-user.sh;
        target = "skel/.bashrc";
      }
      
      { # Configuration for readline in bash.
        source = ./inputrc;
        target = "inputrc";
      }
    ];

  system.build.binsh = pkgs.bashInteractive;
}