Call Nx directly with --output-style=static flag instead of through npm scripts to completely bypass the pseudo terminal initialization that crashes in non-TTY environments. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
43 lines
970 B
Nix
43 lines
970 B
Nix
# Helper function to build Vite-based static apps
|
|
{ pkgs, src, npmDepsHash }:
|
|
|
|
{ name, buildScript, envVars ? {} }:
|
|
|
|
pkgs.buildNpmPackage {
|
|
pname = "imphnen-${name}";
|
|
version = "0.0.1";
|
|
inherit src npmDepsHash;
|
|
|
|
npmFlags = [ "--legacy-peer-deps" ];
|
|
makeCacheWritable = true;
|
|
|
|
nativeBuildInputs = with pkgs; [
|
|
nodejs_22
|
|
nodePackages.npm
|
|
];
|
|
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
export NX_DAEMON=false
|
|
export HOME=$TMPDIR
|
|
export CI=true
|
|
export NO_COLOR=1
|
|
export TERM=dumb
|
|
export NX_SKIP_NX_CACHE=true
|
|
export NX_TASKS_RUNNER_DYNAMIC_OUTPUT=false
|
|
export NX_NATIVE=false
|
|
${pkgs.lib.concatStringsSep "\n" (pkgs.lib.mapAttrsToList (k: v: "export ${k}=\"${v}\"") envVars)}
|
|
./node_modules/.bin/nx build ${name} --output-style=static
|
|
runHook postBuild
|
|
'';
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
mkdir -p $out
|
|
cp -r dist/apps/${name}/* $out/
|
|
runHook postInstall
|
|
'';
|
|
|
|
dontNpmBuild = true;
|
|
}
|