diff --git a/flake.nix b/flake.nix index 588438c..b937be4 100644 --- a/flake.nix +++ b/flake.nix @@ -10,32 +10,24 @@ let apps = [ "main" "events" "wallet" "chat" "market" "forum" "tasks" "restaurant" "libra" ]; - # Use this flake's pinned nixpkgs for the build, regardless of which - # nixpkgs the consumer's `pkgs` is from. Without this, the pnpmDeps - # hash drifts as soon as a consumer's nixpkgs has a different - # pnpm_10 minor version (snapshots are byte-for-byte different per - # pnpm version). Only `pkgs`'s system attribute is honored. - flakePkgsFor = pkgs: import nixpkgs { - inherit (pkgs.stdenv.hostPlatform) system; - }; - mkWebapp = { pkgs, brandDir ? ./branding/default, app ? "main" }: let buildScript = if app == "main" then "build" else "build:${app}"; outDir = if app == "main" then "dist" else "dist-${app}"; - flakePkgs = flakePkgsFor pkgs; in - flakePkgs.stdenv.mkDerivation (finalAttrs: { + pkgs.stdenv.mkDerivation (finalAttrs: { pname = "aio-webapp-${app}"; version = "0.0.0"; src = ./.; - # pnpm comes from THIS flake's pinned nixpkgs (via flakePkgs), - # never the consumer's, so the pnpmDeps snapshot is stable. - pnpm = flakePkgs.pnpm_10; + # Pin pnpm major version (10.x) regardless of consumer's nixpkgs + # so the pnpmDeps hash stays stable for downstream callers that + # bring their own pkgs. package.json's packageManager field + # declares pnpm@10.33.0; pnpm_10 satisfies that. + pnpm = pkgs.pnpm_10; - pnpmDeps = flakePkgs.fetchPnpmDeps { + pnpmDeps = pkgs.fetchPnpmDeps { inherit (finalAttrs) pname version src; inherit (finalAttrs) pnpm; fetcherVersion = 3; @@ -43,16 +35,16 @@ }; nativeBuildInputs = [ - flakePkgs.nodejs + pkgs.nodejs finalAttrs.pnpm - flakePkgs.pnpmConfigHook - flakePkgs.autoPatchelfHook + pkgs.pnpmConfigHook + pkgs.autoPatchelfHook ]; # sharp's prebuilt libvips binaries (under @img/sharp-libvips-*) # are dynamically linked; autoPatchelfHook needs the runtime libs. buildInputs = [ - flakePkgs.stdenv.cc.cc.lib + pkgs.stdenv.cc.cc.lib ]; # Brand kit env knobs read by vite-branding.ts and @@ -80,7 +72,7 @@ runHook postInstall ''; - meta = with flakePkgs.lib; { + meta = with pkgs.lib; { description = "AIO webapp${if app == "main" then "" else " (${app} standalone)"}"; homepage = "https://git.atitlan.io/aiolabs/webapp"; license = licenses.mit;