1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 asciidoctor,
6 gawk,
7 gnused,
8 runtimeShell,
9 binlore,
10 esh,
11}:
12
13stdenv.mkDerivation rec {
14 pname = "esh";
15 version = "0.1.1";
16
17 src = fetchFromGitHub {
18 owner = "jirutka";
19 repo = "esh";
20 rev = "v${version}";
21 sha256 = "1ddaji5nplf1dyvgkrhqjy8m5djaycqcfhjv30yprj1avjymlj6w";
22 };
23
24 nativeBuildInputs = [ asciidoctor ];
25
26 buildInputs = [
27 gawk
28 gnused
29 ];
30
31 makeFlags = [
32 "prefix=$(out)"
33 "DESTDIR="
34 ];
35
36 postPatch = ''
37 patchShebangs .
38 substituteInPlace esh \
39 --replace '"/bin/sh"' '"${runtimeShell}"' \
40 --replace '"awk"' '"${gawk}/bin/awk"' \
41 --replace 'sed' '${gnused}/bin/sed'
42 substituteInPlace tests/test-dump.exp \
43 --replace '#!/bin/sh' '#!${runtimeShell}'
44 '';
45
46 doCheck = true;
47 checkTarget = "test";
48
49 # working around a bug in file. Was fixed in
50 # file 5.41-5.43 but regressed in 5.44+
51 # see https://bugs.astron.com/view.php?id=276
52 # "can" verdict because of `-s SHELL` arg
53 passthru.binlore.out = binlore.synthesize esh ''
54 execer can bin/esh
55 '';
56
57 meta = with lib; {
58 description = "Simple templating engine based on shell";
59 mainProgram = "esh";
60 homepage = "https://github.com/jirutka/esh";
61 license = licenses.mit;
62 maintainers = with maintainers; [ mnacamura ];
63 platforms = platforms.unix;
64 };
65}