automerge daemon to keep local files in sync

init

bun.lockb

This is a binary file and will not be displayed.

+61
flake.lock
··· 1 + { 2 + "nodes": { 3 + "flake-utils": { 4 + "inputs": { 5 + "systems": "systems" 6 + }, 7 + "locked": { 8 + "lastModified": 1731533236, 9 + "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=", 10 + "owner": "numtide", 11 + "repo": "flake-utils", 12 + "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b", 13 + "type": "github" 14 + }, 15 + "original": { 16 + "owner": "numtide", 17 + "repo": "flake-utils", 18 + "type": "github" 19 + } 20 + }, 21 + "nixpkgs": { 22 + "locked": { 23 + "lastModified": 1736420959, 24 + "narHash": "sha256-dMGNa5UwdtowEqQac+Dr0d2tFO/60ckVgdhZU9q2E2o=", 25 + "owner": "NixOS", 26 + "repo": "nixpkgs", 27 + "rev": "32af3611f6f05655ca166a0b1f47b57c762b5192", 28 + "type": "github" 29 + }, 30 + "original": { 31 + "owner": "NixOS", 32 + "ref": "nixpkgs-unstable", 33 + "repo": "nixpkgs", 34 + "type": "github" 35 + } 36 + }, 37 + "root": { 38 + "inputs": { 39 + "flake-utils": "flake-utils", 40 + "nixpkgs": "nixpkgs" 41 + } 42 + }, 43 + "systems": { 44 + "locked": { 45 + "lastModified": 1681028828, 46 + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 47 + "owner": "nix-systems", 48 + "repo": "default", 49 + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 50 + "type": "github" 51 + }, 52 + "original": { 53 + "owner": "nix-systems", 54 + "repo": "default", 55 + "type": "github" 56 + } 57 + } 58 + }, 59 + "root": "root", 60 + "version": 7 61 + }
+119
flake.nix
··· 1 + { 2 + description = "A basic flake with a shell"; 3 + inputs = { 4 + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; 5 + flake-utils.url = "github:numtide/flake-utils"; 6 + }; 7 + 8 + outputs = { nixpkgs, flake-utils, ... }: 9 + flake-utils.lib.eachDefaultSystem (system: 10 + let 11 + pkgs = import nixpkgs { inherit system; }; 12 + username = "admin"; 13 + passwordHash = 14 + "$apr1$bhZ6EAAr$E8cv5p/2RUBrxLZD.9Jpi."; # Replace with your hash 15 + 16 + nginxConfig = pkgs.writeText "nginx.conf" '' 17 + worker_processes auto; 18 + daemon off; 19 + 20 + events { 21 + worker_connections 1024; 22 + } 23 + 24 + http { 25 + include ${pkgs.nginx}/conf/mime.types; 26 + 27 + server { 28 + listen 8080; 29 + 30 + location / { 31 + auth_basic "Restricted Content"; 32 + auth_basic_user_file /etc/nginx/htpasswd; 33 + 34 + root /app; 35 + index index.html; 36 + try_files $uri $uri/ /index.html; 37 + } 38 + } 39 + } 40 + ''; 41 + 42 + htpasswd = pkgs.writeText "htpasswd" '' 43 + ${username}:${passwordHash} 44 + ''; 45 + in { 46 + packages = rec { 47 + react = pkgs.buildNpmPackage { 48 + pname = "mast-react"; 49 + version = "0.0.1"; 50 + src = ./mast-react-vite; 51 + 52 + npmDepsHash = "sha256-oqq55MEzXGEiF9UW7rZFyQrkyTPrUEkh2enZmbbZ7Ks="; 53 + buildInputs = with pkgs; [ nodejs typescript ]; 54 + nativeBuildInputs = with pkgs; [ nodejs ]; 55 + 56 + # npmWorkspace = ./mast-react-vite; 57 + npmBuildScript = "build"; 58 + installPhase = '' 59 + mkdir -p $out 60 + cp -r dist $out/ 61 + ''; 62 + }; 63 + react-server = pkgs.dockerTools.buildImage { 64 + name = "react-server"; 65 + tag = "latest"; 66 + 67 + copyToRoot = pkgs.buildEnv { 68 + name = "image-root"; 69 + paths = [ 70 + pkgs.nginx 71 + react 72 + (pkgs.writeScriptBin "start-server" '' 73 + #!/usr/bin/env bash 74 + 75 + # Create necessary directories 76 + mkdir -p /etc/nginx 77 + cp ${htpasswd} /etc/nginx/htpasswd 78 + 79 + # Create app directory and copy built files 80 + mkdir -p /app 81 + cp -r ${react}/* /app/ 82 + 83 + # Start nginx 84 + ${pkgs.nginx}/bin/nginx -c ${nginxConfig} 85 + '') 86 + ]; 87 + pathsToLink = [ "/bin" ]; 88 + }; 89 + 90 + config = { 91 + Cmd = [ "/bin/start-server" ]; 92 + ExposedPorts = { "8080/tcp" = { }; }; 93 + }; 94 + }; 95 + }; 96 + devShells.default = pkgs.mkShell { 97 + buildInputs = with pkgs; [ bun ]; 98 + 99 + # TODO: 100 + # Shell Aliases don't work for direnv because they're not shell portable 101 + # Find an alternative to this 102 + shellHook = '' 103 + alias start-dev='npm run dev' 104 + alias build-dev='npm run build' 105 + alias clean-dev='rm -rf dist node_modules' 106 + alias ws-server='go run ./server/main.go' 107 + alias gen-pass='openssl passwd -apr1 ' 108 + 109 + echo "System: ${system}" 110 + echo "Available commands:" 111 + echo " start-dev - Start Vite dev server" 112 + echo " build-dev - Build the application" 113 + echo " clean-dev - Clean build artifacts" 114 + echo " ws-server - Run the websocket server" 115 + echo " gen-pass - Generate a basic_auth password" 116 + ''; 117 + }; 118 + }); 119 + }
+4
index.ts
··· 1 + import { Repo } from "@automerge/automerge-repo" 2 + 3 + const repo = new Repo() 4 + console.log(repo)
+6
package.json
··· 1 + { 2 + "dependencies": { 3 + "@automerge/automerge": "^2.2.8", 4 + "@automerge/automerge-repo": "^1.2.1" 5 + } 6 + }