Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at litex 85 lines 2.4 kB view raw
1{ lib, stdenv, fetchFromGitHub, nawk, groff, icon-lang, useIcon ? true }: 2 3stdenv.mkDerivation (finalAttrs: rec { 4 pname = "noweb"; 5 version = "2.12"; 6 7 src = fetchFromGitHub { 8 owner = "nrnrnr"; 9 repo = "noweb"; 10 rev = "v${builtins.replaceStrings ["."] ["_"] version}"; 11 sha256 = "1160i2ghgzqvnb44kgwd6s3p4jnk9668rmc15jlcwl7pdf3xqm95"; 12 }; 13 14 sourceRoot = "source/src"; 15 16 patches = [ 17 # Remove FAQ 18 ./no-FAQ.patch 19 ]; 20 21 postPatch = '' 22 substituteInPlace Makefile --replace 'strip' '${stdenv.cc.targetPrefix}strip' 23 ''; 24 25 nativeBuildInputs = [ groff ] ++ lib.optionals useIcon [ icon-lang ]; 26 buildInputs = [ nawk ]; 27 28 preBuild = '' 29 mkdir -p "$out/lib/noweb" 30 ''; 31 32 makeFlags = lib.optionals useIcon [ 33 "LIBSRC=icon" 34 "ICONC=icont" 35 ] ++ [ "CC=${stdenv.cc.targetPrefix}cc" ]; 36 37 preInstall = '' 38 mkdir -p "$tex/tex/latex/noweb" 39 installFlagsArray+=( \ 40 "BIN=${placeholder "out"}/bin" \ 41 "ELISP=${placeholder "out"}/share/emacs/site-lisp" \ 42 "LIB=${placeholder "out"}/lib/noweb" \ 43 "MAN=${placeholder "out"}/share/man" \ 44 "TEXINPUTS=${placeholder "tex"}/tex/latex/noweb" \ 45 ) 46 ''; 47 48 installTargets = [ "install-code" "install-tex" "install-elisp" ]; 49 50 postInstall = '' 51 substituteInPlace "$out/bin/cpif" --replace "PATH=/bin:/usr/bin" "" 52 53 for f in $out/bin/no{index,roff,roots,untangle,web} \ 54 $out/lib/noweb/to{ascii,html,roff,tex} \ 55 $out/lib/noweb/{bt,empty}defn \ 56 $out/lib/noweb/{noidx,pipedocs,unmarkup}; do 57 # NOTE: substituteInPlace breaks Icon binaries, so make sure the script 58 # uses (n)awk before calling. 59 if grep -q nawk "$f"; then 60 substituteInPlace "$f" --replace "nawk" "${nawk}/bin/nawk" 61 fi 62 done 63 64 # HACK: This is ugly, but functional. 65 PATH=$out/bin:$PATH make -BC xdoc 66 make "''${installFlagsArray[@]}" install-man 67 68 ln -s "$tex" "$out/share/texmf" 69 ''; 70 71 outputs = [ "out" "tex" ]; 72 73 passthru = { 74 tlType = "run"; 75 pkgs = [ finalAttrs.finalPackage.tex ]; 76 }; 77 78 meta = with lib; { 79 description = "A simple, extensible literate-programming tool"; 80 homepage = "https://www.cs.tufts.edu/~nr/noweb"; 81 license = licenses.bsd2; 82 maintainers = with maintainers; [ yurrriq ]; 83 platforms = with platforms; linux ++ darwin; 84 }; 85})