1{ stdenv, fetchurl, readline ? null, interactive ? false, texinfo ? null, binutils ? null, bison }:
2
3assert interactive -> readline != null;
4assert stdenv.isDarwin -> binutils != null;
5
6let
7 version = "4.3";
8 realName = "bash-${version}";
9 shortName = "bash43";
10 baseConfigureFlags = if interactive then "--with-installed-readline" else "--disable-readline";
11 sha256 = "1m14s1f61mf6bijfibcjm9y6pkyvz6gibyl8p4hxq90fisi8gimg";
12in
13
14stdenv.mkDerivation rec {
15 name = "${realName}-p${toString (builtins.length patches)}";
16
17 src = fetchurl {
18 url = "mirror://gnu/bash/${realName}.tar.gz";
19 inherit sha256;
20 };
21
22 outputs = [ "out" "doc" ];
23
24 NIX_CFLAGS_COMPILE = ''
25 -DSYS_BASHRC="/etc/bashrc"
26 -DSYS_BASH_LOGOUT="/etc/bash_logout"
27 -DDEFAULT_PATH_VALUE="/no-such-path"
28 -DSTANDARD_UTILS_PATH="/no-such-path"
29 -DNON_INTERACTIVE_LOGIN_SHELLS
30 -DSSH_SOURCE_BASHRC
31 '';
32
33 patchFlags = "-p0";
34
35 patches =
36 (let
37 patch = nr: sha256:
38 fetchurl {
39 url = "mirror://gnu/bash/${realName}-patches/${shortName}-${nr}";
40 inherit sha256;
41 };
42 in
43 import ./bash-4.3-patches.nix patch)
44 ++ stdenv.lib.optional stdenv.isCygwin ./cygwin-bash-4.3.33-1.src.patch;
45
46 crossAttrs = {
47 configureFlags = baseConfigureFlags +
48 " bash_cv_job_control_missing=nomissing bash_cv_sys_named_pipes=nomissing" +
49 stdenv.lib.optionalString stdenv.isCygwin ''
50 --without-libintl-prefix --without-libiconv-prefix
51 --with-installed-readline
52 bash_cv_dev_stdin=present
53 bash_cv_dev_fd=standard
54 bash_cv_termcap_lib=libncurses
55 '';
56 };
57
58 configureFlags = baseConfigureFlags;
59
60 # Note: Bison is needed because the patches above modify parse.y.
61 nativeBuildInputs = [bison]
62 ++ stdenv.lib.optional (texinfo != null) texinfo
63 ++ stdenv.lib.optional interactive readline
64 ++ stdenv.lib.optional stdenv.isDarwin binutils;
65
66 # Bash randomly fails to build because of a recursive invocation to
67 # build `version.h'.
68 enableParallelBuilding = false;
69
70 postInstall = ''
71 # Add an `sh' -> `bash' symlink.
72 ln -s bash "$out/bin/sh"
73 '';
74
75 meta = {
76 homepage = http://www.gnu.org/software/bash/;
77 description =
78 "GNU Bourne-Again Shell, the de facto standard shell on Linux" +
79 (if interactive then " (for interactive use)" else "");
80
81 longDescription = ''
82 Bash is the shell, or command language interpreter, that will
83 appear in the GNU operating system. Bash is an sh-compatible
84 shell that incorporates useful features from the Korn shell
85 (ksh) and C shell (csh). It is intended to conform to the IEEE
86 POSIX P1003.2/ISO 9945.2 Shell and Tools standard. It offers
87 functional improvements over sh for both programming and
88 interactive use. In addition, most sh scripts can be run by
89 Bash without modification.
90 '';
91
92 license = stdenv.lib.licenses.gpl3Plus;
93
94 platforms = stdenv.lib.platforms.all;
95
96 maintainers = [ stdenv.lib.maintainers.simons ];
97 };
98
99 passthru = {
100 shellPath = "/bin/bash";
101 };
102}