@adrifer/winix 0.2.0-preview.3 → 0.2.0

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/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type { Fragment, FragmentFactory, PlatformFactory, ProfileFactory, LazyFragment, PlatformLazyFragment, FragmentEntry, FragmentResult, NixExpr, RawModuleRef, ImportRef, InputDef, InputWithOptions, WorkspaceDef, HostDef, EvalContext } from "./core/types.js";
2
- export type { Attrs, BootOptions, DarwinNetworking, DarwinOptions, DarwinSecurity, DarwinDefaults, DarwinSystem, EnvironmentOptions, FirewallOptions, FontsOptions, FzfOptions, GitInclude, GitOptions, HomeActivation, HomebrewOptions, HomeConfig, HomeFile, HomeOptions, I18nOptions, LaunchdAgentOptions, LaunchdOptions, NeovimOptions, NetworkingOptions, NixConfig, NixGcOptions, NixHomebrewOptions, NixOptions, NixpkgsOptions, NixosSecurityOptions, NixosSystemOptions, NixPrimitive, NixSettings, NixValue, NixosOptions, OciContainerOptions, PackageRef, Script, ServicesOptions, StarshipOptions, SystemdOptions, SystemdService, SystemdTimer, TimeOptions, TmuxOptions, UserOptions, UsersOptions, VirtualisationOptions, WslOptions, XdgFile, XdgOptions, ZoxideOptions, ZshOptions, WindowsOptions, WinPackage, WinPackageSource, WinRawCommand, } from "./types/index.js";
2
+ export type { Attrs, BootOptions, DarwinNetworking, DarwinOptions, DarwinSecurity, DarwinDefaults, DarwinSystem, EnvironmentOptions, FirewallOptions, FontsOptions, FzfOptions, GitInclude, GitOptions, HomeActivation, HomebrewOptions, HomeConfig, HomeFile, HomeOptions, I18nOptions, LaunchdAgentOptions, LaunchdOptions, NeovimOptions, NetworkingOptions, NixConfig, NixGcOptions, NixHomebrewOptions, NixOptions, NixpkgsOptions, NixosSecurityOptions, NixosSystemOptions, NixPrimitive, NixSettings, NixValue, NixosOptions, OciContainerOptions, PackageRef, Script, ServicesOptions, StarshipOptions, SystemdOptions, SystemdService, SystemdTimer, TimeOptions, TmuxOptions, UserOptions, UsersOptions, VirtualisationOptions, WslOptions, XdgFile, XdgOptions, ZoxideOptions, ZshOptions, WindowsOptions, WinPackage, WinPackageSource, WinRawCommand, WinSettings, WinColorMode, WinStartFolder, WinTaskbarAlignment, WinTaskbarGroupingMode, WinTaskbarMultiMonMode, } from "./types/index.js";
3
3
  export { platform, feature, profile, host, workspace, input, defineInputs, rawModule, withContext } from "./sdk/index.js";
4
4
  export type { WinixContext } from "./sdk/context.js";
5
5
  export { evaluate } from "./evaluator/index.js";
@@ -9,4 +9,4 @@ export type { NixOutput } from "./backends/nix/index.js";
9
9
  export { generateWindows, isWindowsHost } from "./backends/windows/index.js";
10
10
  export type { WindowsOutput, WindowsHostOutput } from "./backends/windows/index.js";
11
11
  export { account, darwin, home, nix, nixos, overlay, platforms, windows } from "./helpers/index.js";
12
- export type { AccountGroupFactory, AccountGroupMember, AccountGroupOpts, AccountNamespace, AccountOpts, AccountUserFactory, AccountUserRef, ActivationOpts, BinaryReleaseArch, BinaryReleaseCompletions, BinaryReleaseMeta, BinaryReleaseOpts, BinaryReleasePlatform, DarwinHelper, DarwinPlatformOpts, DarwinProgramOptions, DarwinServiceOptions, HomeHelper, HomeProgramOptions, HomeServiceOptions, LaunchdHelper, NixNamespace, NixosHelper, NixosPlatformOpts, NixosProgramOptions, NixosServiceOptions, OverlayHelper, PkgHelper, PlatformsHelper, ScriptHelper, SysctlSettings, SystemdHelper, VirtualisationHelper, WindowsHelper, WindowsPlatformOpts, WinPackageArg, WinPackageSpec, WinRawCommandArg, WinRawCommandSpec } from "./helpers/index.js";
12
+ export type { AccountGroupFactory, AccountGroupMember, AccountGroupOpts, AccountNamespace, AccountOpts, AccountUserFactory, AccountUserRef, ActivationOpts, BinaryReleaseArch, BinaryReleaseCompletions, BinaryReleaseMeta, BinaryReleaseOpts, BinaryReleasePlatform, DarwinHelper, DarwinPlatformOpts, DarwinProgramOptions, DarwinServiceOptions, HomeHelper, HomeProgramOptions, HomeServiceOptions, LaunchdHelper, NixNamespace, NixosHelper, NixosPlatformOpts, NixosProgramOptions, NixosServiceOptions, OverlayHelper, PkgHelper, PlatformsHelper, ScriptHelper, SysctlSettings, SystemdHelper, VirtualisationHelper, WindowsHelper, WindowsPlatformOpts, WinEnvNamespace, WinEnvOpts, WinEnvScope, WinFileEncoding, WinFileNamespace, WinFileOpts, WinPackageArg, WinPackageSpec, WinPathNamespace, WinRawCommandArg, WinRawCommandSpec, WinSettingOpts } from "./helpers/index.js";
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Escape content for a Nix double-quoted string without changing its value.
3
+ */
4
+ export declare function escapeNixDoubleQuoted(value: string): string;
5
+ /**
6
+ * Serialize a JavaScript string as a behavior-preserving Nix literal.
7
+ */
8
+ export declare function nixStringLiteral(value: string): string;
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Escape content for a Nix double-quoted string without changing its value.
3
+ */
4
+ export function escapeNixDoubleQuoted(value) {
5
+ if (value.includes("\0")) {
6
+ throw new Error("Nix strings cannot contain null bytes");
7
+ }
8
+ return value
9
+ .replace(/\\/g, "\\\\")
10
+ .replace(/"/g, '\\"')
11
+ .replace(/\$\{/g, "\\${")
12
+ .replace(/\n/g, "\\n")
13
+ .replace(/\r/g, "\\r")
14
+ .replace(/\t/g, "\\t");
15
+ }
16
+ /**
17
+ * Serialize a JavaScript string as a behavior-preserving Nix literal.
18
+ */
19
+ export function nixStringLiteral(value) {
20
+ return `"${escapeNixDoubleQuoted(value)}"`;
21
+ }
@@ -8,8 +8,8 @@ export interface HomeConfig extends Record<string, unknown> {
8
8
  stateVersion?: string;
9
9
  packages?: PackageRef[];
10
10
  file?: Record<string, HomeFile> | NixExpr;
11
- sessionVariables?: Record<string, string>;
12
- sessionPath?: string[];
11
+ sessionVariables?: Record<string, string | NixExpr>;
12
+ sessionPath?: (string | NixExpr)[];
13
13
  activation?: Record<string, HomeActivation | Script>;
14
14
  }
15
15
  export interface HomeFile extends Record<string, unknown> {
@@ -34,8 +34,8 @@ export interface HomeOptions extends Record<string, unknown> {
34
34
  services?: Attrs;
35
35
  xdg?: XdgOptions;
36
36
  packages?: PackageRef[];
37
- sessionVariables?: Record<string, string>;
38
- sessionPath?: string[];
37
+ sessionVariables?: Record<string, string | NixExpr>;
38
+ sessionPath?: (string | NixExpr)[];
39
39
  activation?: Record<string, HomeActivation | Script>;
40
40
  manual?: {
41
41
  manpages?: {
@@ -60,6 +60,112 @@ export interface WinRawCommand {
60
60
  */
61
61
  dependsOn?: ResourceRef[];
62
62
  }
63
+ /**
64
+ * A generic DSC v3 resource, produced by `windows.dsc(...)` and by the typed
65
+ * helpers built on top of it (env/path). This is the escape hatch's IR: it
66
+ * carries an arbitrary DSC resource `type` and a free-form `properties` object
67
+ * that the emitter serializes verbatim as YAML.
68
+ *
69
+ * Typed helpers (env/path) construct native DSC resources internally:
70
+ * `Microsoft.Windows/Registry` for env and
71
+ * `Microsoft.DSC.Transitional/WindowsPowerShellScript` for PATH/files.
72
+ */
73
+ export interface WinDscResource {
74
+ /**
75
+ * Fully qualified DSC resource type, e.g. `Microsoft.Windows/Registry` or
76
+ * `Microsoft.Windows/Service`.
77
+ */
78
+ resourceType: string;
79
+ /**
80
+ * Optional friendly name. When omitted, the emitter generates one
81
+ * (`dsc N` in declaration order), sanitized to the DSC name charset.
82
+ */
83
+ name?: string;
84
+ /**
85
+ * Free-form DSC resource properties, serialized verbatim to YAML. May be a
86
+ * deeply nested object (e.g. the adapter's `resources:` array). Restricted to
87
+ * JSON-like values (string/number/boolean/null/array/object).
88
+ */
89
+ properties?: WinDscProperties;
90
+ /**
91
+ * When true, the resource is applied in an elevated security context via
92
+ * `metadata.winget.securityContext: elevated`.
93
+ */
94
+ elevated?: boolean;
95
+ /**
96
+ * Unique identity token so a handle returned by `windows.dsc(...)`,
97
+ * `windows.env.*(...)`, or `windows.path.*(...)` can be referenced in another
98
+ * resource's `dependsOn`. Non-enumerable in spirit; carried internally only.
99
+ */
100
+ token?: symbol;
101
+ /**
102
+ * Internal metadata for typed helpers. The emitter uses this to perform
103
+ * host-level rewrites that require seeing multiple resources together (for
104
+ * example resolving Winix-managed env var references in PATH entries). This
105
+ * must never be serialized to the generated DSC YAML.
106
+ */
107
+ winix?: WinDscMetadata;
108
+ /**
109
+ * Resources this resource must be applied after, as resolved references.
110
+ * Emitted as DSC v3 `dependsOn`. References must belong to the same host.
111
+ */
112
+ dependsOn?: ResourceRef[];
113
+ }
114
+ export type WinDscMetadata = {
115
+ kind: "env";
116
+ action: "set" | "remove";
117
+ name: string;
118
+ value?: string;
119
+ scope: "user" | "machine";
120
+ } | {
121
+ kind: "path";
122
+ action: "add" | "remove";
123
+ value: string;
124
+ scope: "user" | "machine";
125
+ } | {
126
+ kind: "setting";
127
+ };
128
+ export type WinColorMode = "Light" | "Dark";
129
+ export type WinTaskbarAlignment = "Left" | "Center";
130
+ export type WinTaskbarGroupingMode = "Always" | "WhenFull" | "Never";
131
+ export type WinTaskbarMultiMonMode = "Duplicate" | "PrimaryAndWindow" | "WindowOnly";
132
+ export type WinStartFolder = "Documents" | "Downloads" | "Music" | "Pictures" | "Videos" | "Network" | "UserProfile" | "Explorer" | "Settings";
133
+ /**
134
+ * Typed Windows OS settings exposed by
135
+ * `Microsoft.Windows.Settings/WindowsSettings`.
136
+ */
137
+ export interface WinSettings {
138
+ TaskbarAlignment?: WinTaskbarAlignment;
139
+ AppColorMode?: WinColorMode;
140
+ SystemColorMode?: WinColorMode;
141
+ DeveloperMode?: boolean;
142
+ SetTimeZoneAutomatically?: boolean;
143
+ /** Windows time zone ID. Winix validates only that this is non-empty; the target validates the ID. */
144
+ TimeZone?: string;
145
+ EnableTransparency?: boolean;
146
+ ShowAccentColorOnStartAndTaskbar?: boolean;
147
+ ShowAccentColorOnTitleBarsAndWindowBorders?: boolean;
148
+ AutoColorization?: boolean;
149
+ StartFolders?: WinStartFolder[];
150
+ ShowRecentList?: boolean;
151
+ ShowRecommendedList?: boolean;
152
+ TaskbarBadges?: boolean;
153
+ DesktopTaskbarBadges?: boolean;
154
+ TaskbarGroupingMode?: WinTaskbarGroupingMode;
155
+ TaskbarMultiMon?: boolean;
156
+ DesktopTaskbarMultiMon?: boolean;
157
+ TaskbarMultiMonMode?: WinTaskbarMultiMonMode;
158
+ DesktopTaskbarMultiMonMode?: WinTaskbarMultiMonMode;
159
+ NotifyOnUsbErrors?: boolean;
160
+ NotifyOnWeakCharger?: boolean;
161
+ }
162
+ /** JSON-like value accepted in generic DSC `properties`. */
163
+ export type WinDscPropertyValue = string | number | boolean | null | WinDscPropertyValue[] | {
164
+ [key: string]: WinDscPropertyValue;
165
+ };
166
+ export type WinDscProperties = {
167
+ [key: string]: WinDscPropertyValue;
168
+ };
63
169
  /**
64
170
  * The `windows` scope of a Fragment. Deep-merged across all fragments for a
65
171
  * host, then handed to the Windows emitter.
@@ -75,6 +181,12 @@ export interface WindowsOptions extends Record<string, unknown> {
75
181
  packages?: Record<string, WinPackage>;
76
182
  /** Raw commands to run on apply, in declaration order. */
77
183
  commands?: WinRawCommand[];
184
+ /**
185
+ * Generic DSC resources (from `windows.dsc(...)` and the env/path helpers),
186
+ * in declaration order. Ordered because they have no natural key and order
187
+ * can carry meaning; `dependsOn` expresses hard ordering.
188
+ */
189
+ dsc?: WinDscResource[];
78
190
  /** Hostname for the target, set by the platform baseline. */
79
191
  hostname?: string;
80
192
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adrifer/winix",
3
- "version": "0.2.0-preview.3",
3
+ "version": "0.2.0",
4
4
  "description": "TypeScript-first system configuration for NixOS, nix-darwin, and Home Manager",
5
5
  "license": "MIT",
6
6
  "author": "Adrian Fernandez",