Add flake.nix exposing lib.mkWebapp #97
Labels
No labels
app:activities
app:chat
app:events
app:forum
app:libra
app:market
app:restaurant
app:tasks
app:wallet
app:webapp
bug
enhancement
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
aiolabs/webapp#97
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Background
The brand kit architecture (#95 / #96) deferred the
flake.nixpiece. This issue tracks adding it.Once
lib.mkWebapp { brandDir, app, ... }is exposed,aiolabs/server-deploy/hosts/<host>/services/webapp.nixcan switch from its current build path to:This is the consumer side of aiolabs/server-deploy#8 (Phase 2).
Scope
flake.nixat the webapp repo root withnixpkgs+flake-utilsinputs.lib.mkWebapp = pkgs: { brandDir ? ./branding/default, app ? "main", ... }: <derivation>.pnpm install --frozen-lockfile+pnpm build(orpnpm build:<app>), withBRAND_DIRexported from the passedbrandDirandBRAND_APPfromapp.packages.${system}.default = lib.mkWebapp { ... }fornix buildsanity (unparameterized aiolabs default).nix flake checkto CI (or document the manual check).Known sticking points
pnpm under nix.
buildNpmPackageis npm-specific. Options:pkgs.stdenv.mkDerivation+pnpm.configHook(pnpm 8+ with corepack)pnpm.fetchDeps { pname; version; src; hash; }for a deps derivation, thencp -r ${deps} node_modulesin the main buildmkPnpmPackageor the nixpkgs pnpm modulepnpmin itspackageManagerfield — verify the nix builder honors itsharp / libvips in the sandbox.
@vite-pwa/assets-generatorusessharp(native libvips bindings). Historically a nix pain point because sharp downloads precompiled binaries at install time, which doesn't fly in nix's offline sandbox.Modern sharp (≥ 0.33) has better nix support: it can be built against system libvips. May need
NPM_CONFIG_SHARP_LIBVIPS_INCLUDE_DIR+pkgs.vipsinbuildInputs.If sharp can't be made to work cleanly under the sandbox, fallback: run the generator outside the derivation (Hydra-side prebuild step that writes to a fixed output, then the nix derivation consumes that). Less elegant but workable.
Vite's image optimizer plugin also uses native code (sharp transitively). Same concerns apply.
Acceptance
nix build .#defaultfrom the webapp repo produces a usabledist/derivation.nix build .#default --override-input pkgs github:NixOS/nixpkgs/<commit>works (consumer can pin their own nixpkgs).inputs.webapp.lib.mkWebapp { inherit pkgs; brandDir = ./some-brand; }from a downstream flake builds with that brand's logo + manifest.nix flake checkpasses.branding/README.md(replace the placeholder note) and a short section inCLAUDE.md.Cross-references