@adrifer/winix 0.3.0-preview.6 → 0.3.0-preview.9

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.
Files changed (53) hide show
  1. package/README.md +137 -12
  2. package/dist/backends/nix/index.d.ts +1 -0
  3. package/dist/backends/nix/index.js +18 -1
  4. package/dist/backends/windows/index.d.ts +9 -1
  5. package/dist/backends/windows/index.js +18 -11
  6. package/dist/backends/windows/lockfile.d.ts +3 -3
  7. package/dist/backends/windows/lockfile.js +4 -3
  8. package/dist/backends/windows/npm.d.ts +2 -0
  9. package/dist/backends/windows/npm.js +60 -0
  10. package/dist/backends/windows/powershell.d.ts +4 -2
  11. package/dist/backends/windows/powershell.js +152 -21
  12. package/dist/backends/windows/wsl-setup-runtime.d.ts +17 -1
  13. package/dist/backends/windows/wsl-setup-runtime.js +75 -11
  14. package/dist/backends/windows/wsl-setup.d.ts +7 -1
  15. package/dist/backends/windows/wsl-setup.js +29 -8
  16. package/dist/backends/windows/wsl.js +1 -1
  17. package/dist/cli/analysis.d.ts +11 -2
  18. package/dist/cli/analysis.js +35 -7
  19. package/dist/cli/commands/apply.d.ts +6 -1
  20. package/dist/cli/commands/apply.js +12 -6
  21. package/dist/cli/commands/check.js +11 -5
  22. package/dist/cli/commands/inspect.js +2 -2
  23. package/dist/cli/commands/switch.d.ts +7 -0
  24. package/dist/cli/commands/switch.js +58 -11
  25. package/dist/cli/commands/update.js +4 -4
  26. package/dist/cli/windows-package-versions.d.ts +2 -1
  27. package/dist/cli/windows-package-versions.js +12 -5
  28. package/dist/cli/windows-state.js +45 -17
  29. package/dist/core/types.d.ts +18 -0
  30. package/dist/evaluator/index.d.ts +5 -3
  31. package/dist/evaluator/index.js +30 -16
  32. package/dist/helpers/account.js +1 -7
  33. package/dist/helpers/home.d.ts +18 -0
  34. package/dist/helpers/home.js +39 -0
  35. package/dist/helpers/index.d.ts +2 -2
  36. package/dist/helpers/nix.d.ts +14 -0
  37. package/dist/helpers/nix.js +2 -0
  38. package/dist/helpers/platforms.d.ts +13 -0
  39. package/dist/helpers/platforms.js +35 -19
  40. package/dist/helpers/windows-npm.d.ts +3 -0
  41. package/dist/helpers/windows-npm.js +52 -0
  42. package/dist/helpers/windows.d.ts +39 -2
  43. package/dist/helpers/windows.js +62 -4
  44. package/dist/helpers/wsl-interop.d.ts +13 -0
  45. package/dist/helpers/wsl-interop.js +72 -0
  46. package/dist/helpers/wsl-repository.d.ts +12 -0
  47. package/dist/helpers/wsl-repository.js +93 -0
  48. package/dist/index.d.ts +4 -4
  49. package/dist/sdk/index.d.ts +5 -1
  50. package/dist/sdk/index.js +9 -2
  51. package/dist/skill.js +34 -2
  52. package/dist/types/windows.d.ts +17 -0
  53. package/package.json +1 -1
package/dist/skill.js CHANGED
@@ -150,8 +150,13 @@ Use one platform factory as the second argument to each host:
150
150
  - \`platforms.nixos({ system, stateVersion, allowUnfree, homeManager, hostname })\`
151
151
  - \`platforms.darwin({ system, stateVersion, allowUnfree, homeManager, homebrew, hostname })\`
152
152
  - \`platforms.windows({ hostname })\`
153
+ - \`platforms.wsl({ stateVersion, input, ... })\` is NixOS under WSL: the NixOS
154
+ options plus the NixOS-WSL module import (\`inputs.nixos-wsl\` unless \`input\`
155
+ names another Nix input) and \`wsl.enable = true\`. Declare the input, e.g.
156
+ \`nixosWsl: input("github:nix-community/NixOS-WSL", { follows: { nixpkgs: "nixpkgs" } })\`.
153
157
 
154
- The platform factories also expose \`.isActive\` during evaluation.
158
+ The platform factories also expose \`.isActive\` during evaluation. A WSL host is
159
+ still NixOS: \`platforms.nixos.isActive\` and \`platforms.wsl.isActive\` are both true.
155
160
 
156
161
  ## Fragment and merge rules
157
162
 
@@ -232,7 +237,11 @@ Available helpers:
232
237
  - \`home.env()\` for \`home.sessionVariables\`
233
238
  - \`home.path()\` for \`home.sessionPath\`
234
239
  - \`home.files()\`, \`home.configFile()\`, and \`home.configFiles()\`
235
- - \`home.symlink()\` for out-of-store symlink file values
240
+ - \`home.symlink()\` for out-of-store symlink file values: \`~/\` paths are
241
+ home-relative, \`./\` and \`../\` paths are relative to winix.config.ts (like
242
+ Windows file sources), e.g. \`home.symlink("../nvim/.config/nvim")\`
243
+ - \`home.wsl.gitCredentialManager({ paths })\` enables git and points
244
+ credential.helper at a shim for Git for Windows' Credential Manager
236
245
  - \`home.activation(name, { after, script })\`
237
246
  - \`home.raw()\` as a last-resort raw Nix escape hatch
238
247
 
@@ -257,6 +266,17 @@ Available helpers:
257
266
  Windows hosts generate a DSC v3 configuration for \`winget configure\`.
258
267
  Resources return handles that can be passed through \`dependsOn\`.
259
268
 
269
+ - \`windows.npm.registries({ registries: { work: {
270
+ uri: "https://packages.example.com/npm/" } }, default: "work",
271
+ scopes: { "@company": "work" } })\` configures current-user npm default/scoped
272
+ registries after host merging. HTTPS only, no credentials/query/fragments.
273
+ Manages only registry and declared @scope:registry keys in .npmrc or absolute
274
+ NPM_CONFIG_USERCONFIG; preserves auth/comments/unrelated settings, rejects
275
+ symlinked files and concurrent edits. Removing declarations doesn't clean up.
276
+ No npm installation, token management or package installation. No allowed-list
277
+ enforcement: project config/env/CLI can override it. Does not alter Winix
278
+ SDK/bootstrap downloads or Linux WSL setup. Dry generation never writes .npmrc.
279
+
260
280
  - \`windows.wallpaper({ source: "../wallpapers/desktop.jpg", style: "Fill" })\`
261
281
  manages the current-user desktop image; source is a local/config-relative or
262
282
  known-folder path. Styles: Fill, Fit, Stretch, Tile, Center, Span. Source
@@ -359,6 +379,14 @@ Resources return handles that can be passed through \`dependsOn\`.
359
379
  { repository: "https://github.com/example/dotfiles.git", ref: "main",
360
380
  configDirectory: "winix", host: "wsl-work", user: "alice",
361
381
  checkout: "/home/alice/dotfiles" }.
382
+ Prefer values over matching strings: host accepts the value returned by
383
+ host(...) and user the account.user(...) factory. repository: "self" clones the
384
+ checkout holding winix.config.ts: its tracked remote (SSH converted to HTTPS),
385
+ current upstream branch as ref (commit when detached; excluded from the
386
+ completed-setup fingerprint) and config path as configDirectory. winix check
387
+ validates the whole setup plan offline (host, account, NixOS-WSL module,
388
+ stateVersion, checkout inside the home). After switch, Winix prints the
389
+ command that applies later Linux changes inside each distro.
362
390
  Repository URLs must be HTTPS without credentials; authentication must already
363
391
  work inside Linux. Commit flake.lock in configDirectory; npm-based Winix also
364
392
  requires package.json/package-lock.json and a released SDK supporting setup.
@@ -508,6 +536,10 @@ Import \`nix\` at file scope. It builds values and does not declare fragments:
508
536
  \`nix.optionalString()\` build common expressions.
509
537
  - \`nix.isDarwin\` and \`nix.isLinux\` are Nix-side conditions.
510
538
  - \`nix.binaryRelease()\` builds a package for a prebuilt CLI release.
539
+ - \`nix.wsl.windowsBin(name, paths)\` builds a package whose bin/<name> runs the
540
+ first existing Windows executable among paths (\`C:\\\\...\` or
541
+ \`%LOCALAPPDATA%\\\\...\`), resolved through interop at run time, e.g.
542
+ \`home.packages(nix.wsl.windowsBin("code", "%LOCALAPPDATA%\\\\Programs\\\\Microsoft VS Code\\\\bin\\\\code"))\`.
511
543
  - \`nix.lib.mkDefault()\`, \`nix.lib.mkForce()\`, \`nix.lib.mkBefore()\`,
512
544
  \`nix.lib.mkAfter()\`, \`nix.lib.optionalAttrs()\`, and
513
545
  \`nix.lib.optionalString()\` expose common library operations.
@@ -61,6 +61,14 @@ export interface WinPowerShellRepositoryPolicy {
61
61
  /** When specified, reject other repositories instead of falling back. */
62
62
  allowed?: string[];
63
63
  }
64
+ export interface WinNpmRegistryPolicy {
65
+ registries: Record<string, {
66
+ uri: string;
67
+ }>;
68
+ default: string;
69
+ /** npm scope (including @) mapped to a declared registry name. */
70
+ scopes?: Record<string, string>;
71
+ }
64
72
  export interface WinWslDistro {
65
73
  name: string;
66
74
  source: "nixos-wsl";
@@ -72,6 +80,12 @@ export interface WinWslDistro {
72
80
  host?: string;
73
81
  /** First-run setup for Winix-created distros; never run for adopted distros. */
74
82
  setup?: WinWslSetup;
83
+ /**
84
+ * Internal: setup.ref was inferred from the config checkout's branch, so it
85
+ * is excluded from the completed-setup fingerprint (switching branches must
86
+ * not invalidate an already-completed distro).
87
+ */
88
+ setupRefFromCheckout?: boolean;
75
89
  }
76
90
  export interface WinWslSetup {
77
91
  /** Opts into executing trusted repository/npm code inside the distro. HTTPS only; never embed credentials. */
@@ -310,6 +324,9 @@ export type WinDscProperties = {
310
324
  * order controls apply order.
311
325
  */
312
326
  export interface WindowsOptions extends Record<string, unknown> {
327
+ npm?: {
328
+ registries?: WinNpmRegistryPolicy;
329
+ };
313
330
  powershell?: {
314
331
  repositories?: WinPowerShellRepositoryPolicy;
315
332
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adrifer/winix",
3
- "version": "0.3.0-preview.6",
3
+ "version": "0.3.0-preview.9",
4
4
  "description": "TypeScript-first system configuration for NixOS, nix-darwin, and Home Manager",
5
5
  "license": "MIT",
6
6
  "author": "Adrian Fernandez",