@adrifer/winix 0.2.4-preview.0 → 0.2.4-preview.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -94,6 +94,58 @@ For what it's worth: Winix today works just as well on macOS and native NixOS as
94
94
 
95
95
  ## Install and create a config
96
96
 
97
+ ### Standalone executable (no Node.js or npm)
98
+
99
+ [GitHub releases](https://github.com/adrifer/winix/releases) include
100
+ `winix-windows-x64.exe`, `winix-windows-arm64.exe`, `winix-linux-x64`,
101
+ `winix-linux-arm64`, and `SHA256SUMS`. Choose a versioned release and the native
102
+ architecture, compare its SHA256 with `SHA256SUMS`, and keep the executable
103
+ outside the config checkout. Windows binaries are not yet code-signed:
104
+ checksums detect corruption, not publisher identity. Respect organizational
105
+ execution/network policies; do not disable TLS verification.
106
+ Redistribution notices and runtime source/rebuild references accompany the
107
+ assets as `LICENSE`, `NOTICE.txt`, and `BUN-LICENSE.md`.
108
+
109
+ On Windows, rename the verified executable to `winix.exe` and either add its
110
+ directory to PATH or invoke it by full path:
111
+
112
+ ```powershell
113
+ & "$HOME\winix-bootstrap\winix.exe" --version
114
+ cd "$HOME\dotfiles\winix"
115
+ & "$HOME\winix-bootstrap\winix.exe" check
116
+ & "$HOME\winix-bootstrap\winix.exe" switch --host windows-devbox --dry
117
+ ```
118
+
119
+ No `npm ci` is needed for normal configs. The executable contains its runtime
120
+ and SDK, supports local TypeScript/JavaScript imports and Node builtins, and
121
+ shares SDK evaluation context across all config files. Its version, not an
122
+ installed npm SDK or the config's package lock, determines the SDK used.
123
+ `winix init` works without npm too; its package/TypeScript files are optional
124
+ editor/development tooling. Type-only `@adrifer/winix/types` imports work;
125
+ runtime SDK imports must use `@adrifer/winix`. Other npm dependencies must
126
+ already be installed: Winix never downloads them automatically.
127
+
128
+ Native prerequisites remain Git, PowerShell 7, WinGet, DSC and the required DSC
129
+ resources on Windows, or Nix/activation tools for Linux targets. Use
130
+ `bootstrap-windows.ps1 -Standalone -Check` to inspect native prerequisites or
131
+ `-Standalone` to install missing ones; this mode never installs/checks Node/npm.
132
+ Standalone Windows WSL setup downloads the matching release's Linux executable,
133
+ verifies a checksum embedded in the Windows binary, and prepares its NixOS
134
+ runtime linker with pinned Nix dependencies. Account/config generation remains
135
+ unprivileged and does not run npm. Keep `flake.lock` committed; package manifests
136
+ are required only by the npm-based setup path. These downloads still need
137
+ approved access to GitHub and Nix caches.
138
+
139
+ Linux release binaries target glibc systems (with libstdc++); use `chmod +x`
140
+ before running. NixOS does not provide an FHS runtime linker by default:
141
+ automatic WSL setup handles this explicitly, while direct manual use needs a
142
+ compatible linker/library environment. Windows binaries used for WSL setup
143
+ must come from a complete official release; developer single-target builds
144
+ lack the Linux checksums. ARM64 assets are cross-compiled; fresh-machine
145
+ activation and ARM64 execution are not yet verified.
146
+
147
+ ### npm installation (optional)
148
+
97
149
  ```bash
98
150
  mkdir my-winix-config
99
151
  cd my-winix-config
@@ -101,7 +153,9 @@ npx @adrifer/winix@latest init
101
153
  npm install
102
154
  ```
103
155
 
104
- Winix expects Node.js with native TypeScript stripping support for `winix.config.ts` files. Node 22+ is recommended.
156
+ The npm CLI requires Node.js with native TypeScript transformation and the
157
+ `--experimental-transform-types` flag (Node 22.13+ or 24; use Node 24).
158
+ The standalone executable has no installed Node version requirement.
105
159
 
106
160
  If you prefer to set up files yourself instead of using `init`, add the package to your own `package.json`:
107
161
 
@@ -578,9 +632,10 @@ windows.wsl.distro("NixOS", {
578
632
  });
579
633
  ```
580
634
 
581
- This explicitly trusts the repository, its npm lifecycle scripts, and its Winix
582
- configuration. Use a committed `package.json`, `package-lock.json`, and `flake.lock`
583
- in `configDirectory`, with a released Winix dependency supporting this API.
635
+ This explicitly trusts the repository and its Winix configuration (including
636
+ npm lifecycle scripts when using the npm SDK). Commit `flake.lock` in
637
+ `configDirectory`; the npm path additionally requires `package.json`,
638
+ `package-lock.json`, and a released Winix dependency supporting this API.
584
639
  Only HTTPS Git URLs without embedded credentials are accepted. Private repository
585
640
  and dependency authentication must already be available inside Linux; credentials
586
641
  are never provisioned by this helper.
@@ -598,7 +653,7 @@ an update without names includes them too. Dry generation never clones or execut
598
653
  repository code. Pins affect **first-run setup only**, not subsequent dotfiles
599
654
  updates; an interrupted setup retains its original commit.
600
655
 
601
- During activation, Git/npm/config preparation runs as the image's initial `nixos`
656
+ During activation, Git/config preparation (and npm on the npm path) runs as the image's initial `nixos`
602
657
  user. A root coordinator first activates only the selected declarative account
603
658
  and required WSL/shell settings, moves checkout ownership to it, then generates
604
659
  the full host as that user and activates it as root. No password is invented and
@@ -639,6 +694,9 @@ Store policy. Run from a normal Windows account, not WSL or another admin accoun
639
694
  ```powershell
640
695
  # Read-only: reports missing/old prerequisites and exits unsuccessfully if not ready.
641
696
  powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\scripts\bootstrap-windows.ps1 -Check
697
+ # Executable workflow: omit all Node/npm checks and installations.
698
+ powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\scripts\bootstrap-windows.ps1 -Standalone -Check
699
+ powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\scripts\bootstrap-windows.ps1 -Standalone
642
700
  # Review and confirm installation/upgrade of missing or outdated prerequisites.
643
701
  powershell.exe -NoProfile -ExecutionPolicy Bypass -File .\scripts\bootstrap-windows.ps1
644
702
  # Choose NVM for Windows rather than standalone Node on NVM-based setups.
@@ -22,11 +22,14 @@ export declare function createWslAccountPlan(host: EvaluatedHost, setup: WinWslS
22
22
  plan: Plan;
23
23
  accountHost: EvaluatedHost;
24
24
  };
25
- export declare function prepareWslAccount(configDirectory: string, accountDirectory: string, setup: WinWslSetup): Promise<Plan>;
25
+ export declare function prepareWslAccount(configDirectory: string, accountDirectory: string, setup: WinWslSetup, embeddedSdk?: typeof import("../../index.ts")): Promise<Plan>;
26
26
  export declare function runWslSetup(request: Request, options?: {
27
27
  stateDirectory?: string;
28
28
  run?: SetupRunner;
29
29
  isRoot?: () => boolean;
30
30
  readWslConfig?: () => Promise<string>;
31
+ standalone?: boolean;
32
+ executable?: string;
31
33
  }): Promise<void>;
34
+ export declare function dispatchWslSetup(embeddedSdk?: typeof import("../../index.ts")): Promise<void>;
32
35
  export {};
@@ -76,7 +76,7 @@ export function createWslAccountPlan(host, setup, architecture) {
76
76
  },
77
77
  };
78
78
  }
79
- export async function prepareWslAccount(configDirectory, accountDirectory, setup) {
79
+ export async function prepareWslAccount(configDirectory, accountDirectory, setup, embeddedSdk) {
80
80
  const configName = [];
81
81
  for (const name of ["winix.config.ts", "winix.config.js", "winix.config.mjs"]) {
82
82
  if (await exists(join(configDirectory, name)))
@@ -84,10 +84,9 @@ export async function prepareWslAccount(configDirectory, accountDirectory, setup
84
84
  }
85
85
  if (configName.length !== 1)
86
86
  throw new Error("WSL setup configDirectory must contain exactly one Winix config file");
87
- const sdkUrl = nativeRun(process.execPath, [
87
+ const sdk = embeddedSdk ?? await import(__rewriteRelativeImportExtension(nativeRun(process.execPath, [
88
88
  "--input-type=module", "--eval", 'console.log(import.meta.resolve("@adrifer/winix"))',
89
- ], { cwd: configDirectory });
90
- const sdk = await import(__rewriteRelativeImportExtension(sdkUrl));
89
+ ], { cwd: configDirectory })));
91
90
  const workspace = (await import(__rewriteRelativeImportExtension(pathToFileURL(join(configDirectory, configName[0])).href))).default;
92
91
  if (!workspace || !Array.isArray(workspace.hosts))
93
92
  throw new Error("Invalid Winix workspace");
@@ -158,6 +157,7 @@ export async function runWslSetup(request, options = {}) {
158
157
  throw new Error("WSL setup coordinator requires Linux root; repository/npm commands run unprivileged");
159
158
  }
160
159
  const run = options.run ?? nativeRun;
160
+ const executable = options.executable ?? process.execPath;
161
161
  const stateDirectory = options.stateDirectory ?? "/var/lib/winix/wsl-setup";
162
162
  await safeDirectory(stateDirectory);
163
163
  await fs.mkdir(stateDirectory, { recursive: true, mode: 0o711 });
@@ -192,11 +192,13 @@ export async function runWslSetup(request, options = {}) {
192
192
  }
193
193
  await atomicJson(statePath, state);
194
194
  const runtimePath = join(stateDirectory, "runtime.mjs");
195
- if (!process.env.WINIX_WSL_SETUP_RUNTIME && !options.run)
196
- throw new Error("Missing WSL setup runtime payload");
197
- const runtimeTemporary = `${runtimePath}.${randomUUID()}.tmp`;
198
- await fs.writeFile(runtimeTemporary, Buffer.from(process.env.WINIX_WSL_SETUP_RUNTIME ?? "", "base64"), { flag: "wx", mode: 0o444 });
199
- await fs.rename(runtimeTemporary, runtimePath);
195
+ if (!options.standalone) {
196
+ if (!process.env.WINIX_WSL_SETUP_RUNTIME && !options.run)
197
+ throw new Error("Missing WSL setup runtime payload");
198
+ const runtimeTemporary = `${runtimePath}.${randomUUID()}.tmp`;
199
+ await fs.writeFile(runtimeTemporary, Buffer.from(process.env.WINIX_WSL_SETUP_RUNTIME ?? "", "base64"), { flag: "wx", mode: 0o444 });
200
+ await fs.rename(runtimeTemporary, runtimePath);
201
+ }
200
202
  const work = join(stateDirectory, "work");
201
203
  const repository = join(work, "repository");
202
204
  const accountDirectory = join(work, "account");
@@ -226,7 +228,7 @@ export async function runWslSetup(request, options = {}) {
226
228
  throw new Error("WSL setup checkout is dirty; refusing reset");
227
229
  };
228
230
  const prepare = (config, user, home) => {
229
- const prepared = run(process.execPath, ["--experimental-transform-types", "--no-warnings", runtimePath], {
231
+ const prepared = run(executable, options.standalone ? [] : ["--experimental-transform-types", "--no-warnings", runtimePath], {
230
232
  user, home, cwd: config,
231
233
  env: { WINIX_WSL_SETUP_PREPARE: JSON.stringify({ config, accountDirectory, setup: request.setup }) },
232
234
  });
@@ -275,11 +277,12 @@ export async function runWslSetup(request, options = {}) {
275
277
  const inside = relative(await fs.realpath(repository), config);
276
278
  if (inside.startsWith("..") || isAbsolute(inside))
277
279
  throw new Error("configDirectory escapes the checkout");
278
- for (const name of ["package-lock.json", "package.json", "flake.lock"]) {
280
+ for (const name of options.standalone ? ["flake.lock"] : ["package-lock.json", "package.json", "flake.lock"]) {
279
281
  if (!await exists(join(config, name)))
280
282
  throw new Error(`WSL setup requires committed ${name} in configDirectory`);
281
283
  }
282
- run("npm", ["ci", "--no-audit", "--no-fund"], { ...asInitial, cwd: config });
284
+ if (!options.standalone)
285
+ run("npm", ["ci", "--no-audit", "--no-fund"], { ...asInitial, cwd: config });
283
286
  verify(repository, "nixos", initial.home);
284
287
  state.plan = prepare(config, "nixos", initial.home);
285
288
  await save("prepared");
@@ -346,7 +349,10 @@ export async function runWslSetup(request, options = {}) {
346
349
  verify(plan.checkout, plan.user, plan.home);
347
350
  if (state.step === "account") {
348
351
  console.log("WSL setup: generating and activating the full Linux host");
349
- run("npm", ["exec", "--offline", "--", "winix", "apply", "--host", plan.host], asUser);
352
+ if (options.standalone)
353
+ run(executable, ["apply", "--host", plan.host], asUser);
354
+ else
355
+ run("npm", ["exec", "--offline", "--", "winix", "apply", "--host", plan.host], asUser);
350
356
  const flake = `path:${join(asUser.cwd, ".winix", "out")}`;
351
357
  const defaultUser = run("nix", ["eval", "--raw", "--no-write-lock-file", `${flake}#nixosConfigurations.${JSON.stringify(plan.host)}.config.wsl.defaultUser`], asUser);
352
358
  if (defaultUser !== plan.user)
@@ -378,10 +384,18 @@ export async function runWslSetup(request, options = {}) {
378
384
  await fs.unlink(lockPath);
379
385
  }
380
386
  }
381
- if (process.env.WINIX_WSL_SETUP_PREPARE) {
382
- const { config, accountDirectory, setup } = JSON.parse(process.env.WINIX_WSL_SETUP_PREPARE);
383
- console.log("WINIX_PLAN:" + JSON.stringify(await prepareWslAccount(config, accountDirectory, setup)));
384
- }
385
- else if (process.env.WINIX_WSL_SETUP_REQUEST) {
386
- await runWslSetup(JSON.parse(Buffer.from(process.env.WINIX_WSL_SETUP_REQUEST, "base64").toString("utf8")));
387
+ export async function dispatchWslSetup(embeddedSdk) {
388
+ if (process.env.WINIX_WSL_SETUP_PREPARE) {
389
+ const { config, accountDirectory, setup } = JSON.parse(process.env.WINIX_WSL_SETUP_PREPARE);
390
+ console.log("WINIX_PLAN:" + JSON.stringify(await prepareWslAccount(config, accountDirectory, setup, embeddedSdk)));
391
+ }
392
+ else if (process.env.WINIX_WSL_SETUP_REQUEST) {
393
+ await runWslSetup(JSON.parse(Buffer.from(process.env.WINIX_WSL_SETUP_REQUEST, "base64").toString("utf8")), {
394
+ standalone: embeddedSdk !== undefined,
395
+ executable: embeddedSdk ? process.env.WINIX_STANDALONE_EXECUTABLE : undefined,
396
+ });
397
+ }
398
+ else {
399
+ throw new Error("Missing WSL setup request");
400
+ }
387
401
  }
@@ -1,9 +1,10 @@
1
1
  import { createHash } from "node:crypto";
2
2
  import { execFileSync } from "node:child_process";
3
3
  import { readFileSync } from "node:fs";
4
- import { stripTypeScriptTypes } from "node:module";
4
+ import { createRequire } from "node:module";
5
5
  import { normalizeWslSetup } from "../../helpers/windows.js";
6
6
  import { powerShellLiteral as ps } from "../../helpers/utils.js";
7
+ import { standaloneRuntime } from "../../runtime.js";
7
8
  export function wslRepositoryKey(setup) {
8
9
  return createHash("sha256").update(JSON.stringify([setup.repository, setup.ref ?? "HEAD"])).digest("hex");
9
10
  }
@@ -58,11 +59,53 @@ export function wslSetupPrelude(setup, pin) {
58
59
  throw new Error("Missing/mismatched WSL repository pin. Run winix update --windows wsl-setup.");
59
60
  }
60
61
  const fingerprint = createHash("sha256").update(JSON.stringify(setup)).digest("hex");
61
- const extension = import.meta.url.endsWith(".ts") ? "ts" : "js";
62
- const source = readFileSync(new URL(`./wsl-setup-runtime.${extension}`, import.meta.url), "utf8");
63
- const runtime = extension === "ts" ? stripTypeScriptTypes(source, { mode: "transform" }) : source;
64
- const encodedRuntime = Buffer.from(runtime).toString("base64");
65
62
  const request = Buffer.from(JSON.stringify({ setup, revision: pin.revision, fingerprint })).toString("base64");
63
+ const standalone = standaloneRuntime();
64
+ let launch;
65
+ if (standalone) {
66
+ const cases = ["x64", "arm64"].map((architecture) => {
67
+ const asset = standalone.linuxAssets[architecture];
68
+ if (!asset || !/^[a-f0-9]{64}$/.test(asset.sha256) || asset.name !== `winix-linux-${architecture}`) {
69
+ throw new Error("This standalone build lacks Linux release checksums; use the official Windows release binary for WSL provisioning.");
70
+ }
71
+ return ` ${architecture === "x64" ? "x86_64" : "aarch64"}) asset='${asset.name}'; checksum='${asset.sha256}'; linker='${architecture === "x64" ? "ld-linux-x86-64.so.2" : "ld-linux-aarch64.so.1"}' ;;`;
72
+ });
73
+ launch = [
74
+ 'case "$(uname -m)" in', ...cases,
75
+ " *) echo 'Unsupported Linux architecture for standalone WSL setup' >&2; exit 2 ;;", "esac",
76
+ "temporary=$(mktemp -d)",
77
+ "trap 'rm -rf -- \"$temporary\"' EXIT",
78
+ `nix shell --no-write-lock-file github:NixOS/nixpkgs/0bb2eedc20e4739f29e8045034f2828ad7054f8f#curl --command curl --fail --location --proto '=https' --proto-redir '=https' --output "$temporary/winix" "https://github.com/adrifer/winix/releases/download/v${standalone.version}/$asset"`,
79
+ "printf '%s %s\\n' \"$checksum\" \"$temporary/winix\" | sha256sum --check --status || { echo 'Standalone Linux executable checksum mismatch' >&2; exit 2; }",
80
+ `directory=/var/lib/winix/runtime/${standalone.version}`,
81
+ 'for parent in /var/lib/winix /var/lib/winix/runtime "$directory"; do',
82
+ ' [[ ! -L "$parent" ]] || { echo "Unsafe standalone runtime directory: $parent" >&2; exit 2; }',
83
+ ' mkdir -p -- "$parent"; [[ $(stat -c %u "$parent") == 0 ]] && (( (8#$(stat -c %a "$parent") & 0022) == 0 )) || { echo "Unsafe runtime directory permissions: $parent" >&2; exit 2; }; chmod 755 -- "$parent"',
84
+ "done",
85
+ '[[ ! -L "$directory/winix" && ! -L "$directory/winix.bin" ]] || { echo "Unsafe standalone runtime path" >&2; exit 2; }',
86
+ 'destination=$(mktemp "$directory/winix.XXXXXX")',
87
+ 'trap \'rm -f -- "$destination"; rm -rf -- "$temporary"\' EXIT',
88
+ 'install -T -m 755 -- "$temporary/winix" "$destination"',
89
+ 'nix build --no-write-lock-file --out-link "$directory/libc" github:NixOS/nixpkgs/0bb2eedc20e4739f29e8045034f2828ad7054f8f#glibc.out',
90
+ 'nix build --no-write-lock-file --out-link "$directory/compiler" github:NixOS/nixpkgs/0bb2eedc20e4739f29e8045034f2828ad7054f8f#stdenv.cc.cc.lib',
91
+ 'mv -fT -- "$destination" "$directory/winix.bin"',
92
+ 'destination=$(mktemp "$directory/launch.XXXXXX")',
93
+ 'printf \'#!/usr/bin/env bash\\nset -euo pipefail\\nexport WINIX_STANDALONE_EXECUTABLE=%q\\nexec %q --argv0 %q --library-path %q %q "$@"\\n\' "$directory/winix" "$directory/libc/lib/$linker" "$directory/winix.bin" "$directory/libc/lib:$directory/compiler/lib" "$directory/winix.bin" > "$destination"',
94
+ 'chmod 755 -- "$destination"; mv -fT -- "$destination" "$directory/winix"',
95
+ 'nix shell --no-write-lock-file github:NixOS/nixpkgs/0bb2eedc20e4739f29e8045034f2828ad7054f8f#git --command "$directory/winix"',
96
+ ];
97
+ }
98
+ else {
99
+ const extension = import.meta.url.endsWith(".ts") ? "ts" : "js";
100
+ const source = readFileSync(new URL(`./wsl-setup-runtime.${extension}`, import.meta.url), "utf8");
101
+ const runtime = extension === "ts"
102
+ ? createRequire(import.meta.url)("node:module").stripTypeScriptTypes(source, { mode: "transform" })
103
+ : source;
104
+ launch = [
105
+ `export WINIX_WSL_SETUP_RUNTIME='${Buffer.from(runtime + "\nawait dispatchWslSetup();\n").toString("base64")}'`,
106
+ "exec nix shell --no-write-lock-file github:NixOS/nixpkgs/0bb2eedc20e4739f29e8045034f2828ad7054f8f#git github:NixOS/nixpkgs/0bb2eedc20e4739f29e8045034f2828ad7054f8f#nodejs_24 --command node --input-type=module --eval \"$(printf '%s' \"$WINIX_WSL_SETUP_RUNTIME\" | base64 --decode)\"",
107
+ ];
108
+ }
66
109
  const probe = [
67
110
  "set -euo pipefail",
68
111
  "state=/var/lib/winix/wsl-setup",
@@ -78,9 +121,8 @@ export function wslSetupPrelude(setup, pin) {
78
121
  const activate = [
79
122
  probe.replace("if [[ ! -f \"$state/complete\" ]]; then exit 3; fi", "if [[ -f \"$state/complete\" ]]; then") + "\nexit 0\nfi",
80
123
  `export WINIX_WSL_SETUP_REQUEST='${request}'`,
81
- `export WINIX_WSL_SETUP_RUNTIME='${encodedRuntime}'`,
82
124
  'export NIX_CONFIG="${NIX_CONFIG:+$NIX_CONFIG$\'\\n\'}extra-experimental-features = nix-command flakes"',
83
- "exec nix shell --no-write-lock-file github:NixOS/nixpkgs/0bb2eedc20e4739f29e8045034f2828ad7054f8f#git github:NixOS/nixpkgs/0bb2eedc20e4739f29e8045034f2828ad7054f8f#nodejs_24 --command node --input-type=module --eval \"$(printf '%s' \"$WINIX_WSL_SETUP_RUNTIME\" | base64 --decode)\"",
125
+ ...launch,
84
126
  ].join("\n");
85
127
  return [
86
128
  "function Invoke-WinixWslSetup([bool]$TestOnly) {",
@@ -3,6 +3,7 @@ import { mkdir, readFile, writeFile } from "node:fs/promises";
3
3
  import { existsSync } from "node:fs";
4
4
  import { fileURLToPath } from "node:url";
5
5
  import { installSkill } from "./install.js";
6
+ import { standaloneRuntime } from "../../runtime.js";
6
7
  export async function init(cwd, opts) {
7
8
  await mkdir(cwd, { recursive: true });
8
9
  const versionRange = await resolveWinixVersionRange();
@@ -15,7 +16,7 @@ export async function init(cwd, opts) {
15
16
  console.log("✓ Initialized Winix project");
16
17
  console.log("");
17
18
  console.log("Next steps:");
18
- console.log(" npm install");
19
+ console.log(standaloneRuntime() ? " winix check" : " npm install");
19
20
  }
20
21
  async function writeIfAllowed(path, content, force) {
21
22
  if (existsSync(path) && !force) {
@@ -25,6 +26,9 @@ async function writeIfAllowed(path, content, force) {
25
26
  }
26
27
  const FALLBACK_VERSION_RANGE = "^0.1.0";
27
28
  export async function resolveWinixVersionRange() {
29
+ const standalone = standaloneRuntime();
30
+ if (standalone)
31
+ return `^${standalone.version}`;
28
32
  try {
29
33
  const here = currentDir();
30
34
  // Compiled layout: dist/cli/commands/init.js → ../../../package.json
package/dist/cli/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  import { parseArgs } from "node:util";
4
4
  import { apply } from "./commands/apply.js";
5
5
  import { check } from "./commands/check.js";
6
- import { init } from "./commands/init.js";
6
+ import { init, resolveWinixVersionRange } from "./commands/init.js";
7
7
  import { installSkill } from "./commands/install.js";
8
8
  import { inspect } from "./commands/inspect.js";
9
9
  import { switchCommand } from "./commands/switch.js";
@@ -23,9 +23,14 @@ const { positionals, values } = parseArgs({
23
23
  skill: { type: "boolean", default: false },
24
24
  "escape-report": { type: "boolean", default: false },
25
25
  help: { type: "boolean", short: "h", default: false },
26
+ version: { type: "boolean", short: "v", default: false },
26
27
  },
27
28
  });
28
29
  const command = positionals[0];
30
+ if (values.version) {
31
+ console.log((await resolveWinixVersionRange()).replace(/^\^/, ""));
32
+ process.exit(0);
33
+ }
29
34
  if (values.skill) {
30
35
  if (command) {
31
36
  console.error("The --skill option does not accept a command.");
@@ -59,6 +64,7 @@ Options:
59
64
  --force Overwrite files (init, install skill)
60
65
  --skill Print version-matched agent instructions
61
66
  -h, --help Show this help
67
+ -v, --version Show this binary/package version
62
68
 
63
69
  Examples:
64
70
  winix init
@@ -0,0 +1,10 @@
1
+ export interface StandaloneAsset {
2
+ name: string;
3
+ sha256: string;
4
+ }
5
+ export interface StandaloneRuntime {
6
+ version: string;
7
+ linuxAssets: Partial<Record<"x64" | "arm64", StandaloneAsset>>;
8
+ }
9
+ export declare function configureStandaloneRuntime(runtime: StandaloneRuntime): void;
10
+ export declare function standaloneRuntime(): StandaloneRuntime | undefined;
@@ -0,0 +1,9 @@
1
+ let standalone;
2
+ export function configureStandaloneRuntime(runtime) {
3
+ if (standalone)
4
+ throw new Error("Standalone runtime is already configured");
5
+ standalone = runtime;
6
+ }
7
+ export function standaloneRuntime() {
8
+ return standalone;
9
+ }
package/dist/skill.js CHANGED
@@ -311,13 +311,15 @@ Resources return handles that can be passed through \`dependsOn\`.
311
311
  configDirectory: "winix", host: "wsl-work", user: "alice",
312
312
  checkout: "/home/alice/dotfiles" }.
313
313
  Repository URLs must be HTTPS without credentials; authentication must already
314
- work inside Linux. Commit package.json, package-lock.json and flake.lock in
315
- configDirectory and use a released SDK supporting setup. The Linux host must
314
+ work inside Linux. Commit flake.lock in configDirectory; npm-based Winix also
315
+ requires package.json/package-lock.json and a released SDK supporting setup.
316
+ Official standalone Windows binaries use a matching, checksum-verified Linux
317
+ binary and pinned Nix runtime libraries instead of Node/npm. The Linux host must
316
318
  explicitly enable/import NixOS-WSL, declare system.stateVersion, and match the
317
319
  distro architecture. user selects a declared normal account (inferred from
318
320
  Home Manager or the sole normal account when omitted); checkout defaults to
319
321
  its home/dotfiles and must remain inside that home. Home Manager identity/home
320
- must agree. Git/npm/config evaluation run unprivileged; root activates the
322
+ must agree. Git/config evaluation (and npm when used) run unprivileged; root activates the
321
323
  account-only bootstrap, assigns checkout ownership, then activates the full
322
324
  Linux host, which must set wsl.defaultUser to that account. No password or
323
325
  sudo policy is supplied. Missing external account secrets fail explicitly.
@@ -366,6 +368,16 @@ For fresh Windows prerequisites, \`scripts/bootstrap-windows.ps1\` runs in built
366
368
  Windows PowerShell 5.1 or PowerShell 7. App Installer/WinGet is the initial
367
369
  prerequisite. \`-Check\` is read-only; install mode confirms missing/outdated
368
370
  Git/Node/PowerShell/DSC installation and enables WinGet configuration support.
371
+ \`-Standalone\` skips all Node/npm checks and installations for executable users;
372
+ it cannot be combined with \`-UseNvm\`. Release executables embed the SDK/runtime,
373
+ load local TS/JS imports and Node builtins without node_modules, and never
374
+ automatically download third-party npm imports. The executable version determines
375
+ the SDK, not package-lock.json; editor TypeScript dependencies remain optional.
376
+ Choose versioned GitHub release assets, verify SHA256SUMS, and respect execution
377
+ policies (binaries are not code-signed). Windows WSL setup embeds matching Linux
378
+ hashes; custom single-target builds cannot provision WSL. Linux assets use glibc;
379
+ automatic WSL setup prepares NixOS's linker explicitly. No ARM64 execution or
380
+ fresh-image activation is claimed.
369
381
  \`-UseNvm\` chooses NVM for Windows instead of standalone Node; \`-Yes\` accepts
370
382
  bootstrap changes. It never installs Winix globally, activates a host, provisions
371
383
  WSL, reboots, or changes execution policy persistently. Prepare the config and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adrifer/winix",
3
- "version": "0.2.4-preview.0",
3
+ "version": "0.2.4-preview.1",
4
4
  "description": "TypeScript-first system configuration for NixOS, nix-darwin, and Home Manager",
5
5
  "license": "MIT",
6
6
  "author": "Adrian Fernandez",
@@ -54,6 +54,7 @@
54
54
  "scripts": {
55
55
  "clean": "node scripts/clean-dist.mjs",
56
56
  "build": "npm run clean && tsc -p tsconfig.build.json && node scripts/fix-dts-imports.mjs",
57
+ "build:standalone": "node scripts/build-standalone.mjs",
57
58
  "dev": "tsc --watch",
58
59
  "test": "vitest",
59
60
  "lint": "eslint src/",
@@ -8,12 +8,15 @@ Only inspect prerequisites. No installation or configuration enablement is perfo
8
8
  Accept prerequisite installation and WinGet configuration enablement without prompting.
9
9
  .PARAMETER UseNvm
10
10
  Install/select Node LTS through NVM for Windows instead of standalone Node.js.
11
+ .PARAMETER Standalone
12
+ Check/install only native prerequisites for the Winix executable; Node.js/npm are not needed.
11
13
  #>
12
14
  [CmdletBinding()]
13
15
  param(
14
16
  [switch]$Check,
15
17
  [switch]$Yes,
16
- [switch]$UseNvm
18
+ [switch]$UseNvm,
19
+ [switch]$Standalone
17
20
  )
18
21
 
19
22
  function Get-WinixBootstrapApplication {
@@ -55,6 +58,7 @@ function Update-WinixBootstrapPath {
55
58
  }
56
59
 
57
60
  function Get-WinixBootstrapTools {
61
+ param([switch]$Standalone)
58
62
  $tools = @(
59
63
  @{ Id = 'Git.Git'; Command = 'git.exe'; Minimum = '2.0.0' }
60
64
  @{ Id = 'OpenJS.NodeJS.LTS'; Command = 'node.exe'; Minimum = '22.13.0' }
@@ -62,6 +66,7 @@ function Get-WinixBootstrapTools {
62
66
  @{ Id = 'Microsoft.DSC'; Command = 'dsc.exe'; Minimum = '3.2.0' }
63
67
  )
64
68
  foreach ($tool in $tools) {
69
+ if ($Standalone -and $tool.Command -eq 'node.exe') { continue }
65
70
  $path = Get-WinixBootstrapApplication $tool.Command
66
71
  $version = $null
67
72
  if ($path) {
@@ -86,19 +91,21 @@ function Get-WinixBootstrapTools {
86
91
  }
87
92
 
88
93
  function Test-WinixBootstrapCapabilities {
89
- param([string]$WinGet)
94
+ param([string]$WinGet, [switch]$Standalone)
90
95
  $help = (Invoke-WinixBootstrapNative $WinGet @('configure', '--help')) -join "`n"
91
96
  if ($help -notmatch '--enable\b') {
92
97
  throw 'Update App Installer from Microsoft Store: this WinGet lacks configuration enablement support.'
93
98
  }
94
- $npm = Get-WinixBootstrapApplication 'npm.cmd'
95
- if (-not $npm) { throw 'npm.cmd is unavailable. Repair the Node.js installation or open a new terminal, then rerun.' }
96
- Invoke-WinixBootstrapNative $npm @('--version') | Out-Null
97
- $node = Get-WinixBootstrapApplication 'node.exe'
98
- Invoke-WinixBootstrapNative $node @(
99
- '--experimental-transform-types', '--no-warnings', '--input-type=module', '--eval',
100
- "import { stripTypeScriptTypes } from 'node:module'; stripTypeScriptTypes('const x: number = 1');"
101
- ) | Out-Null
99
+ if (-not $Standalone) {
100
+ $npm = Get-WinixBootstrapApplication 'npm.cmd'
101
+ if (-not $npm) { throw 'npm.cmd is unavailable. Repair the Node.js installation or open a new terminal, then rerun.' }
102
+ Invoke-WinixBootstrapNative $npm @('--version') | Out-Null
103
+ $node = Get-WinixBootstrapApplication 'node.exe'
104
+ Invoke-WinixBootstrapNative $node @(
105
+ '--experimental-transform-types', '--no-warnings', '--input-type=module', '--eval',
106
+ "import { stripTypeScriptTypes } from 'node:module'; stripTypeScriptTypes('const x: number = 1');"
107
+ ) | Out-Null
108
+ }
102
109
  $pwsh = Get-WinixBootstrapApplication 'pwsh.exe'
103
110
  $script = @'
104
111
  $ErrorActionPreference = 'Stop'
@@ -120,12 +127,14 @@ Get-PSResourceRepository -Name PSGallery -ErrorAction Stop | Out-Null
120
127
  throw "Required DSC resource is unavailable: $name. Update App Installer/DSC, open a new terminal, and rerun."
121
128
  }
122
129
  }
123
- Write-Host 'OK: npm, Node TypeScript support, PSResourceGet/PSGallery, and required DSC resources.'
130
+ if (-not $Standalone) { Write-Host 'OK: npm and Node TypeScript support.' }
131
+ Write-Host 'OK: PSResourceGet/PSGallery and required DSC resources.'
124
132
  }
125
133
 
126
134
  function Invoke-WinixWindowsBootstrap {
127
- param([switch]$Check, [switch]$Yes, [switch]$UseNvm)
135
+ param([switch]$Check, [switch]$Yes, [switch]$UseNvm, [switch]$Standalone)
128
136
  $ErrorActionPreference = 'Stop'
137
+ if ($Standalone -and $UseNvm) { throw '-Standalone and -UseNvm cannot be combined.' }
129
138
  if ([Environment]::OSVersion.Platform -ne [PlatformID]::Win32NT) {
130
139
  throw 'This bootstrap is for native Windows, not WSL. Run it from Windows PowerShell or PowerShell 7.'
131
140
  }
@@ -140,7 +149,7 @@ Then rerun this bootstrap. No prerequisites have been installed.
140
149
  '@
141
150
  }
142
151
  Write-Host ("WinGet: " + ((Invoke-WinixBootstrapNative $winget @('--version')) -join ' '))
143
- $tools = @(Get-WinixBootstrapTools)
152
+ $tools = @(Get-WinixBootstrapTools -Standalone:$Standalone)
144
153
  foreach ($tool in $tools) {
145
154
  $installed = if ($tool.Version) { $tool.Version.ToString() } else { 'missing' }
146
155
  $status = if ($tool.Ready) { 'OK' } else { 'NEEDED' }
@@ -192,23 +201,23 @@ Then rerun this bootstrap. No prerequisites have been installed.
192
201
  ) | ForEach-Object { Write-Host $_ }
193
202
  }
194
203
  Update-WinixBootstrapPath
195
- $updated = @(Get-WinixBootstrapTools | Where-Object { $_.Id -eq $tool.Id })
204
+ $updated = @(Get-WinixBootstrapTools -Standalone:$Standalone | Where-Object { $_.Id -eq $tool.Id })
196
205
  if ($updated.Count -ne 1 -or -not $updated[0].Ready) {
197
206
  throw "Installation did not make $($tool.Command) ready. Open a new terminal or restart if requested, then rerun."
198
207
  }
199
208
  }
200
- Invoke-WinixBootstrapNative $winget @('configure', '--enable', '--disable-interactivity') |
209
+ Invoke-WinixBootstrapNative $winget @('configure', '--enable') |
201
210
  ForEach-Object { Write-Host $_ }
202
211
  Update-WinixBootstrapPath
203
212
  }
204
- Test-WinixBootstrapCapabilities $winget
213
+ Test-WinixBootstrapCapabilities $winget -Standalone:$Standalone
205
214
  Write-Host 'Prerequisite checks passed. No Winix host was activated.'
206
215
  Write-Host 'Open a new PowerShell 7 terminal before preparing the Winix/config checkout and running winix check or switch --dry.'
207
216
  }
208
217
 
209
218
  if ($MyInvocation.InvocationName -ne '.') {
210
219
  try {
211
- Invoke-WinixWindowsBootstrap -Check:$Check -Yes:$Yes -UseNvm:$UseNvm
220
+ Invoke-WinixWindowsBootstrap -Check:$Check -Yes:$Yes -UseNvm:$UseNvm -Standalone:$Standalone
212
221
  } catch {
213
222
  Write-Error $_ -ErrorAction Continue
214
223
  exit 1