1{ lib
2, stdenv
3, buildPackages
4, pkg-config
5, fetchurl
6, libedit
7, runCommand
8, dash
9}:
10
11stdenv.mkDerivation rec {
12 pname = "dash";
13 version = "0.5.12";
14
15 src = fetchurl {
16 url = "http://gondor.apana.org.au/~herbert/dash/files/${pname}-${version}.tar.gz";
17 sha256 = "sha256-akdKxG6LCzKRbExg32lMggWNMpfYs4W3RQgDDKSo8oo=";
18 };
19
20 strictDeps = true;
21
22 nativeBuildInputs = lib.optionals stdenv.hostPlatform.isStatic [ pkg-config ];
23
24 depsBuildBuild = [ buildPackages.stdenv.cc ];
25 buildInputs = [ libedit ];
26
27 configureFlags = [ "--with-libedit" ];
28 preConfigure = lib.optional stdenv.hostPlatform.isStatic ''
29 export LIBS="$(''${PKG_CONFIG:-pkg-config} --libs --static libedit)"
30 '';
31
32 enableParallelBuilding = true;
33
34 meta = with lib; {
35 homepage = "http://gondor.apana.org.au/~herbert/dash/";
36 description = "A POSIX-compliant implementation of /bin/sh that aims to be as small as possible";
37 platforms = platforms.unix;
38 license = with licenses; [ bsd3 gpl2 ];
39 };
40
41 passthru = {
42 shellPath = "/bin/dash";
43 tests = {
44 "execute-simple-command" = runCommand "${pname}-execute-simple-command" { } ''
45 mkdir $out
46 ${dash}/bin/dash -c 'echo "Hello World!" > $out/success'
47 [ -s $out/success ]
48 grep -q "Hello World" $out/success
49 '';
50 };
51 };
52}