Automerge backed Markdown editor for the Atmosphere
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123{ description = "Reams - Mobile-first markdown editor development environment";
inputs = { nixpkgs.url = "github:NixOS/nixpkgs/25.05"; # `prek` was added after the 25.05 package set, so source it from # nixos-unstable without changing the project's primary package set. nixpkgs-prek.url = "github:NixOS/nixpkgs/nixos-unstable"; flake-utils.url = "github:numtide/flake-utils"; # Nix-packaged automerge-repo-sync-server. Putting it in the dev # shell makes `bun run dev` and the pushwork-sync test harness # self-contained -- no sibling repo required. automerge-repo-nix.url = "git+https://tangled.org/hyl.st/automerge-repo-nix"; };
outputs = { self, nixpkgs, nixpkgs-prek, flake-utils, automerge-repo-nix }: flake-utils.lib.eachDefaultSystem (system: let pkgs = nixpkgs.legacyPackages.${system}; pkgsPrek = nixpkgs-prek.legacyPackages.${system}; # chromium has no darwin build in nixpkgs, and the sync server is # a Linux-focused dev tool (the harness's PID-recycling guard # reads /proc). Gate both on Linux. On darwin, use # `bun run dev:vite-only` and point localStorage at an external # sync server. isLinux = pkgs.stdenv.isLinux; # The sync server package from the automerge-repo-nix flake. # The upstream flake exposes it as `packages.${system}.default` # (confirmed via `nix flake show`). syncServer = automerge-repo-nix.packages.${system}.default; in { packages.wavescope-mcp = pkgs.writeShellApplication { name = "wavescope-mcp"; runtimeInputs = [ pkgs.nodejs_22 ]; text = '' exec npx --yes wavescope-mcp@1.0.10 "$@" ''; };
packages.container = import ./nix/container.nix { # The server SDK requires Node >=22.19; the locked 25.05 set has # 22.14. Use the already pinned newer set for this production package. pkgs = pkgsPrek; # Carry the prior public release's immutable assets into the new web # image so installed clients can finish loading during an upgrade. previousAssets = let previous = builtins.getEnv "REAMS_PREVIOUS_ASSETS"; in if previous == "" then [ ] else [ (builtins.path { path = /. + previous; name = "reams-previous-release-assets"; }) ]; # Only public build configuration is read here, never server secrets. # Values are captured in the derivation; --impure admits environment # inputs just as in the Seams image build, not runtime network builds. deployment = { publicOrigin = builtins.getEnv "REAMS_PUBLIC_ORIGIN"; happyviewUrl = builtins.getEnv "VITE_HAPPYVIEW_URL"; happyviewClientKey = builtins.getEnv "VITE_HAPPYVIEW_CLIENT_KEY"; baseScope = builtins.getEnv "VITE_ATPROTO_OAUTH_SCOPE"; }; };
packages.auth-container = import ./nix/container.nix { pkgs = pkgsPrek; role = "auth"; deployment = null; }; packages.happyview-container = import ./nix/happyview-container.nix { pkgs = pkgsPrek; sourcePath = builtins.getEnv "HAPPYVIEW_SOURCE"; }; packages.combined-container = import ./nix/container.nix { pkgs = pkgsPrek; role = "combined"; deployment = { publicOrigin = builtins.getEnv "REAMS_PUBLIC_ORIGIN"; happyviewUrl = builtins.getEnv "VITE_HAPPYVIEW_URL"; happyviewClientKey = builtins.getEnv "VITE_HAPPYVIEW_CLIENT_KEY"; baseScope = builtins.getEnv "VITE_ATPROTO_OAUTH_SCOPE"; }; };
packages.publish-image = pkgs.writeShellApplication { name = "reams-publish-image"; runtimeInputs = [ pkgs.nix pkgs.git pkgs.docker-client pkgs.gnutar pkgs.jq pkgsPrek.flyctl ]; text = builtins.readFile ./scripts/publish-container.sh; };
devShells.default = pkgs.mkShell { buildInputs = with pkgs; [ bun nodejs_22 nodePackages.npm nodePackages.typescript nodePackages.typescript-language-server git pkgsPrek.prek pkgsPrek.flyctl semgrep # audit-flow tooling: AST-pattern queries (not via npm -- ships a # generic-linux precompiled binary that needs patching on NixOS). ast-grep self.packages.${system}.wavescope-mcp self.packages.${system}.publish-image ] ++ pkgs.lib.optional isLinux chromium ++ pkgs.lib.optionals isLinux [ firefox geckodriver ] ++ pkgs.lib.optional isLinux util-linux ++ pkgs.lib.optional isLinux syncServer;
PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD = "1"; PLAYWRIGHT_CHROMIUM_BIN = pkgs.lib.optionalString isLinux (pkgs.lib.getExe pkgs.chromium); FIREFOX_BIN = pkgs.lib.optionalString isLinux (pkgs.lib.getExe pkgs.firefox); GECKODRIVER_BIN = pkgs.lib.optionalString isLinux (pkgs.lib.getExe pkgs.geckodriver);
shellHook = '' echo "Reams development environment" echo "Bun version: $(bun --version)" echo "Node version: $(node --version)" echo "npm version: $(npm --version)" echo "prek version: $(prek --version)" echo "ast-grep version: $(ast-grep --version)" echo "semgrep version: $(semgrep --version)" ${pkgs.lib.optionalString isLinux ''echo "chromium path: ${pkgs.lib.getExe pkgs.chromium}"''} ${pkgs.lib.optionalString isLinux ''echo "sync server: $(command -v automerge-repo-sync-server || echo '(not found)')"''} ''; }; } );}