1{
2 gauge-unwrapped,
3 gauge,
4 makeWrapper,
5 stdenvNoCC,
6 lib,
7 xorg,
8 gaugePlugins,
9 plugins ? [ ],
10 runCommand,
11}:
12
13stdenvNoCC.mkDerivation {
14 pname = "gauge-wrapped";
15 inherit (gauge-unwrapped) version;
16
17 dontUnpack = true;
18
19 installPhase = ''
20 mkdir -p $out{bin,/share/gauge/{plugins,config}}
21 export NIX_GAUGE_IN_SANDBOX=true
22 export GAUGE_HOME=$(mktemp -d)
23
24 # run gauge to create config files
25 cd $(mktemp -d)
26 gauge init js || true
27
28 mkdir -p "$out/share/gauge/config"
29 mv "$GAUGE_HOME"/config/{gauge,template}.properties "$out/share/gauge/config"
30
31 export GAUGE_HOME="$out/share/gauge"
32
33 ${lib.concatMapStringsSep "\n" (plugin: ''
34 for plugin in "$(ls ${plugin}/share/gauge-plugins)"; do
35 echo Installing gauge plugin $plugin
36 mkdir -p "$GAUGE_HOME/plugins/$plugin"
37 # Use lndir here
38 # gauge checks for a directory, which fails if it's a symlink
39 # It's easier to link this with lndir, than patching an upstream dependency
40 lndir "${plugin}/share/gauge-plugins/$plugin" "$GAUGE_HOME/plugins/$plugin"
41 done
42 '') plugins}
43
44 makeWrapper ${gauge-unwrapped}/bin/gauge $out/bin/gauge \
45 --set GAUGE_HOME "$GAUGE_HOME"
46 '';
47
48 nativeBuildInputs = [
49 gauge-unwrapped
50 makeWrapper
51 xorg.lndir
52 ];
53
54 passthru = {
55 withPlugins = f: gauge.override { plugins = f gaugePlugins; };
56 fromManifest =
57 path:
58 let
59 manifest = lib.importJSON path;
60 requiredPlugins = with manifest; [ Language ] ++ Plugins;
61 manifestPlugins =
62 plugins:
63 map (name: plugins.${name} or (throw "Gauge plugin ${name} is not available!")) requiredPlugins;
64 in
65 gauge.withPlugins manifestPlugins;
66 # Builds gauge with all plugins and checks for successful installation
67 tests.allPlugins = gaugePlugins.testGaugePlugins {
68 plugins = lib.filter lib.isDerivation (lib.attrValues gaugePlugins);
69 };
70 };
71
72 inherit (gauge-unwrapped) meta;
73}