1 { lib, stdenv, fetchFromGitHub, nawk, groff, icon-lang, useIcon ? true }:
3 stdenv.mkDerivation (finalAttrs: {
7 src = fetchFromGitHub {
10 rev = "v${builtins.replaceStrings ["."] ["_"] finalAttrs.version}";
11 sha256 = "sha256-COcWyrYkheRaSr2gqreRRsz9SYRTX2PSl7km+g98ljs=";
14 sourceRoot = "${finalAttrs.src.name}/src";
22 substituteInPlace Makefile --replace 'strip' '${stdenv.cc.targetPrefix}strip'
23 substituteInPlace Makefile --replace '`./gitversion`' '${finalAttrs.src.rev}'
26 nativeBuildInputs = [ groff ] ++ lib.optionals useIcon [ icon-lang ];
27 buildInputs = [ nawk ];
30 mkdir -p "$out/lib/noweb"
33 makeFlags = lib.optionals useIcon [
36 ] ++ [ "CC=${stdenv.cc.targetPrefix}cc" ];
39 mkdir -p "$tex/tex/latex/noweb"
40 installFlagsArray+=( \
41 "BIN=${placeholder "out"}/bin" \
42 "ELISP=${placeholder "out"}/share/emacs/site-lisp" \
43 "LIB=${placeholder "out"}/lib/noweb" \
44 "MAN=${placeholder "out"}/share/man" \
45 "TEXINPUTS=${placeholder "tex"}/tex/latex/noweb" \
49 installTargets = [ "install-code" "install-tex" "install-elisp" ];
52 substituteInPlace "$out/bin/cpif" --replace "PATH=/bin:/usr/bin" ""
54 for f in $out/bin/no{index,roff,roots,untangle,web} \
55 $out/lib/noweb/to{ascii,html,roff,tex} \
56 $out/lib/noweb/{bt,empty}defn \
57 $out/lib/noweb/{noidx,pipedocs,unmarkup}; do
58 # NOTE: substituteInPlace breaks Icon binaries, so make sure the script
59 # uses (n)awk before calling.
60 if grep -q nawk "$f"; then
61 substituteInPlace "$f" --replace "nawk" "${nawk}/bin/nawk"
65 # HACK: This is ugly, but functional.
66 PATH=$out/bin:$PATH make -BC xdoc
67 make "''${installFlagsArray[@]}" install-man
69 ln -s "$tex" "$out/share/texmf"
72 outputs = [ "out" "tex" ];
76 pkgs = [ finalAttrs.finalPackage.tex ];
80 description = "A simple, extensible literate-programming tool";
81 homepage = "https://www.cs.tufts.edu/~nr/noweb";
82 license = licenses.bsd2;
83 maintainers = with maintainers; [ yurrriq ];
84 platforms = with platforms; linux ++ darwin;