Something went wrong. Try again.
Monorepo for the nibling.run platform
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546// node:os for a runtime that reports itself as Linux on x64 (process.platform/arch).// Values the browser cannot know are fixed: one loopback interface, a user named// "user" in /home/user, /tmp for temporary files. CPU count is the browser's.import { ARCH, PLATFORM } from "../shared/platform";import { SIGNALS } from "../shared/protocol";
const ERRNO = { E2BIG: 7, EACCES: 13, EADDRINUSE: 98, EADDRNOTAVAIL: 99, EAGAIN: 11, EBADF: 9, EBUSY: 16, ECHILD: 10, ECONNREFUSED: 111, ECONNRESET: 104, EEXIST: 17, EINTR: 4, EINVAL: 22, EIO: 5, EISDIR: 21, EMFILE: 24, ENOENT: 2, ENOMEM: 12, ENOSPC: 28, ENOSYS: 38, ENOTDIR: 20, ENOTEMPTY: 39, EPERM: 1, EPIPE: 32, ESRCH: 3, ETIMEDOUT: 110, EXDEV: 18,};
export function makeOs(env: () => Record<string, string>) { const cpuCount = Math.max(1, navigator.hardwareConcurrency || 1); const cpu = { model: "nib virtual cpu", speed: 0, times: { user: 0, nice: 0, sys: 0, idle: 0, irq: 0 } }; const homedir = (): string => env().HOME ?? "/home/user"; return { EOL: "\n", devNull: "/dev/null", constants: { signals: { ...SIGNALS }, errno: ERRNO, priority: { PRIORITY_LOW: 19, PRIORITY_NORMAL: 0, PRIORITY_HIGH: -14 } }, arch: () => ARCH, machine: () => "x86_64", platform: () => PLATFORM, type: () => "Linux", release: () => "6.0.0-nib", version: () => "#1 SMP nib", hostname: () => "localhost", endianness: () => "LE", homedir, tmpdir: (): string => (env().TMPDIR ?? "/tmp").replace(/(.)\/$/, "$1"), uptime: () => Math.floor(performance.now() / 1000), loadavg: () => [0, 0, 0], totalmem: () => 4 * 1024 ** 3, freemem: () => 2 * 1024 ** 3, availableParallelism: () => cpuCount, cpus: () => Array.from({ length: cpuCount }, () => ({ ...cpu, times: { ...cpu.times } })), networkInterfaces: () => ({ lo: [{ address: "127.0.0.1", netmask: "255.0.0.0", family: "IPv4", mac: "00:00:00:00:00:00", internal: true, cidr: "127.0.0.1/8" }], }), userInfo: () => ({ uid: 1000, gid: 1000, username: "user", homedir: homedir(), shell: "/bin/sh" }), getPriority: () => 0, setPriority: () => {}, };}