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