@adrifer/winix 0.3.0-preview.2 → 0.3.0-preview.4
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 +105 -23
- package/dist/backends/windows/index.js +22 -31
- package/dist/backends/windows/lockfile.d.ts +3 -3
- package/dist/backends/windows/lockfile.js +16 -14
- package/dist/backends/windows/powershell.d.ts +1 -1
- package/dist/backends/windows/powershell.js +20 -9
- package/dist/backends/windows/wsl-setup.d.ts +1 -0
- package/dist/backends/windows/wsl-setup.js +9 -5
- package/dist/backends/windows/wsl.d.ts +2 -1
- package/dist/backends/windows/wsl.js +117 -35
- package/dist/cli/commands/apply.js +3 -3
- package/dist/cli/commands/bootstrap.d.ts +1 -1
- package/dist/cli/commands/bootstrap.js +2 -7
- package/dist/cli/commands/switch.js +2 -3
- package/dist/cli/commands/update.js +1 -1
- package/dist/cli/index.d.ts +1 -1
- package/dist/cli/index.js +29 -7
- package/dist/cli/loader.d.ts +1 -0
- package/dist/cli/loader.js +2 -2
- package/dist/cli/node.d.ts +1 -0
- package/dist/cli/node.js +8 -0
- package/dist/cli/windows-state.d.ts +11 -0
- package/dist/cli/windows-state.js +48 -2
- package/dist/helpers/windows-repositories.d.ts +2 -0
- package/dist/helpers/windows-repositories.js +4 -0
- package/dist/helpers/windows.d.ts +4 -0
- package/dist/helpers/windows.js +17 -2
- package/dist/skill.js +39 -7
- package/dist/types/windows.d.ts +7 -0
- package/package.json +6 -2
- package/scripts/bootstrap-windows.ps1 +10 -4
- package/scripts/winix.mjs +16 -0
package/dist/helpers/windows.js
CHANGED
|
@@ -965,7 +965,11 @@ export const windows = {
|
|
|
965
965
|
wsl: Object.assign((opts = {}) => {
|
|
966
966
|
normalizeFileOpts(opts, "windows.wsl");
|
|
967
967
|
const content = opts.config === undefined ? undefined : serializeWslConfig(opts.config);
|
|
968
|
-
const
|
|
968
|
+
const runtime = windows.package("Microsoft.WSL");
|
|
969
|
+
const dependencies = opts.dependsOn === undefined ? []
|
|
970
|
+
: Array.isArray(opts.dependsOn) ? opts.dependsOn : [opts.dependsOn];
|
|
971
|
+
const enabled = optionalFeatures(["Microsoft-Windows-Subsystem-Linux", "VirtualMachinePlatform"], { dependsOn: [runtime, ...dependencies] });
|
|
972
|
+
enabled.windows.packages = runtime.windows.packages;
|
|
969
973
|
if (content === undefined)
|
|
970
974
|
return enabled;
|
|
971
975
|
const resource = normalizeFileText(knownFolder("userProfile", ".wslconfig"), content, {
|
|
@@ -976,6 +980,7 @@ export const windows = {
|
|
|
976
980
|
resource.name = "WSL configuration";
|
|
977
981
|
resource.dependsOn = [enabled.__winixHandle, ...(resource.dependsOn ?? [])];
|
|
978
982
|
const configured = dscHandle(resource);
|
|
983
|
+
configured.windows.packages = enabled.windows.packages;
|
|
979
984
|
configured.windows.dsc.unshift(...enabled.windows.dsc);
|
|
980
985
|
return configured;
|
|
981
986
|
}, {
|
|
@@ -989,12 +994,17 @@ export const windows = {
|
|
|
989
994
|
(spec.default !== undefined && typeof spec.default !== "boolean")) {
|
|
990
995
|
throw new Error("windows.wsl.distro requires source 'nixos-wsl', an absolute/environment/known-folder installLocation, and an optional boolean default");
|
|
991
996
|
}
|
|
997
|
+
if (spec.host !== undefined && (typeof spec.host !== "string" ||
|
|
998
|
+
!/^[a-z0-9][a-z0-9._-]*$/i.test(spec.host))) {
|
|
999
|
+
throw new Error("windows.wsl.distro host must be a valid expected Linux hostname");
|
|
1000
|
+
}
|
|
992
1001
|
return dscHandle(withDscMetadata(withDscToken({
|
|
993
1002
|
resourceType: POWERSHELL_SCRIPT_RESOURCE,
|
|
994
1003
|
name: `WSL distro ${name}`,
|
|
995
1004
|
dependsOn: resolveDependsOn(spec.dependsOn),
|
|
996
1005
|
}), { kind: "wsl-distro", distro: {
|
|
997
1006
|
name, source: spec.source, installLocation: spec.installLocation, default: spec.default ?? false,
|
|
1007
|
+
...(spec.host === undefined ? {} : { host: spec.host }),
|
|
998
1008
|
...(spec.setup === undefined ? {} : { setup: normalizeWslSetup(spec.setup) }),
|
|
999
1009
|
} }));
|
|
1000
1010
|
},
|
|
@@ -1025,11 +1035,16 @@ export const windows = {
|
|
|
1025
1035
|
if (repository !== undefined && (typeof repository !== "string" || !/^[a-z0-9][a-z0-9._-]*$/i.test(repository))) {
|
|
1026
1036
|
throw new Error("windows.powershell.module repository must be a registered repository name");
|
|
1027
1037
|
}
|
|
1038
|
+
if (opts.prerelease !== undefined && typeof opts.prerelease !== "boolean") {
|
|
1039
|
+
throw new Error("windows.powershell.module prerelease must be a boolean");
|
|
1040
|
+
}
|
|
1028
1041
|
const resource = withDscMetadata(withDscToken({
|
|
1029
1042
|
resourceType: POWERSHELL_SCRIPT_RESOURCE,
|
|
1030
1043
|
name: `PowerShell module ${name}`,
|
|
1031
1044
|
dependsOn: resolveDependsOn(opts.dependsOn),
|
|
1032
|
-
}), { kind: "powershell-module", module: {
|
|
1045
|
+
}), { kind: "powershell-module", module: {
|
|
1046
|
+
name, repository, ...(opts.prerelease !== undefined ? { prerelease: opts.prerelease } : {}),
|
|
1047
|
+
} });
|
|
1033
1048
|
return dscHandle(resource);
|
|
1034
1049
|
},
|
|
1035
1050
|
},
|
package/dist/skill.js
CHANGED
|
@@ -260,7 +260,10 @@ Resources return handles that can be passed through \`dependsOn\`.
|
|
|
260
260
|
- \`windows.package()\` installs a winget or Microsoft Store package. A string
|
|
261
261
|
means a floating winget package ID. The object form accepts \`id\`,
|
|
262
262
|
\`source\`, \`version\`, and dependency options.
|
|
263
|
-
- \`windows.setting()\` manages supported Windows settings.
|
|
263
|
+
- \`windows.setting()\` manages supported Windows settings. Symlinks automatically
|
|
264
|
+
depend on same-host typed settings declaring DeveloperMode: true. Declare that
|
|
265
|
+
policy explicitly; symlinks never enable Developer Mode themselves. Without the
|
|
266
|
+
declaration, existing Developer Mode or elevation is still required.
|
|
264
267
|
- \`windows.env.set()\` and \`windows.env.remove()\` manage environment
|
|
265
268
|
variables.
|
|
266
269
|
- \`windows.path.add()\` and \`windows.path.remove()\` manage PATH entries.
|
|
@@ -299,19 +302,31 @@ Resources return handles that can be passed through \`dependsOn\`.
|
|
|
299
302
|
- \`windows.dsc()\` declares an arbitrary DSC resource.
|
|
300
303
|
- \`windows.optionalFeature()\` enables/disables a named Windows optional feature;
|
|
301
304
|
enabled defaults to true. Changes require elevation, never reboot automatically.
|
|
302
|
-
- \`windows.wsl()\`
|
|
305
|
+
- \`windows.wsl()\` declares the Microsoft.WSL package with normal package locking
|
|
306
|
+
and enables the WSL and Virtual Machine Platform features. A separate package
|
|
307
|
+
declaration may customize the runtime's package options.
|
|
303
308
|
Options are config, backup, force, and dependsOn. The optional config manages
|
|
304
309
|
the full current-user .wslconfig with file overwrite protections; omitting it
|
|
305
310
|
leaves the file untouched. The returned handle covers the complete setup.
|
|
306
311
|
If a reboot is needed, restart Windows manually and rerun switch.
|
|
307
312
|
It never shuts down WSL; restart WSL manually when configuration changes.
|
|
308
|
-
- \`windows.wsl.distro()\`
|
|
309
|
-
installLocation, optional default and dependsOn. Declare windows.wsl()
|
|
310
|
-
|
|
313
|
+
- \`windows.wsl.distro()\` creates or adopts a named distro with source "nixos-wsl",
|
|
314
|
+
installLocation, optional host, default and dependsOn. Declare windows.wsl() in the
|
|
315
|
+
same host; features, config, and runtime become
|
|
311
316
|
automatic dependencies.
|
|
312
317
|
Images for x64/ARM64 are verified against winix-windows.lock wslImages pins.
|
|
313
318
|
Update with winix update --windows nixos-wsl. Updates never reinstall an
|
|
314
|
-
existing distro.
|
|
319
|
+
existing distro. An untracked existing registration is automatically adopted
|
|
320
|
+
only if it is WSL 2, runs NixOS, and its Linux hostname matches host (defaults
|
|
321
|
+
to setup.host). An expected hostname is required for adoption, not creation.
|
|
322
|
+
No Git/user/checkout/config inspection. Mismatches fail without replacement.
|
|
323
|
+
Adoption preserves actual location and defaults, skips setup permanently, and
|
|
324
|
+
leaves Linux activation manual. Probing may start WSL but makes no Linux changes.
|
|
325
|
+
Local AppData Winix/wsl-registrations records GUID/location/adoption/hostname;
|
|
326
|
+
later runs reject changed or missing registrations and hostname mismatches.
|
|
327
|
+
Legacy Winix import markers retain their provisioning behavior.
|
|
328
|
+
check/dry are static only; creation pins may still resolve. Adoption is not
|
|
329
|
+
available in preview.3.
|
|
315
330
|
Removing a declaration never unregisters a distro or deletes its data.
|
|
316
331
|
Optional setup opts into trusted first-run Linux provisioning:
|
|
317
332
|
{ repository: "https://github.com/example/dotfiles.git", ref: "main",
|
|
@@ -357,6 +372,13 @@ package/module/image/repository pins (all when omitted, nixos-wsl for images,
|
|
|
357
372
|
wsl-setup for setup commits); --dry reports without writing.
|
|
358
373
|
Keep the lock in version control. Installation still requires network access
|
|
359
374
|
when the locked package/module is not installed.
|
|
375
|
+
Typed \`windows.setting(...)\` implicitly locks Microsoft.Windows.Settings through
|
|
376
|
+
the same host-policy/source-aware module mechanism, with prereleases allowed.
|
|
377
|
+
\`windows.powershell.module(name, { prerelease: true })\` opts other modules in;
|
|
378
|
+
stable-only declarations reject prerelease pins. Exact numeric version and
|
|
379
|
+
prerelease label are checked. Do not put versions in handwritten settings config.
|
|
380
|
+
Side-by-side DSC adapted-module selection/native Settings activation is unverified;
|
|
381
|
+
installing the pin alone does not guarantee which installed module DSC selects.
|
|
360
382
|
|
|
361
383
|
Native Windows \`winix switch\` keeps a separate per-user/machine applied-state
|
|
362
384
|
inventory in LocalAppData/Winix, shared across recorded workspace/host activations.
|
|
@@ -373,6 +395,12 @@ External shortcut edits/package-version drift block reconciliation.
|
|
|
373
395
|
without deleting the resource; --dry previews. Do not copy applied state to a
|
|
374
396
|
new machine or infer ownership from version locks. Direct DSC/script activation
|
|
375
397
|
bypasses this tracking. Files, modules, env and PATH cleanup are not tracked.
|
|
398
|
+
\`state forget\` retains owner requirements; it cannot repair checkout moves or
|
|
399
|
+
host renames. Run \`winix state owners\`, then from the new config checkout use
|
|
400
|
+
\`winix state migrate-owner <old-owner-id> --host NEW --dry\` and explicitly
|
|
401
|
+
confirm with \`--yes\` instead of \`--dry\`. This transfers recorded requirements,
|
|
402
|
+
not resources, and preserves snapshots, external status, other owners, drift
|
|
403
|
+
checks and later removal confirmation. It does not evaluate config or activate.
|
|
376
404
|
|
|
377
405
|
For fresh Windows prerequisites, \`scripts/bootstrap-windows.ps1\` runs in built-in
|
|
378
406
|
Windows PowerShell 5.1 or PowerShell 7. App Installer/WinGet is the initial
|
|
@@ -412,10 +440,14 @@ Do not run real bootstrap/activation as a development check on a shared machine.
|
|
|
412
440
|
\`winix bootstrap --host HOST\` performs the checkout validation/preview/confirmation
|
|
413
441
|
phase. Its generated \`.winix/bin/winix.ps1\` or \`.winix/bin/winix\` launcher invokes
|
|
414
442
|
\`winix run <args>\`, rereading the exact pin on every invocation. A matching
|
|
415
|
-
optional node_modules SDK uses its own CLI under
|
|
443
|
+
optional node_modules SDK uses its own CLI under supported stable Node
|
|
444
|
+
22.13+ (22.x), 24.x or 26.x; stale/corrupt
|
|
416
445
|
local packages fail, never silently fall back. Otherwise the standalone must
|
|
417
446
|
match the manifest; rerun bootstrap after changing the pin. The user may run
|
|
418
447
|
\`npm ci\` explicitly using an approved source, then use normal local npm scripts.
|
|
448
|
+
The npm launcher enables transformation on Node 22/24, omits the removed
|
|
449
|
+
transform flag on 26, and rejects unsupported majors. Node 26 accepts erasable
|
|
450
|
+
TypeScript only; use Node 24 for enums/parameter properties in config/local imports.
|
|
419
451
|
|
|
420
452
|
On existing NixOS/NixOS-WSL, \`bash bootstrap-nixos.sh\` (from
|
|
421
453
|
\`scripts/bootstrap-nixos.sh\` or a reviewed release asset) opens a temporary
|
package/dist/types/windows.d.ts
CHANGED
|
@@ -20,6 +20,8 @@ export interface WinPowerShellModule {
|
|
|
20
20
|
name: string;
|
|
21
21
|
/** Omitted repositories inherit the host policy after all fragments merge. */
|
|
22
22
|
repository?: string;
|
|
23
|
+
/** Allow prereleases when resolving the lock; installations still use an exact pin. */
|
|
24
|
+
prerelease?: boolean;
|
|
23
25
|
}
|
|
24
26
|
export interface WinPowerShellRepositoryPolicy {
|
|
25
27
|
/** Named HTTPS feeds to register for the current Windows user. No credentials in URLs. */
|
|
@@ -33,8 +35,13 @@ export interface WinPowerShellRepositoryPolicy {
|
|
|
33
35
|
export interface WinWslDistro {
|
|
34
36
|
name: string;
|
|
35
37
|
source: "nixos-wsl";
|
|
38
|
+
/** Creation destination; an adopted distro keeps its registered location. */
|
|
36
39
|
installLocation: WinFilePath;
|
|
40
|
+
/** Default selection is managed only for Winix-created distros. */
|
|
37
41
|
default: boolean;
|
|
42
|
+
/** Expected Linux hostname for adoption; defaults to setup.host. */
|
|
43
|
+
host?: string;
|
|
44
|
+
/** First-run setup for Winix-created distros; never run for adopted distros. */
|
|
38
45
|
setup?: WinWslSetup;
|
|
39
46
|
}
|
|
40
47
|
export interface WinWslSetup {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adrifer/winix",
|
|
3
|
-
"version": "0.3.0-preview.
|
|
3
|
+
"version": "0.3.0-preview.4",
|
|
4
4
|
"description": "TypeScript-first system configuration for NixOS, nix-darwin, and Home Manager",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Adrian Fernandez",
|
|
@@ -40,9 +40,13 @@
|
|
|
40
40
|
}
|
|
41
41
|
},
|
|
42
42
|
"bin": {
|
|
43
|
-
"winix": "
|
|
43
|
+
"winix": "scripts/winix.mjs"
|
|
44
|
+
},
|
|
45
|
+
"engines": {
|
|
46
|
+
"node": "^22.13.0 || ^24.0.0 || ^26.0.0"
|
|
44
47
|
},
|
|
45
48
|
"files": [
|
|
49
|
+
"scripts/winix.mjs",
|
|
46
50
|
"scripts/bootstrap-windows.ps1",
|
|
47
51
|
"scripts/bootstrap-nixos.sh",
|
|
48
52
|
"scripts/bootstrap-linux.sh",
|
|
@@ -94,12 +94,14 @@ function Get-WinixBootstrapTools {
|
|
|
94
94
|
throw "Prerelease $($tool.Command) is not supported by this bootstrap. Install a stable release."
|
|
95
95
|
}
|
|
96
96
|
}
|
|
97
|
+
$ready = $null -ne $version -and $version -ge [version]$tool.Minimum
|
|
98
|
+
if ($tool.Command -eq 'node.exe' -and $ready -and $version.Major -notin @(22, 24, 26)) { $ready = $false }
|
|
97
99
|
[pscustomobject]@{
|
|
98
100
|
Id = $tool.Id
|
|
99
101
|
Command = $tool.Command
|
|
100
102
|
Path = $path
|
|
101
103
|
Version = $version
|
|
102
|
-
Ready = $
|
|
104
|
+
Ready = $ready
|
|
103
105
|
Minimum = $tool.Minimum
|
|
104
106
|
}
|
|
105
107
|
}
|
|
@@ -116,10 +118,14 @@ function Test-WinixBootstrapCapabilities {
|
|
|
116
118
|
if (-not $npm) { throw 'npm.cmd is unavailable. Repair the Node.js installation or open a new terminal, then rerun.' }
|
|
117
119
|
Invoke-WinixBootstrapNative $npm @('--version') | Out-Null
|
|
118
120
|
$node = Get-WinixBootstrapApplication 'node.exe'
|
|
119
|
-
Invoke-WinixBootstrapNative $node @(
|
|
120
|
-
|
|
121
|
+
$nodeVersion = (Invoke-WinixBootstrapNative $node @('--version')) -join ''
|
|
122
|
+
if ($nodeVersion -notmatch '^v?(22|24|26)\.') { throw 'Winix npm supports stable Node 22.13+, 24.x or 26.x.' }
|
|
123
|
+
$nodeArgs = @(
|
|
124
|
+
'--no-warnings', '--input-type=module', '--eval',
|
|
121
125
|
"import { stripTypeScriptTypes } from 'node:module'; stripTypeScriptTypes('const x: number = 1');"
|
|
122
|
-
)
|
|
126
|
+
)
|
|
127
|
+
if ([int]$Matches[1] -lt 26) { $nodeArgs = @('--experimental-transform-types') + $nodeArgs }
|
|
128
|
+
Invoke-WinixBootstrapNative $node $nodeArgs | Out-Null
|
|
123
129
|
}
|
|
124
130
|
$pwsh = Get-WinixBootstrapApplication 'pwsh.exe'
|
|
125
131
|
$script = @'
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { spawnSync } from "node:child_process";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { nodeTypeArguments } from "../dist/cli/node.js";
|
|
5
|
+
|
|
6
|
+
try {
|
|
7
|
+
const result = spawnSync(process.execPath, [
|
|
8
|
+
...nodeTypeArguments(process.version), "--no-warnings",
|
|
9
|
+
fileURLToPath(new URL("../dist/cli/index.js", import.meta.url)), ...process.argv.slice(2),
|
|
10
|
+
], { stdio: "inherit" });
|
|
11
|
+
if (result.error) throw result.error;
|
|
12
|
+
process.exitCode = result.status ?? 1;
|
|
13
|
+
} catch (error) {
|
|
14
|
+
console.error(`Error: ${error.message}`);
|
|
15
|
+
process.exitCode = 1;
|
|
16
|
+
}
|