nixpkgs/pkgs/development/tools/gauge/wrapper.nix
Marie Ramlow 86913e049d gauge: add wrapper
Adds a wrapper to the gauge package, which allows installing plugins declaratively with nix.
2024-04-24 09:22:38 +02:00

49 lines
1.3 KiB
Nix

{ gauge-unwrapped
, makeWrapper
, stdenvNoCC
, lib
, xorg
, gaugePlugins
, plugins ? []
}:
stdenvNoCC.mkDerivation {
pname = "gauge-wrapped";
inherit (gauge-unwrapped) version;
dontUnpack = true;
installPhase = ''
mkdir -p $out{bin,/share/gauge/{plugins,config}}
export NIX_GAUGE_IN_SANDBOX=true
export GAUGE_HOME=$(mktemp -d)
# run gauge to create config files
cd $(mktemp -d)
gauge init js || true
mkdir -p "$out/share/gauge/config"
mv "$GAUGE_HOME"/config/{gauge,template}.properties "$out/share/gauge/config"
export GAUGE_HOME="$out/share/gauge"
${lib.concatMapStringsSep "\n" (plugin: ''
for plugin in "$(ls ${plugin}/share/gauge-plugins)"; do
echo Installing gauge plugin $plugin
mkdir -p "$GAUGE_HOME/plugins/$plugin"
# Use lndir here
# gauge checks for a directory, which fails if it's a symlink
# It's easier to link this with lndir, than patching an upstream dependency
lndir "${plugin}/share/gauge-plugins/$plugin" "$GAUGE_HOME/plugins/$plugin"
done
'') plugins}
makeWrapper ${gauge-unwrapped}/bin/gauge $out/bin/gauge \
--set GAUGE_HOME "$GAUGE_HOME"
'';
nativeBuildInputs = [ gauge-unwrapped makeWrapper xorg.lndir ];
inherit (gauge-unwrapped) meta;
}