Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ lib, stdenv 2, buildPackages 3, fetchurl 4, binutils ? null 5, bison 6, util-linux 7 8 # patch for cygwin requires readline support 9, interactive ? stdenv.isCygwin 10, readline81 ? null 11, withDocs ? false 12, texinfo ? null 13, forFHSEnv ? false 14}: 15 16with lib; 17 18assert interactive -> readline81 != null; 19assert withDocs -> texinfo != null; 20assert stdenv.hostPlatform.isDarwin -> binutils != null; 21let 22 upstreamPatches = import ./bash-5.1-patches.nix (nr: sha256: fetchurl { 23 url = "mirror://gnu/bash/bash-5.1-patches/bash51-${nr}"; 24 inherit sha256; 25 }); 26in 27stdenv.mkDerivation rec { 28 name = "bash-${optionalString interactive "interactive-"}${version}-p${toString (builtins.length upstreamPatches)}"; 29 version = "5.1"; 30 31 src = fetchurl { 32 url = "mirror://gnu/bash/bash-${version}.tar.gz"; 33 sha256 = "1alv68wplnfdm6mh39hm57060xgssb9vqca4yr1cyva0c342n0fc"; 34 }; 35 36 hardeningDisable = [ "format" ]; 37 38 outputs = [ "out" "dev" "man" "doc" "info" ]; 39 40 NIX_CFLAGS_COMPILE = '' 41 -DSYS_BASHRC="/etc/bashrc" 42 -DSYS_BASH_LOGOUT="/etc/bash_logout" 43 '' + optionalString (!forFHSEnv) '' 44 -DDEFAULT_PATH_VALUE="/no-such-path" 45 -DSTANDARD_UTILS_PATH="/no-such-path" 46 '' + '' 47 -DNON_INTERACTIVE_LOGIN_SHELLS 48 -DSSH_SOURCE_BASHRC 49 ''; 50 51 patchFlags = [ "-p0" ]; 52 53 patches = upstreamPatches 54 ++ [ ./pgrp-pipe-5.1.patch ]; 55 56 configureFlags = [ 57 (if interactive then "--with-installed-readline" else "--disable-readline") 58 ] ++ optionals (stdenv.hostPlatform != stdenv.buildPlatform) [ 59 "bash_cv_job_control_missing=nomissing" 60 "bash_cv_sys_named_pipes=nomissing" 61 "bash_cv_getcwd_malloc=yes" 62 ] ++ optionals stdenv.hostPlatform.isCygwin [ 63 "--without-libintl-prefix" 64 "--without-libiconv-prefix" 65 "--with-installed-readline" 66 "bash_cv_dev_stdin=present" 67 "bash_cv_dev_fd=standard" 68 "bash_cv_termcap_lib=libncurses" 69 ] ++ optionals (stdenv.hostPlatform.libc == "musl") [ 70 "--without-bash-malloc" 71 "--disable-nls" 72 ]; 73 74 strictDeps = true; 75 # Note: Bison is needed because the patches above modify parse.y. 76 depsBuildBuild = [ buildPackages.stdenv.cc ]; 77 nativeBuildInputs = [ bison ] 78 ++ optional withDocs texinfo 79 ++ optional stdenv.hostPlatform.isDarwin binutils; 80 81 buildInputs = optional interactive readline81; 82 83 enableParallelBuilding = true; 84 85 makeFlags = optional stdenv.hostPlatform.isCygwin [ 86 "LOCAL_LDFLAGS=-Wl,--export-all,--out-implib,libbash.dll.a" 87 "SHOBJ_LIBS=-lbash" 88 ]; 89 90 checkInputs = [ util-linux ]; 91 doCheck = false; # dependency cycle, needs to be interactive 92 93 postInstall = '' 94 ln -s bash "$out/bin/sh" 95 rm -f $out/lib/bash/Makefile.inc 96 ''; 97 98 postFixup = 99 if interactive 100 then '' 101 substituteInPlace "$out/bin/bashbug" \ 102 --replace '#!/bin/sh' "#!$out/bin/bash" 103 '' 104 # most space is taken by locale data 105 else '' 106 rm -rf "$out/share" "$out/bin/bashbug" 107 ''; 108 109 meta = with lib; { 110 homepage = "https://www.gnu.org/software/bash/"; 111 description = 112 "GNU Bourne-Again Shell, the de facto standard shell on Linux" + 113 (if interactive then " (for interactive use)" else ""); 114 115 longDescription = '' 116 Bash is the shell, or command language interpreter, that will 117 appear in the GNU operating system. Bash is an sh-compatible 118 shell that incorporates useful features from the Korn shell 119 (ksh) and C shell (csh). It is intended to conform to the IEEE 120 POSIX P1003.2/ISO 9945.2 Shell and Tools standard. It offers 121 functional improvements over sh for both programming and 122 interactive use. In addition, most sh scripts can be run by 123 Bash without modification. 124 ''; 125 126 license = licenses.gpl3Plus; 127 128 platforms = platforms.all; 129 130 maintainers = with maintainers; [ dtzWill ]; 131 132 mainProgram = "bash"; 133 }; 134 135 passthru = { 136 shellPath = "/bin/bash"; 137 }; 138}