Skip to content

Commit

Permalink
godbolt: simplify wrapper script in Nix.
Browse files Browse the repository at this point in the history
  • Loading branch information
katrinafyi committed Oct 18, 2023
1 parent 9e8820c commit 471836f
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions basil/godbolt.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
fetchFromGitHub,
buildNpmPackage,
makeBinaryWrapper,
writeShellScript,
testers,
bash,
basil-tool,
Expand Down Expand Up @@ -65,32 +66,29 @@ let
rm -rf $lib/test $lib/node_modules/.cache
'';
};
in stdenv.mkDerivation {
in stdenv.mkDerivation rec {
pname = "godbolt";
version = ce-ailrst.version;

buildInputs = [ bash nodejs ];

unpackPhase = ":";

postInstall = ''
script = writeShellScript "godbolt-script"
''
lib=${ce-ailrst}/lib/node_modules/compiler-explorer
cd $lib
# env NODE_ENV=production $(NODE) $(NODE_ARGS) ./out/dist/app.js --webpackContent ./out/webpack/static $(EXTRA_ARGS)
export NODE_ENV=production
export COMPILER_CACHE="''${COMPILER_CACHE:-/tmp/compiler-cache}"
export LOCAL_STORAGE="''${LOCAL_STORAGE:-$HOME/.local/state/compiler-explorer}"
export BASIL_TOOL="''${BASIL_TOOL:-${basil-tool}/bin/basil-tool}"
exec ${nodejs}/bin/node $lib/out/dist/app.js --webpackContent $lib/out/webpack/static "$@"
'';

postInstall = ''
mkdir -p $out/bin
cat <<EOF > $out/bin/godbolt
#!/bin/bash
cd $lib
export NODE_ENV=production
export COMPILER_CACHE="\''${COMPILER_CACHE:-/tmp/compiler-cache}"
export LOCAL_STORAGE="\''${LOCAL_STORAGE:-\$HOME/.local/state/compiler-explorer}"
export BASIL_TOOL="\''${BASIL_TOOL:-${basil-tool}/bin/basil-tool}"
exec ${nodejs}/bin/node $lib/out/dist/app.js --webpackContent $lib/out/webpack/static "\$@"
EOF
chmod a+x $out/bin/godbolt
cp -v "${script}" $out/bin/godbolt
'';

passthru = {
Expand Down

0 comments on commit 471836f

Please sign in to comment.