145 lines
3.0 KiB
Nix
145 lines
3.0 KiB
Nix
{
|
|
lib,
|
|
bun,
|
|
pkgs,
|
|
deps,
|
|
fable,
|
|
version,
|
|
netrcConfig,
|
|
stdenvNoCC,
|
|
nix-gitignore,
|
|
packageSources,
|
|
dotnet-sdk,
|
|
dotnet-runtime,
|
|
buildDotnetModule,
|
|
writableTmpDirAsHomeHook,
|
|
}:
|
|
let
|
|
root = ../../.;
|
|
|
|
src = nix-gitignore.gitignoreSource [ ] root;
|
|
# src = lib.cleanSource root;
|
|
|
|
pname = "Atlantis";
|
|
|
|
nodeDeps = stdenvNoCC.mkDerivation {
|
|
inherit version;
|
|
pname = "${pname}-node-deps";
|
|
|
|
nativeBuildInputs = [
|
|
bun
|
|
writableTmpDirAsHomeHook
|
|
];
|
|
|
|
src = lib.fileset.toSource {
|
|
inherit root;
|
|
fileset = lib.fileset.unions [
|
|
../../package.json
|
|
../../bun.lock
|
|
];
|
|
};
|
|
|
|
dontConfigure = true;
|
|
|
|
# Only install dependencies, don't build
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
|
|
export BUN_INSTALL_CACHE_DIR=$(mktemp -d)
|
|
|
|
# Disable post-install scripts to avoid shebang issues
|
|
bun install \
|
|
--frozen-lockfile \
|
|
--ignore-scripts \
|
|
--backend copyfile \
|
|
--no-progress \
|
|
--force
|
|
|
|
runHook postBuild
|
|
'';
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
mkdir -p $out
|
|
cp -r node_modules $out/
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
# Required else we get errors that our fixed-output derivation references store paths
|
|
dontFixup = true;
|
|
|
|
outputHashMode = "recursive";
|
|
outputHashAlgo = "sha256";
|
|
# NOTE: Empty this when a new dependency is added
|
|
outputHash = "sha256-T9X1EFeoNV3yKdVUIMOvaYtja6XR0fne6CDkKHD5rhE=";
|
|
};
|
|
|
|
in
|
|
buildDotnetModule {
|
|
inherit dotnet-sdk dotnet-runtime;
|
|
inherit src version;
|
|
pname = "${pname}-Client";
|
|
|
|
projectFile = "src/Atlantis/src/Client/Client.fsproj";
|
|
dotnetRestoreFlags = "--force-evaluate";
|
|
# nugetDeps = ./atlantis-client.json; # nix-build -A packages.atlantis-client.fetch-deps && ./result src/Atlantis/nix/atlantis-client.json
|
|
nugetDeps = deps {
|
|
inherit
|
|
pkgs
|
|
netrcConfig
|
|
packageSources
|
|
;
|
|
name = "${pname}-Client";
|
|
lockfiles = [
|
|
../../src/Atlantis/src/Client/packages.lock.json
|
|
];
|
|
};
|
|
|
|
# Skip the default dotnet build since we're using Fable
|
|
dontDotnetBuild = true;
|
|
|
|
buildInputs = [
|
|
fable
|
|
bun
|
|
];
|
|
|
|
buildPhase = ''
|
|
runHook preBuild
|
|
|
|
export HOME=$TMPDIR
|
|
|
|
cp -r ${nodeDeps}/node_modules ./.
|
|
chmod -R u+rw node_modules
|
|
|
|
chmod -R u+x node_modules/.bin
|
|
patchShebangs node_modules/.bin
|
|
export PATH="./node_modules/.bin:$PATH"
|
|
|
|
cd src/Atlantis/src/Client
|
|
|
|
# NOTE(mrtz): Uses fable from nixpkgs instead of dotnet (Could be out of sync). --MSBuildCracker
|
|
${lib.getExe fable} -e .jsx -o build
|
|
|
|
# Run vite from the Atlantis directory with proper config, always bundle for prod
|
|
${lib.getExe bun} ../../../../node_modules/.bin/vite build -c ../../vite.config.js --outDir dist/public --mode Production
|
|
|
|
runHook postBuild
|
|
'';
|
|
|
|
installPhase = ''
|
|
runHook preInstall
|
|
|
|
# Copy output (*.js, *.css and *.html) to `/public`.
|
|
mkdir -p $out/public
|
|
cp -r dist/public/* $out/public/
|
|
|
|
runHook postInstall
|
|
'';
|
|
|
|
dontFixup = true;
|
|
dontPatchELF = true;
|
|
dontStrip = true;
|
|
}
|