2020-02-26 13:12:17 +00:00
|
|
|
import { execFileSync } from 'child_process';
|
|
|
|
import { exit } from 'process';
|
|
|
|
import { createConnection } from 'net';
|
2019-09-29 19:52:02 +00:00
|
|
|
|
2020-02-24 11:13:30 +00:00
|
|
|
async function awaitSocket() {
|
|
|
|
const daemonSocket = createConnection({ path: '/nix/var/nix/daemon-socket/socket' });
|
|
|
|
daemonSocket.on('error', async () => {
|
|
|
|
console.log('Waiting for daemon socket to be available, reconnecting...');
|
|
|
|
await new Promise(resolve => setTimeout(resolve, 500));
|
|
|
|
await awaitSocket();
|
|
|
|
});
|
|
|
|
daemonSocket.on('connect', () => {
|
|
|
|
exit(0);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-02-26 13:12:17 +00:00
|
|
|
execFileSync(`${__dirname}/install-nix.sh`, { stdio: 'inherit' });
|
|
|
|
|
|
|
|
// nc doesn't work correctly on macOS :(
|
|
|
|
awaitSocket();
|