🌳
pt0/deployF/nixF/nixBuildGuardAI.mts
1import { execSync } from 'child_process'
4export const isWithNix = () => cliFlag('--withNix')
6export const guardNixInstalled = () => {
7 try {
8 execSync('which nix', {stdio: 'ignore'})
9 } catch {
10 console.error([
11 'nix not found. Install with:',
12 '',
13 ' sh <(curl -L https://nixos.org/nix/install) --daemon',
14 '',
15 'Then restart your shell and re-run with --withNix.',
16 'Docs: https://nixos.org/download',
17 ].join('\n'))
18 process.exit(1)
19 }
20 try {
21 // nix store info hangs with ssh-ng://, so test with a trivial build dispatch instead
22 execSync(`nix build --impure --expr '(import <nixpkgs> { system = "x86_64-linux"; }).hello' --no-link 2>&1`, {timeout: 60000, stdio: 'ignore'})
23 } catch {
24 console.error([
25 'nix remote builder not reachable or not configured.',
26 '',
27 'Deploy the builder: ptnode pt0/klustersF/do2demo/epSyncNixbuilder.mjs apply',
28 'Then configure: ptnode pt0/klustersF/do2demo/epSyncNixbuilder.mjs setup',
29 'Host key changed? ptnode pt0/klustersF/do2demo/epSyncNixbuilder.mjs fixssh',
30 ].join('\n'))
31 process.exit(1)
32 }