1{
2 stdenv,
3}@initAttrs:
4
5drvArgs:
6
7(stdenv.mkDerivation drvArgs).overrideAttrs (
8 finalAttrs:
9 {
10 name ? "${finalAttrs.pname}-${finalAttrs.version}",
11 vocabName ? finalAttrs.pname or name,
12 vocabRoot ? "extra",
13 # Runtime libraries needed to run this vocab, handed to runtime wrapper
14 extraLibs ? [ ],
15 # Extra vocabularies, handed to runtime wrapper
16 extraVocabs ? [ ],
17 # Extra binaries in PATH, handed to runtime wrapper
18 extraPaths ? [ ],
19 ...
20 }@attrs:
21 {
22 inherit vocabName vocabRoot;
23 installPhase =
24 # Default installer
25 # 1. If lib/factor/<vocabRoot>/<vocabName> exists, copy all vocab roots
26 # under lib/factor/* to out/.
27 # 2. If <vocabName> exists, copy all directories next to <vocabName> to
28 # out/.
29 # These two carry over package-defined vocabs that the name-giving vocab
30 # depends on.
31 # 3. Otherwise, copy all .factor and .txt files to out/. For simple
32 # single-vocab packages.
33 attrs.installPhase or ''
34 runHook preInstall
35 mkdir -p "$out/lib/factor/${finalAttrs.vocabRoot}/${finalAttrs.vocabName}"
36 if [ -d "lib/factor/${finalAttrs.vocabRoot}/${finalAttrs.vocabName}" ]; then
37 find lib/factor -mindepth 1 -maxdepth 1 -type d -exec \
38 cp -r -t "$out/lib/factor" {} \+
39 elif [ -d "${finalAttrs.vocabName}" ]; then
40 fname="${finalAttrs.vocabName}"
41 base=$(basename "${finalAttrs.vocabName}")
42 root=''${fname%$base}
43 root=''${root:-.}
44 find "$root" -mindepth 1 -maxdepth 1 -type d \
45 -not \( -name bin -or -name doc -or -name lib \) -exec \
46 cp -r -t "$out/lib/factor/${finalAttrs.vocabRoot}" {} \+
47 else
48 cp *.factor *.txt "$out/lib/factor/${finalAttrs.vocabRoot}/${finalAttrs.vocabName}"
49 fi
50 runHook postInstall
51 '';
52
53 passthru = {
54 inherit extraLibs extraVocabs extraPaths;
55 };
56
57 meta = attrs.meta or { };
58 }
59)