From 658c3c2b4df42274199e1ffafeadac5d80082a3e Mon Sep 17 00:00:00 2001 From: Patrick Mulligan Date: Sun, 22 Feb 2026 15:14:35 -0500 Subject: [PATCH] fix(machine): live USB ISO with native modules and debug mode Enable debugMode by default (simulated bill buttons) until real hardware validator is connected. Fix live.nix to include native node_modules (better-sqlite3, bindings) from pnpm virtual store, add LD_LIBRARY_PATH for NixOS, bake aiolabs.dev endpoints into env template, and enable Electron renderer logging in journalctl. Co-Authored-By: Claude Opus 4.6 --- apps/machine/src/stores/atm.ts | 3 +- apps/machine/src/views/CashInView.vue | 1 - deploy/nixos/live.nix | 41 ++++++++++++++++----------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/apps/machine/src/stores/atm.ts b/apps/machine/src/stores/atm.ts index 0fddefe..96bc12b 100644 --- a/apps/machine/src/stores/atm.ts +++ b/apps/machine/src/stores/atm.ts @@ -132,7 +132,8 @@ export const useAtmStore = defineStore('atm', () => { // State const actor = ref | null>(null) const snapshot = ref | null>(null) - const debugMode = ref(import.meta.env.DEV) + // Always on until real hardware bill validator is connected + const debugMode = ref(true) const useLiveServices = ref(false) const connectionStatus = ref<'disconnected' | 'connecting' | 'connected' | 'error'>( 'disconnected' diff --git a/apps/machine/src/views/CashInView.vue b/apps/machine/src/views/CashInView.vue index 0e2fb00..1b13faa 100644 --- a/apps/machine/src/views/CashInView.vue +++ b/apps/machine/src/views/CashInView.vue @@ -10,7 +10,6 @@ import { Skeleton } from '@/components/ui/skeleton' import { Input } from '@/components/ui/input' import { ScrollArea } from '@/components/ui/scroll-area' import QRCode from '@/components/QRCode.vue' -import BitcoinIcon from '@/components/BitcoinIcon.vue' const router = useRouter() const atmStore = useAtmStore() diff --git a/deploy/nixos/live.nix b/deploy/nixos/live.nix index c31bcb0..44849f5 100644 --- a/deploy/nixos/live.nix +++ b/deploy/nixos/live.nix @@ -12,34 +12,38 @@ let # Build first: pnpm run build --filter=@lamassu/machine # Requires --impure: reads MACHINE_DIR env var to find build artifacts (dist/ is gitignored) machineDir = builtins.getEnv "MACHINE_DIR"; + # Resolve pnpm virtual store paths for native modules + pnpmStore = machineDir + "/../../node_modules/.pnpm"; + betterSqliteStore = pnpmStore + "/better-sqlite3@11.10.0/node_modules"; + bindingsStore = pnpmStore + "/bindings@1.5.0/node_modules"; + fileUriStore = pnpmStore + "/file-uri-to-path@1.0.0/node_modules"; + atm-app = assert machineDir != "" || throw "MACHINE_DIR env var must be set (use build-iso.sh or: export MACHINE_DIR=/path/to/apps/machine)"; pkgs.runCommand "lamassu-atm-app" { } '' - mkdir -p $out + mkdir -p $out/node_modules cp -r ${builtins.path { path = machineDir + "/dist"; name = "dist"; }} $out/dist cp -r ${builtins.path { path = machineDir + "/dist-electron"; name = "dist-electron"; }} $out/dist-electron cp ${builtins.path { path = machineDir + "/package.json"; name = "package.json"; }} $out/package.json + # Native modules required at runtime (not bundled by Vite) + # Resolved from pnpm virtual store to get real files (not symlinks) + cp -rL ${builtins.path { path = betterSqliteStore + "/better-sqlite3"; name = "better-sqlite3"; }} $out/node_modules/better-sqlite3 + cp -rL ${builtins.path { path = bindingsStore + "/bindings"; name = "bindings"; }} $out/node_modules/bindings + cp -rL ${builtins.path { path = fileUriStore + "/file-uri-to-path"; name = "file-uri-to-path"; }} $out/node_modules/file-uri-to-path ''; # .env template with regtest defaults pointing to the dev machine envTemplate = pkgs.writeText "lamassu-atm-env" '' - # Lamassu ATM Live USB Configuration - # Run provision-atm.sh from your dev machine, or edit manually: - # sudo nano /var/lib/lamassu-atm/.env && sudo systemctl restart lamassu-atm - - VITE_RELAY_URL=ws://192.168.1.190:7777 - VITE_LIGHTNING_PUB_API_URL=http://192.168.1.190:1776 - VITE_EXTENSION_API_URL=http://192.168.1.190:1777 - - VITE_LIGHTNING_PUB_PUBKEY= - VITE_ATM_PRIVATE_KEY= - VITE_ADMIN_TOKEN= - VITE_APP_ID= - VITE_APP_TOKEN= - + VITE_RELAY_URL=wss://relay.atm.aiolabs.dev + VITE_LIGHTNING_PUB_PUBKEY=64b0d9b1af689e99e4b8a23ee7b77715b394740a6830bdccf4718a060a53649a + VITE_LIGHTNING_PUB_API_URL=https://lp.atm.aiolabs.dev + VITE_ADMIN_TOKEN=lamassu-dev-admin-token + VITE_ATM_PRIVATE_KEY=f391a2c3fc734f443b0f685688a0441b5fb9805853c0023f570c5a3c6412b136 + VITE_EXTENSION_API_URL=https://lp-ext.atm.aiolabs.dev + VITE_APP_ID=6016dadc6c677f131bc82cc0cb780d2b1090b83b8b7d0c972e469010270a4208 + VITE_LNDCONNECT_URL=lndconnect://lnd.atm.aiolabs.dev:443?cert=&macaroon=AgEDbG5kAvgBAwoQjLYgcUni_8EKmwpX_vwOWxIBMBoWCgdhZGRyZXNzEgRyZWFkEgV3cml0ZRoTCgRpbmZvEgRyZWFkEgV3cml0ZRoXCghpbnZvaWNlcxIEcmVhZBIFd3JpdGUaIQoIbWFjYXJvb24SCGdlbmVyYXRlEgRyZWFkEgV3cml0ZRoWCgdtZXNzYWdlEgRyZWFkEgV3cml0ZRoXCghvZmZjaGFpbhIEcmVhZBIFd3JpdGUaFgoHb25jaGFpbhIEcmVhZBIFd3JpdGUaFAoFcGVlcnMSBHJlYWQSBXdyaXRlGhgKBnNpZ25lchIIZ2VuZXJhdGUSBHJlYWQAAAYgClsDux9_gPaKUK7PI54y-sTwt5WGmSzrzfKaKamwvK0 VITE_LAMASSU_MACHINE_MODEL=sintra VITE_LAMASSU_FIAT_CODE=USD - ELECTRON_FORCE_PROD=1 DISPLAY=:0 ''; @@ -138,8 +142,11 @@ in systemd.services.lamassu-atm = { serviceConfig = { EnvironmentFile = lib.mkForce "/var/lib/lamassu-atm/.env"; + # Native modules need libstdc++ on NixOS + Environment = "LD_LIBRARY_PATH=${pkgs.stdenv.cc.cc.lib}/lib"; # Electron needs --no-sandbox in the live/testing environment - ExecStart = lib.mkForce "${pkgs-unstable.electron}/bin/electron --no-sandbox --disable-gpu-sandbox ${atm-app}"; + # --enable-logging makes renderer console.log visible in journalctl + ExecStart = lib.mkForce "${pkgs-unstable.electron}/bin/electron --no-sandbox --disable-gpu-sandbox --enable-logging ${atm-app}"; # Disable all security hardening that conflicts with Electron NoNewPrivileges = lib.mkForce false; ProtectSystem = lib.mkForce false;