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

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
@@ -960,6 +960,74 @@ as `.lnk.bak` and refuses backup collisions, while `force: true` opts into
960
960
  replacement without a backup. A new shortcut is staged and verified before
961
961
  replacing the old one. Keep names unique per host.
962
962
 
963
+ ### Windows personalization and fonts
964
+
965
+ These helpers manage the current Windows user without requiring elevation:
966
+
967
+ ```ts
968
+ windows.wallpaper({ source: "../wallpapers/desktop.jpg", style: "Fill" });
969
+ windows.personalization({
970
+ accentColor: "#336699",
971
+ explorer: { showExtensions: true, showHiddenFiles: false, openTo: "ThisPC" },
972
+ taskbar: { autoHide: false, search: "Hidden", taskView: true, widgets: false },
973
+ });
974
+ windows.fonts({
975
+ sources: [
976
+ "../fonts/MyFont-Regular.ttf",
977
+ { url: "https://example.com/releases/v1/fonts.zip", files: ["**/*.ttf"] },
978
+ { provider: "nerd-fonts", family: "JetBrainsMono" },
979
+ ],
980
+ });
981
+ ```
982
+
983
+ Wallpaper accepts a local path or `windows.knownFolder.*` path. Relative image
984
+ and font paths resolve from `winix.config.ts`, including Windows and WSL path
985
+ conversion. Wallpaper images are cached by content hash, so editing the source
986
+ image is detected. Styles are `Fill` (default), `Fit`, `Stretch`, `Tile`, `Center`,
987
+ and `Span`; this is one desktop background, not per-monitor image assignment.
988
+
989
+ Personalization only changes declared values. `accentColor` is `#RRGGBB` and
990
+ disables automatic accent coloring. Explorer `openTo` accepts `ThisPC` or `Home`;
991
+ hidden files does not expose protected operating-system files. Taskbar `search`
992
+ accepts `Hidden`, `Icon`, `IconAndLabel`, or `Box`. Explorer/taskbar/accent values
993
+ depend on Windows version and policy and may require signing out; Winix never
994
+ restarts Explorer. Existing `windows.setting()` theme settings remain available.
995
+ Avoid declaring conflicting automatic accent coloring in both helpers.
996
+
997
+ Fonts support local `.ttf`/`.otf` files, HTTPS `.ttf`/`.otf` downloads, and ZIP
998
+ archives. ZIP `files` accepts exact member paths or `**/*.ttf` / `**/*.otf`;
999
+ omitting it selects all font files. Unsafe archives, missing selections and
1000
+ conflicting filenames fail explicitly. Downloads and expanded archives have
1001
+ size limits. Remote sources must not contain credentials. An optional `sha256`
1002
+ provides an independently trusted checksum; otherwise the first resolution
1003
+ records the upstream digest or the downloaded bytes (trust on first use).
1004
+
1005
+ Remote fonts have a separate `fonts` section in `winix-windows.lock`. First
1006
+ apply resolves missing entries; subsequent apply reuses them without a catalog
1007
+ query. `winix update --windows fonts` refreshes only font pins; `--dry` never
1008
+ writes pins or installs fonts. Installation verifies checksums and caches
1009
+ downloads in Local AppData. Nerd Fonts IDs come from official release ZIP
1010
+ assets, not a handwritten registry:
1011
+
1012
+ ```sh
1013
+ winix fonts search JetBrains --provider nerd-fonts
1014
+ winix update --windows fonts --dry
1015
+ ```
1016
+
1017
+ Nerd Fonts is the only built-in provider. Its optional `version: "vX.Y.Z"` selects
1018
+ an exact upstream release; otherwise latest resolves once and stays locked.
1019
+ Provider IDs, archive filenames and installed family names differ. Installation
1020
+ reports family names from font metadata; configure Terminal/editors separately
1021
+ to select them. Fonts are installed and registered for the current user,
1022
+ identical files are reused, and differing existing files/registry entries are
1023
+ not overwritten. Updating a ZIP pin may therefore require explicitly resolving
1024
+ an existing font collision. Font removal/cleanup is not tracked; deleting a
1025
+ declaration leaves installed fonts and caches intact.
1026
+
1027
+ These helpers emit idempotent DSC PowerShell resources. Native desktop/font
1028
+ activation has not been rehearsed on a shared machine; automated checks cover
1029
+ authoring, locking, generated scripts and isolated archive handling.
1030
+
963
1031
  ### Windows removal and ownership
964
1032
 
965
1033
  Native Windows `winix switch` keeps a separate applied-state inventory under
@@ -0,0 +1 @@
1
+ export declare const fontInstallPrelude: string;
@@ -0,0 +1,206 @@
1
+ export const fontInstallPrelude = String.raw `
2
+ function Get-WinixFontRegistry {
3
+ return [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey('Software\Microsoft\Windows NT\CurrentVersion\Fonts')
4
+ }
5
+ function Test-WinixFonts {
6
+ if (-not (Test-Path -LiteralPath $manifest -PathType Leaf)) { return $false }
7
+ $record = Get-Content -LiteralPath $manifest -Raw | ConvertFrom-Json
8
+ if ($record.version -ne 1 -or @($record.fonts).Count -eq 0) { throw 'Invalid Winix font manifest' }
9
+ foreach ($source in $plan) {
10
+ if ($source.path) {
11
+ $path = [Environment]::ExpandEnvironmentVariables($source.path)
12
+ if (-not (Test-Path -LiteralPath $path -PathType Leaf)) { throw "Local font does not exist: $path" }
13
+ $hash = (Get-FileHash -LiteralPath $path -Algorithm SHA256).Hash
14
+ if (-not @($record.sources | Where-Object { $_.path -eq $source.path -and $_.sha256 -eq $hash }).Count) { return $false }
15
+ }
16
+ $destination = Join-Path $env:LOCALAPPDATA 'Microsoft\Windows\Fonts'
17
+ foreach ($font in $record.fonts) {
18
+ if (-not $font.name -or [IO.Path]::GetFileName($font.name) -ne $font.name -or
19
+ $font.path -ne (Join-Path $destination $font.name) -or $font.sha256 -notmatch '^[a-f0-9]{64}$') {
20
+ throw 'Invalid Winix font manifest entry'
21
+ }
22
+ }
23
+ }
24
+ $registry = Get-WinixFontRegistry
25
+ if ($null -eq $registry) { return $false }
26
+ try {
27
+ foreach ($font in $record.fonts) {
28
+ if (-not (Test-Path -LiteralPath $font.path -PathType Leaf) -or
29
+ (Get-FileHash -LiteralPath $font.path -Algorithm SHA256).Hash -ne $font.sha256 -or
30
+ $registry.GetValue($font.name) -ne $font.path) { return $false }
31
+ }
32
+ } finally { $registry.Dispose() }
33
+ return $true
34
+ }
35
+ function Get-WinixFontDownload($source) {
36
+ $cache = Join-Path $env:LOCALAPPDATA 'Winix\cache\fonts'
37
+ New-Item -ItemType Directory -Path $cache -Force | Out-Null
38
+ $target = Join-Path $cache ($source.sha256 + '.' + $source.format)
39
+ if (Test-Path -LiteralPath $target -PathType Leaf) {
40
+ if ((Get-FileHash -LiteralPath $target -Algorithm SHA256).Hash -ne $source.sha256) { throw "Corrupt font cache: $target" }
41
+ return $target
42
+ }
43
+ $temporary = Join-Path $cache ([guid]::NewGuid().ToString() + '.download')
44
+ $client = [Net.Http.HttpClient]::new([Net.Http.HttpClientHandler]@{ AllowAutoRedirect = $false })
45
+ $client.Timeout = [TimeSpan]::FromSeconds(60)
46
+ try {
47
+ $uri = [uri]$source.url
48
+ for ($redirect = 0; $redirect -le 5; $redirect++) {
49
+ if ($uri.Scheme -ne 'https' -or $uri.UserInfo) { throw 'Unsafe font download URL' }
50
+ $response = $client.GetAsync($uri, [Net.Http.HttpCompletionOption]::ResponseHeadersRead).GetAwaiter().GetResult()
51
+ if ([int]$response.StatusCode -in @(301,302,303,307,308)) {
52
+ try {
53
+ if ($null -eq $response.Headers.Location) { throw 'Font redirect has no location' }
54
+ $uri = [uri]::new($uri, $response.Headers.Location)
55
+ } finally { $response.Dispose() }
56
+ continue
57
+ }
58
+ try {
59
+ $response.EnsureSuccessStatusCode() | Out-Null
60
+ $inputStream = $response.Content.ReadAsStreamAsync().GetAwaiter().GetResult()
61
+ $outputStream = [IO.File]::Open($temporary, [IO.FileMode]::CreateNew)
62
+ try {
63
+ $buffer = [byte[]]::new(65536)
64
+ $total = 0L
65
+ while (($count = $inputStream.Read($buffer, 0, $buffer.Length)) -gt 0) {
66
+ $total += $count
67
+ if ($total -gt 134217728) { throw 'Font download exceeds 128 MiB' }
68
+ $outputStream.Write($buffer, 0, $count)
69
+ }
70
+ } finally { $outputStream.Dispose(); $inputStream.Dispose() }
71
+ } finally { $response.Dispose() }
72
+ if ((Get-FileHash -LiteralPath $temporary -Algorithm SHA256).Hash -ne $source.sha256) { throw 'Font checksum mismatch' }
73
+ [IO.File]::Move($temporary, $target, $false)
74
+ return $target
75
+ }
76
+ throw 'Too many font redirects'
77
+ } finally {
78
+ $client.Dispose()
79
+ if (Test-Path -LiteralPath $temporary) { Remove-Item -LiteralPath $temporary -Force }
80
+ }
81
+ }
82
+ function Expand-WinixFonts([string]$archive, [string]$destination, $selectors) {
83
+ $zip = [IO.Compression.ZipFile]::OpenRead($archive)
84
+ $result = [Collections.Generic.List[string]]::new()
85
+ try {
86
+ if ($zip.Entries.Count -gt 4096) { throw 'Font archive has too many entries' }
87
+ $total = 0L
88
+ foreach ($entry in $zip.Entries) {
89
+ $name = $entry.FullName
90
+ if ($name.StartsWith('/') -or $name.Contains('\') -or $name.Contains(':') -or
91
+ $name.Contains([char]0) -or ($name.Split('/') -contains '..') -or ($name.Split('/') -contains '.') -or
92
+ (($entry.ExternalAttributes -shr 16) -band 0xf000) -eq 0xa000) { throw "Unsafe font ZIP entry: $name" }
93
+ if (-not $entry.Name) { continue }
94
+ $total += $entry.Length
95
+ if ($total -gt 268435456) { throw 'Font archive exceeds 256 MiB expanded' }
96
+ if ([IO.Path]::GetExtension($name) -notin @('.ttf','.otf')) { continue }
97
+ $selected = $false
98
+ foreach ($selector in $selectors) {
99
+ if (($selector -eq '**/*.ttf' -and $name.EndsWith('.ttf', [StringComparison]::OrdinalIgnoreCase)) -or
100
+ ($selector -eq '**/*.otf' -and $name.EndsWith('.otf', [StringComparison]::OrdinalIgnoreCase)) -or
101
+ $selector -ceq $name) { $selected = $true }
102
+ }
103
+ if (-not $selected) { continue }
104
+ $path = Join-Path $destination $entry.Name
105
+ if (Test-Path -LiteralPath $path) { throw "Duplicate font filename: $($entry.Name)" }
106
+ [IO.Compression.ZipFileExtensions]::ExtractToFile($entry, $path, $false)
107
+ $result.Add($path)
108
+ }
109
+ if ($result.Count -eq 0) { throw 'Font archive contains no matching TTF/OTF files' }
110
+ foreach ($selector in $selectors) {
111
+ if (-not $selector.StartsWith('**/') -and -not @($zip.Entries | Where-Object { $_.FullName -ceq $selector }).Count) {
112
+ throw "Font ZIP member does not exist: $selector"
113
+ }
114
+ }
115
+ return $result.ToArray()
116
+ } finally { $zip.Dispose() }
117
+ }
118
+ function Install-WinixFonts {
119
+ $stageRoot = Join-Path $env:LOCALAPPDATA 'Winix\fonts'
120
+ New-Item -ItemType Directory -Path $stageRoot -Force | Out-Null
121
+ $stage = Join-Path $stageRoot ([guid]::NewGuid().ToString())
122
+ New-Item -ItemType Directory -Path $stage | Out-Null
123
+ $files = [Collections.Generic.List[string]]::new()
124
+ $localSources = [Collections.Generic.List[object]]::new()
125
+ try {
126
+ foreach ($source in $plan) {
127
+ if ($source.path) {
128
+ $path = [Environment]::ExpandEnvironmentVariables($source.path)
129
+ if (-not (Test-Path -LiteralPath $path -PathType Leaf)) { throw "Font file does not exist: $path" }
130
+ $files.Add($path)
131
+ $localSources.Add(@{ path = $source.path; sha256 = (Get-FileHash -LiteralPath $path -Algorithm SHA256).Hash })
132
+ } else {
133
+ $download = Get-WinixFontDownload $source
134
+ if ($source.format -eq 'zip') {
135
+ $directory = Join-Path $stage ([guid]::NewGuid().ToString())
136
+ New-Item -ItemType Directory -Path $directory | Out-Null
137
+ foreach ($path in @(Expand-WinixFonts $download $directory $source.files)) { $files.Add($path) }
138
+ } else { $files.Add($download) }
139
+ }
140
+ }
141
+ Add-Type -AssemblyName System.Drawing
142
+ $destination = Join-Path $env:LOCALAPPDATA 'Microsoft\Windows\Fonts'
143
+ $prepared = @{}
144
+ $registry = Get-WinixFontRegistry
145
+ try {
146
+ foreach ($path in $files) {
147
+ $name = [IO.Path]::GetFileName($path)
148
+ $hash = (Get-FileHash -LiteralPath $path -Algorithm SHA256).Hash
149
+ $target = Join-Path $destination $name
150
+ if ($prepared.ContainsKey($name)) {
151
+ if ($prepared[$name].sha256 -ne $hash) { throw "Conflicting font filename: $name" }
152
+ continue
153
+ }
154
+ if ((Test-Path -LiteralPath $target) -and
155
+ ((Get-Item -LiteralPath $target).Attributes -band [IO.FileAttributes]::ReparsePoint)) { throw "Font target is a link: $target" }
156
+ if ((Test-Path -LiteralPath $target) -and
157
+ (Get-FileHash -LiteralPath $target -Algorithm SHA256).Hash -ne $hash) { throw "Font replacement refused: $target" }
158
+ $registered = if ($null -ne $registry) { $registry.GetValue($name) } else { $null }
159
+ if ($null -ne $registered -and $registered -ne $target) { throw "Font registry collision: $name" }
160
+ $collection = [Drawing.Text.PrivateFontCollection]::new()
161
+ try {
162
+ $collection.AddFontFile($path)
163
+ $families = @($collection.Families | ForEach-Object { $_.Name })
164
+ if (-not $families.Count) { throw "Invalid font file: $path" }
165
+ } finally { $collection.Dispose() }
166
+ $prepared[$name] = @{ name = $name; path = $target; source = $path; sha256 = $hash; families = $families }
167
+ }
168
+ } finally { if ($null -ne $registry) { $registry.Dispose() } }
169
+ if (-not ('WinixFontNative' -as [type])) {
170
+ Add-Type @'
171
+ using System;
172
+ using System.Runtime.InteropServices;
173
+ public static class WinixFontNative {
174
+ [DllImport("gdi32.dll", CharSet=CharSet.Unicode, SetLastError=true)]
175
+ public static extern int AddFontResourceEx(string path, uint flags, IntPtr reserved);
176
+ [DllImport("user32.dll", CharSet=CharSet.Unicode, SetLastError=true)]
177
+ public static extern IntPtr SendMessageTimeout(IntPtr hwnd, uint message, IntPtr wparam, IntPtr lparam, uint flags, uint timeout, out IntPtr result);
178
+ }
179
+ '@
180
+ }
181
+ New-Item -ItemType Directory -Path $destination -Force | Out-Null
182
+ $registry = [Microsoft.Win32.Registry]::CurrentUser.CreateSubKey('Software\Microsoft\Windows NT\CurrentVersion\Fonts')
183
+ try {
184
+ foreach ($font in $prepared.Values) {
185
+ if (-not (Test-Path -LiteralPath $font.path)) { [IO.File]::Copy($font.source, $font.path, $false) }
186
+ if ((Get-FileHash -LiteralPath $font.path -Algorithm SHA256).Hash -ne $font.sha256) { throw 'Font changed during installation' }
187
+ $registered = $registry.GetValue($font.name)
188
+ if ($null -ne $registered -and $registered -ne $font.path) { throw "Font registry changed during installation: $($font.name)" }
189
+ if ($null -eq $registered) {
190
+ if ([WinixFontNative]::AddFontResourceEx($font.path, 0, [IntPtr]::Zero) -eq 0) { throw "Windows rejected font: $($font.path)" }
191
+ $registry.SetValue($font.name, $font.path, [Microsoft.Win32.RegistryValueKind]::String)
192
+ }
193
+ Write-Host ("Installed font families: " + ($font.families -join ', '))
194
+ }
195
+ } finally { $registry.Dispose() }
196
+ $result = [IntPtr]::Zero
197
+ if ([WinixFontNative]::SendMessageTimeout([IntPtr]0xffff, 0x001d, [IntPtr]::Zero, [IntPtr]::Zero, 2, 5000, [ref]$result) -eq [IntPtr]::Zero) {
198
+ Write-Warning 'Font change notification timed out; applications may need restarting.'
199
+ }
200
+ $record = @{ version = 1; fonts = @($prepared.Values | ForEach-Object { @{ name = $_.name; path = $_.path; sha256 = $_.sha256; families = $_.families } }); sources = @($localSources.ToArray()) }
201
+ $pending = Join-Path $stage 'manifest.json'
202
+ $record | ConvertTo-Json -Depth 8 | Set-Content -LiteralPath $pending -Encoding utf8
203
+ [IO.File]::Move($pending, $manifest, $true)
204
+ } finally { Remove-Item -LiteralPath $stage -Recurse -Force }
205
+ }
206
+ `;
@@ -0,0 +1,32 @@
1
+ import type { EvaluatedHost } from "../../evaluator/index.js";
2
+ import type { WinFontSource, WinDscProperties } from "../../types/windows.js";
3
+ import type { WindowsLock } from "./lockfile.js";
4
+ export interface WindowsFontPin {
5
+ url: string;
6
+ sha256: string;
7
+ format: "zip" | "ttf" | "otf";
8
+ version?: string;
9
+ resolvedAt: string;
10
+ }
11
+ export type RemoteFontSource = Exclude<WinFontSource, string>;
12
+ export type WindowsFontResolver = (source: RemoteFontSource) => Promise<WindowsFontPin>;
13
+ export declare function fontSourceKey(source: RemoteFontSource): string;
14
+ export declare function validFontPin(value: unknown): value is WindowsFontPin;
15
+ export declare function fontPinMatches(source: RemoteFontSource, pin: WindowsFontPin): boolean;
16
+ export declare function fontFetch(url: string): Promise<Response>;
17
+ export interface NerdFontsCatalog {
18
+ version: string;
19
+ fonts: {
20
+ family: string;
21
+ url: string;
22
+ sha256?: string;
23
+ }[];
24
+ }
25
+ export declare function nerdFontsCatalog(version?: string): Promise<NerdFontsCatalog>;
26
+ export declare const resolveFontSource: WindowsFontResolver;
27
+ export declare function collectFontSources(hosts: EvaluatedHost[]): Map<string, RemoteFontSource>;
28
+ export declare function resolveWindowsFonts(lock: WindowsLock, sources: Iterable<RemoteFontSource>, resolver?: WindowsFontResolver, now?: Date, missingOnly?: boolean): Promise<{
29
+ lock: WindowsLock;
30
+ changed: boolean;
31
+ }>;
32
+ export declare function fontsProperties(sources: WinFontSource[], lock: WindowsLock, configDir?: string): WinDscProperties;
@@ -0,0 +1,199 @@
1
+ import { createHash } from "node:crypto";
2
+ import { fontHttpsUrl, validateFontSources } from "../../helpers/windows-personalization.js";
3
+ import { resolveWindowsSource } from "../../helpers/windows.js";
4
+ import { powerShellLiteral as quote } from "../../helpers/utils.js";
5
+ import { windowsSourcePath } from "./paths.js";
6
+ import { fontInstallPrelude } from "./fonts-runtime.js";
7
+ const maxDownloadBytes = 128 * 1024 * 1024;
8
+ export function fontSourceKey(source) {
9
+ validateFontSources([source]);
10
+ const identity = "provider" in source
11
+ ? { provider: source.provider, family: source.family, version: source.version ?? null }
12
+ : { url: fontHttpsUrl(source.url), sha256: source.sha256?.toLowerCase() ?? null, files: source.files ?? null };
13
+ return createHash("sha256").update(JSON.stringify(identity)).digest("hex");
14
+ }
15
+ export function validFontPin(value) {
16
+ if (!value || typeof value !== "object")
17
+ return false;
18
+ const pin = value;
19
+ if (typeof pin.url !== "string" || typeof pin.sha256 !== "string" ||
20
+ !/^[a-f0-9]{64}$/.test(pin.sha256) || !["zip", "ttf", "otf"].includes(String(pin.format)) ||
21
+ typeof pin.resolvedAt !== "string" ||
22
+ (pin.version !== undefined && (typeof pin.version !== "string" || !/^v\d+\.\d+\.\d+$/.test(pin.version))))
23
+ return false;
24
+ try {
25
+ return fontHttpsUrl(pin.url) === pin.url;
26
+ }
27
+ catch {
28
+ return false;
29
+ }
30
+ }
31
+ export function fontPinMatches(source, pin) {
32
+ if (!validFontPin(pin))
33
+ return false;
34
+ if ("url" in source)
35
+ return pin.url === fontHttpsUrl(source.url) &&
36
+ pin.format === new URL(source.url).pathname.split(".").at(-1)?.toLowerCase() &&
37
+ (source.sha256 === undefined || source.sha256.toLowerCase() === pin.sha256);
38
+ return pin.format === "zip" && pin.version !== undefined &&
39
+ (source.version === undefined || source.version === pin.version) &&
40
+ pin.url === `https://github.com/ryanoasis/nerd-fonts/releases/download/${pin.version}/${source.family}.zip`;
41
+ }
42
+ export async function fontFetch(url) {
43
+ let current = fontHttpsUrl(url);
44
+ for (let redirects = 0; redirects <= 5; redirects++) {
45
+ const response = await fetch(current, {
46
+ redirect: "manual", signal: AbortSignal.timeout(60000),
47
+ headers: { "User-Agent": "Winix-font-resolver", Accept: "application/json, application/octet-stream" },
48
+ });
49
+ if ([301, 302, 303, 307, 308].includes(response.status)) {
50
+ const location = response.headers.get("location");
51
+ await response.body?.cancel();
52
+ if (!location)
53
+ throw new Error("Font download redirect has no Location");
54
+ current = fontHttpsUrl(new URL(location, current).href);
55
+ continue;
56
+ }
57
+ if (!response.ok) {
58
+ await response.body?.cancel();
59
+ throw new Error(`Font request failed (${response.status}) for ${current}`);
60
+ }
61
+ return response;
62
+ }
63
+ throw new Error("Too many font download redirects");
64
+ }
65
+ async function fontResponseBytes(response, limit) {
66
+ const reader = response.body?.getReader();
67
+ if (!reader)
68
+ throw new Error("Empty font response");
69
+ const chunks = [];
70
+ let length = 0;
71
+ try {
72
+ while (true) {
73
+ const { value, done } = await reader.read();
74
+ if (done)
75
+ break;
76
+ length += value.length;
77
+ if (length > limit)
78
+ throw new Error("Font response exceeds the size limit");
79
+ chunks.push(value);
80
+ }
81
+ }
82
+ finally {
83
+ await reader.cancel();
84
+ }
85
+ return Buffer.concat(chunks);
86
+ }
87
+ export async function nerdFontsCatalog(version) {
88
+ if (version !== undefined && !/^v\d+\.\d+\.\d+$/.test(version))
89
+ throw new Error("Invalid Nerd Fonts release tag");
90
+ const response = await fontFetch(`https://api.github.com/repos/ryanoasis/nerd-fonts/releases/${version ? `tags/${version}` : "latest"}`);
91
+ const data = JSON.parse((await fontResponseBytes(response, 4 * 1024 * 1024)).toString("utf8"));
92
+ if (!data || typeof data !== "object")
93
+ throw new Error("Invalid Nerd Fonts release metadata");
94
+ const release = data;
95
+ if (typeof release.tag_name !== "string" || !/^v\d+\.\d+\.\d+$/.test(release.tag_name) ||
96
+ !Array.isArray(release.assets) || release.draft || release.prerelease ||
97
+ (version !== undefined && release.tag_name !== version))
98
+ throw new Error("Invalid Nerd Fonts release");
99
+ const fonts = [];
100
+ for (const asset of release.assets) {
101
+ if (!asset || typeof asset !== "object" || typeof asset.name !== "string" ||
102
+ !/^[a-z0-9][a-z0-9_-]*\.zip$/i.test(asset.name))
103
+ continue;
104
+ const family = asset.name.slice(0, -4);
105
+ const url = `https://github.com/ryanoasis/nerd-fonts/releases/download/${release.tag_name}/${asset.name}`;
106
+ if (asset.browser_download_url !== url)
107
+ throw new Error(`Unexpected Nerd Fonts download URL for ${family}`);
108
+ if (fonts.some((font) => font.family === family))
109
+ throw new Error(`Duplicate Nerd Fonts asset ${family}`);
110
+ fonts.push({ family, url, ...(typeof asset.digest === "string" && /^sha256:[a-f0-9]{64}$/.test(asset.digest)
111
+ ? { sha256: asset.digest.slice(7) } : {}) });
112
+ }
113
+ if (!fonts.length)
114
+ throw new Error("Nerd Fonts release has no font ZIP assets");
115
+ return { version: release.tag_name, fonts: fonts.sort((a, b) => a.family.localeCompare(b.family)) };
116
+ }
117
+ export const resolveFontSource = async (source) => {
118
+ validateFontSources([source]);
119
+ let url;
120
+ let sha256;
121
+ let version;
122
+ let format;
123
+ if ("provider" in source) {
124
+ const catalog = await nerdFontsCatalog(source.version);
125
+ const font = catalog.fonts.find((entry) => entry.family === source.family);
126
+ if (!font)
127
+ throw new Error(`Nerd Fonts ID "${source.family}" does not exist in ${catalog.version}. Run winix fonts search --provider nerd-fonts.`);
128
+ ({ url, sha256 } = font);
129
+ version = catalog.version;
130
+ format = "zip";
131
+ }
132
+ else {
133
+ url = fontHttpsUrl(source.url);
134
+ sha256 = source.sha256?.toLowerCase();
135
+ const extension = new URL(url).pathname.split(".").at(-1)?.toLowerCase();
136
+ if (extension !== "zip" && extension !== "ttf" && extension !== "otf")
137
+ throw new Error("Invalid font format");
138
+ format = extension;
139
+ }
140
+ if (!sha256) {
141
+ const bytes = await fontResponseBytes(await fontFetch(url), maxDownloadBytes);
142
+ sha256 = createHash("sha256").update(bytes).digest("hex");
143
+ }
144
+ return { url, sha256, format, ...(version ? { version } : {}), resolvedAt: new Date().toISOString() };
145
+ };
146
+ export function collectFontSources(hosts) {
147
+ const sources = new Map();
148
+ for (const host of hosts)
149
+ for (const resource of host.windows.dsc ?? []) {
150
+ if (resource.winix?.kind !== "fonts")
151
+ continue;
152
+ validateFontSources(resource.winix.sources);
153
+ for (const source of resource.winix.sources)
154
+ if (typeof source !== "string")
155
+ sources.set(fontSourceKey(source), source);
156
+ }
157
+ return sources;
158
+ }
159
+ export async function resolveWindowsFonts(lock, sources, resolver = resolveFontSource, now = new Date(), missingOnly = false) {
160
+ const fonts = { ...lock.fonts };
161
+ let changed = false;
162
+ for (const source of sources) {
163
+ const key = fontSourceKey(source);
164
+ if (fonts[key] && !fontPinMatches(source, fonts[key]))
165
+ throw new Error(`Font lock does not match declaration ${key}`);
166
+ if (missingOnly && fonts[key])
167
+ continue;
168
+ const pin = { ...await resolver(source), resolvedAt: now.toISOString() };
169
+ if (!fontPinMatches(source, pin))
170
+ throw new Error("Invalid font resolution");
171
+ const previous = fonts[key];
172
+ if (previous && previous.url === pin.url && previous.sha256 === pin.sha256 && previous.version === pin.version)
173
+ continue;
174
+ fonts[key] = pin;
175
+ changed = true;
176
+ }
177
+ return { lock: changed ? { ...lock, fonts, generatedAt: now.toISOString() } : lock, changed };
178
+ }
179
+ export function fontsProperties(sources, lock, configDir) {
180
+ validateFontSources(sources);
181
+ const plan = sources.map((source) => {
182
+ if (typeof source === "string")
183
+ return { path: resolveWindowsSource(source, configDir, windowsSourcePath) };
184
+ const pin = lock.fonts?.[fontSourceKey(source)];
185
+ if (!pin || !fontPinMatches(source, pin))
186
+ throw new Error("Font source has no matching pin; run winix update --windows fonts");
187
+ return { ...pin, files: "url" in source ? source.files ?? ["**/*.ttf", "**/*.otf"] : ["**/*.ttf", "**/*.otf"] };
188
+ });
189
+ const identity = createHash("sha256").update(JSON.stringify(plan)).digest("hex");
190
+ const prelude = `$ErrorActionPreference = 'Stop'
191
+ $plan = @(ConvertFrom-Json ${quote(JSON.stringify(plan))})
192
+ $manifest = Join-Path $env:LOCALAPPDATA 'Winix\\fonts\\${identity}.json'
193
+ ${fontInstallPrelude}`;
194
+ return {
195
+ getScript: `${prelude}\n@{ InDesiredState = (Test-WinixFonts) }`,
196
+ testScript: `${prelude}\nTest-WinixFonts`,
197
+ setScript: `${prelude}\nif (-not (Test-WinixFonts)) { Install-WinixFonts }\nif (-not (Test-WinixFonts)) { throw 'Font installation verification failed' }`,
198
+ };
199
+ }
@@ -35,6 +35,8 @@ import { powerShellRepositoryUri, resolvePowerShellModule, validateWindowsPowerS
35
35
  import { powerShellLiteral as psSingleQuoted } from "../../helpers/utils.js";
36
36
  import { windowsSourcePath } from "./paths.js";
37
37
  import { optionalFeatureProperties, wslDistroProperties } from "./wsl.js";
38
+ import { fontsProperties } from "./fonts.js";
39
+ import { wallpaperProperties } from "./personalization.js";
38
40
  export { isWindowsHost } from "./host.js";
39
41
  const DSC_SCHEMA = "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/config/document.json";
40
42
  const WINGET_PACKAGE_TYPE = "Microsoft.WinGet/Package";
@@ -85,6 +87,12 @@ function generateConfiguration(hostName, win, lock, configDir) {
85
87
  .map((resource) => ({ kind: "dsc", token: resource.token }));
86
88
  const resources = (win.dsc ?? []).map((resource) => {
87
89
  const metadata = resource.winix;
90
+ if (metadata?.kind === "fonts") {
91
+ return cloneDscResource(resource, fontsProperties(metadata.sources, lock, configDir));
92
+ }
93
+ if (metadata?.kind === "wallpaper") {
94
+ return cloneDscResource(resource, wallpaperProperties(metadata.wallpaper, configDir));
95
+ }
88
96
  if (metadata?.kind === "file") {
89
97
  const properties = resolveWindowsFileProperties(resource, configDir, windowsSourcePath);
90
98
  if (metadata.wslConfig && properties) {
@@ -1,3 +1,4 @@
1
+ import { type WindowsFontPin } from "./fonts.js";
1
2
  import type { EvaluatedHost } from "../../evaluator/index.js";
2
3
  import type { WinPackage, WinPackageSource } from "../../types/index.js";
3
4
  import { type WslArchitecture, type WindowsWslImageResolver } from "./wsl.js";
@@ -14,6 +15,7 @@ export interface WindowsLock {
14
15
  version: typeof WINDOWS_LOCK_VERSION;
15
16
  generatedAt: string;
16
17
  packages: Record<string, WindowsLockPackage>;
18
+ fonts?: Record<string, WindowsFontPin>;
17
19
  /** Source-qualified lowercase keys; legacy name-only entries remain readable. */
18
20
  modules?: Record<string, WindowsLockModule>;
19
21
  wslImages?: Record<string, WindowsLockWslImage>;
@@ -1,4 +1,5 @@
1
1
  import { existsSync, readFileSync, writeFileSync } from "node:fs";
2
+ import { validFontPin } from "./fonts.js";
2
3
  import { join } from "node:path";
3
4
  import { createHash } from "node:crypto";
4
5
  import { validWslImage } from "./wsl.js";
@@ -165,6 +166,11 @@ export function serializeWindowsLock(lock) {
165
166
  sorted.modules[name] = { ...lock.modules[name] };
166
167
  }
167
168
  }
169
+ if (lock.fonts !== undefined) {
170
+ sorted.fonts = {};
171
+ for (const key of Object.keys(lock.fonts).sort(comparePackageIds))
172
+ sorted.fonts[key] = { ...lock.fonts[key] };
173
+ }
168
174
  if (lock.wslImages !== undefined) {
169
175
  sorted.wslImages = {};
170
176
  for (const key of Object.keys(lock.wslImages).sort(comparePackageIds)) {
@@ -363,6 +369,16 @@ function validateWindowsLock(value) {
363
369
  }
364
370
  }
365
371
  const wslImages = {};
372
+ const fonts = {};
373
+ if (value.fonts !== undefined) {
374
+ if (!isObject(value.fonts))
375
+ throw new Error(`${WINDOWS_LOCKFILE_NAME} fonts must be an object`);
376
+ for (const [key, pin] of Object.entries(value.fonts)) {
377
+ if (!/^[a-f0-9]{64}$/.test(key) || !validFontPin(pin))
378
+ throw new Error(`${WINDOWS_LOCKFILE_NAME} font pin "${key}" is invalid`);
379
+ fonts[key] = { ...pin };
380
+ }
381
+ }
366
382
  if (value.wslImages !== undefined) {
367
383
  if (!isObject(value.wslImages))
368
384
  throw new Error(`${WINDOWS_LOCKFILE_NAME} wslImages must be an object.`);
@@ -388,6 +404,7 @@ function validateWindowsLock(value) {
388
404
  version: WINDOWS_LOCK_VERSION,
389
405
  generatedAt: value.generatedAt,
390
406
  packages,
407
+ ...(value.fonts === undefined ? {} : { fonts }),
391
408
  ...(value.modules === undefined ? {} : { modules }),
392
409
  ...(value.wslImages === undefined ? {} : { wslImages }),
393
410
  ...(value.wslRepositories === undefined ? {} : { wslRepositories }),
@@ -0,0 +1,4 @@
1
+ import type { WinDscProperties, WinWallpaper } from "../../types/windows.js";
2
+ import type { PersonalizationRegistryValue } from "../../helpers/windows-personalization.js";
3
+ export declare function personalizationProperties(values: PersonalizationRegistryValue[], autoHide?: boolean): WinDscProperties;
4
+ export declare function wallpaperProperties(wallpaper: WinWallpaper, configDir?: string): WinDscProperties;
@@ -0,0 +1,125 @@
1
+ import { powerShellLiteral as quote } from "../../helpers/utils.js";
2
+ import { filePathExpression, filePathPrelude, resolveWindowsSource } from "../../helpers/windows.js";
3
+ import { windowsSourcePath } from "./paths.js";
4
+ export function personalizationProperties(values, autoHide) {
5
+ const appBar = autoHide === undefined ? "" : `
6
+ if (-not ('WinixAppBarNative' -as [type])) {
7
+ Add-Type @'
8
+ using System;
9
+ using System.Runtime.InteropServices;
10
+ public static class WinixAppBarNative {
11
+ [StructLayout(LayoutKind.Sequential)]
12
+ public struct Data { public uint size; public IntPtr hwnd; public uint message; public uint edge;
13
+ public int left; public int top; public int right; public int bottom; public IntPtr param; }
14
+ [DllImport("shell32.dll")] public static extern UIntPtr SHAppBarMessage(uint message, ref Data data);
15
+ }
16
+ '@
17
+ }
18
+ $appBar = [WinixAppBarNative+Data]::new()
19
+ $appBar.size = [Runtime.InteropServices.Marshal]::SizeOf($appBar)
20
+ `;
21
+ const prelude = `
22
+ $ErrorActionPreference = 'Stop'
23
+ $values = ConvertFrom-Json ${quote(JSON.stringify(values))}
24
+ ${appBar}
25
+ function Test-WinixPersonalization {
26
+ ${autoHide === undefined ? "" : `if ((([WinixAppBarNative]::SHAppBarMessage(4, [ref]$appBar).ToUInt64() -band 1) -ne 0) -ne $${autoHide}) { return $false }`}
27
+ foreach ($item in $values) {
28
+ $key = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey($item.path)
29
+ if ($null -eq $key) { return $false }
30
+ try {
31
+ if ($key.GetValueNames() -notcontains $item.name -or
32
+ $key.GetValueKind($item.name) -ne [Microsoft.Win32.RegistryValueKind]::DWord -or
33
+ ([long]$key.GetValue($item.name) -band 0xffffffffL) -ne [long]$item.value) { return $false }
34
+ } finally { $key.Dispose() }
35
+ }
36
+ return $true
37
+ }`;
38
+ return {
39
+ getScript: `${prelude}\n@{ InDesiredState = (Test-WinixPersonalization) }`,
40
+ testScript: `${prelude}\nTest-WinixPersonalization`,
41
+ setScript: `${prelude}
42
+ if (Test-WinixPersonalization) { return }
43
+ ${autoHide === undefined ? "" : `
44
+ $state = [WinixAppBarNative]::SHAppBarMessage(4, [ref]$appBar).ToUInt64()
45
+ $appBar.param = [IntPtr](($state -band 2) -bor ${autoHide ? 1 : 0})
46
+ [WinixAppBarNative]::SHAppBarMessage(10, [ref]$appBar) | Out-Null
47
+ `}
48
+ foreach ($item in $values) {
49
+ $key = [Microsoft.Win32.Registry]::CurrentUser.CreateSubKey($item.path)
50
+ try {
51
+ $signed = [BitConverter]::ToInt32([BitConverter]::GetBytes([uint32]$item.value), 0)
52
+ $key.SetValue($item.name, $signed, [Microsoft.Win32.RegistryValueKind]::DWord)
53
+ } finally { $key.Dispose() }
54
+ }
55
+ if (-not (Test-WinixPersonalization)) { throw 'Windows personalization verification failed' }
56
+ Write-Warning 'Some Explorer/taskbar/theme preferences take effect after signing out. Winix will not restart Explorer.'`,
57
+ };
58
+ }
59
+ export function wallpaperProperties(wallpaper, configDir) {
60
+ const source = typeof wallpaper.source === "string"
61
+ ? resolveWindowsSource(wallpaper.source, configDir, windowsSourcePath) : wallpaper.source;
62
+ const styles = { Fill: [10, 0], Fit: [6, 0], Stretch: [2, 0], Tile: [0, 1], Center: [0, 0], Span: [22, 0] };
63
+ const [style, tile] = styles[wallpaper.style ?? "Fill"];
64
+ const prelude = `${filePathPrelude().join("\n")}
65
+ $ErrorActionPreference = 'Stop'
66
+ $source = ${filePathExpression(source)}
67
+ if (-not (Test-Path -LiteralPath $source -PathType Leaf)) { throw "Wallpaper image does not exist: $source" }
68
+ $hash = (Get-FileHash -LiteralPath $source -Algorithm SHA256).Hash
69
+ $cache = Join-Path $env:LOCALAPPDATA 'Winix\\wallpapers'
70
+ $target = Join-Path $cache ($hash + [IO.Path]::GetExtension($source))
71
+ $desktop = [Microsoft.Win32.Registry]::CurrentUser.OpenSubKey('Control Panel\\Desktop')
72
+ function Test-WinixWallpaper {
73
+ if ($null -eq $desktop) { return $false }
74
+ $image = [string]$desktop.GetValue('WallPaper', '')
75
+ return (Test-Path -LiteralPath $target -PathType Leaf) -and
76
+ (Get-FileHash -LiteralPath $target -Algorithm SHA256).Hash -eq $hash -and
77
+ $image -eq $target -and
78
+ [string]$desktop.GetValue('WallpaperStyle', '') -eq '${style}' -and
79
+ [string]$desktop.GetValue('TileWallpaper', '') -eq '${tile}'
80
+ }`;
81
+ const dispose = "if ($null -ne $desktop) { $desktop.Dispose() }";
82
+ return {
83
+ getScript: `${prelude}\ntry { @{ InDesiredState = (Test-WinixWallpaper) } } finally { ${dispose} }`,
84
+ testScript: `${prelude}\ntry { Test-WinixWallpaper } finally { ${dispose} }`,
85
+ setScript: `${prelude}
86
+ try { $matches = Test-WinixWallpaper } finally { ${dispose} }
87
+ if ($matches) { return }
88
+ Add-Type -AssemblyName System.Drawing
89
+ $image = [System.Drawing.Image]::FromFile($source)
90
+ try {
91
+ if ($image.Width -lt 1 -or $image.Height -lt 1) { throw 'Invalid wallpaper image' }
92
+ } finally { $image.Dispose() }
93
+ New-Item -ItemType Directory -Path $cache -Force | Out-Null
94
+ if (-not (Test-Path -LiteralPath $target)) { [IO.File]::Copy($source, $target, $false) }
95
+ if ((Get-FileHash -LiteralPath $target -Algorithm SHA256).Hash -ne $hash) { throw 'Wallpaper changed or its cache is corrupt' }
96
+ if (-not ('WinixWallpaperNative' -as [type])) {
97
+ Add-Type @'
98
+ using System;
99
+ using System.Runtime.InteropServices;
100
+ public static class WinixWallpaperNative {
101
+ [DllImport("user32.dll", CharSet=CharSet.Unicode, SetLastError=true)]
102
+ public static extern bool SystemParametersInfo(uint action, uint param, string value, uint flags);
103
+ }
104
+ '@
105
+ }
106
+ $key = [Microsoft.Win32.Registry]::CurrentUser.CreateSubKey('Control Panel\\Desktop')
107
+ try {
108
+ $previousStyle = $key.GetValue('WallpaperStyle', $null)
109
+ $previousTile = $key.GetValue('TileWallpaper', $null)
110
+ $key.SetValue('WallpaperStyle', '${style}', [Microsoft.Win32.RegistryValueKind]::String)
111
+ $key.SetValue('TileWallpaper', '${tile}', [Microsoft.Win32.RegistryValueKind]::String)
112
+ } finally { $key.Dispose() }
113
+ if (-not [WinixWallpaperNative]::SystemParametersInfo(20, 0, $target, 3)) {
114
+ $failure = [System.ComponentModel.Win32Exception]::new([Runtime.InteropServices.Marshal]::GetLastWin32Error())
115
+ $key = [Microsoft.Win32.Registry]::CurrentUser.CreateSubKey('Control Panel\\Desktop')
116
+ try {
117
+ if ($null -eq $previousStyle) { $key.DeleteValue('WallpaperStyle', $false) }
118
+ else { $key.SetValue('WallpaperStyle', $previousStyle, [Microsoft.Win32.RegistryValueKind]::String) }
119
+ if ($null -eq $previousTile) { $key.DeleteValue('TileWallpaper', $false) }
120
+ else { $key.SetValue('TileWallpaper', $previousTile, [Microsoft.Win32.RegistryValueKind]::String) }
121
+ } finally { $key.Dispose() }
122
+ throw $failure
123
+ }`,
124
+ };
125
+ }
@@ -3,7 +3,9 @@ import { type WindowsLock, type WindowsPackageVersionResolver, type WindowsModul
3
3
  import { type WindowsWslImageResolver } from "../../backends/windows/wsl.js";
4
4
  import { type WindowsWslRepositoryResolver } from "../../backends/windows/wsl-setup.js";
5
5
  import { type ActivationPlatform } from "../activation.js";
6
+ import { type WindowsFontResolver } from "../../backends/windows/fonts.js";
6
7
  interface ApplyOptions {
8
+ resolveWindowsFont?: WindowsFontResolver;
7
9
  /** Activation-only overrides; the committed lock and inline declarations remain unchanged. */
8
10
  windowsPackageVersions?: (hosts: ReturnType<typeof evaluate>, lock: WindowsLock) => Promise<Record<string, string>>;
9
11
  host?: string;
@@ -12,6 +12,7 @@ import { resolvePowerShellModuleVersion } from "../../backends/windows/powershel
12
12
  import { resolveNixosWslImage } from "../../backends/windows/wsl.js";
13
13
  import { resolveWslRepository } from "../../backends/windows/wsl-setup.js";
14
14
  import { platformForEvaluatedHost } from "../activation.js";
15
+ import { collectFontSources, resolveWindowsFonts, resolveFontSource } from "../../backends/windows/fonts.js";
15
16
  export async function applyWorkspace(cwd, opts) {
16
17
  const { workspace, configDir } = await loadWorkspace(cwd);
17
18
  let evaluated = evaluate(workspace);
@@ -29,7 +30,7 @@ export async function applyWorkspace(cwd, opts) {
29
30
  for (const host of windowsHosts)
30
31
  validateWindowsWslResources(host.windows);
31
32
  const windowsLock = windowsHosts.length > 0
32
- ? await prepareWindowsLock(configDir, windowsHosts, opts.dry || opts.windowsLockDry === true, opts.resolveWindowsPackageVersion ?? resolveWingetVersion, opts.resolveWindowsModuleVersion ?? resolvePowerShellModuleVersion, opts.resolveWindowsWslImage ?? resolveNixosWslImage, opts.resolveWindowsWslRepository ?? resolveWslRepository)
33
+ ? await prepareWindowsLock(configDir, windowsHosts, opts.dry || opts.windowsLockDry === true, opts.resolveWindowsPackageVersion ?? resolveWingetVersion, opts.resolveWindowsModuleVersion ?? resolvePowerShellModuleVersion, opts.resolveWindowsWslImage ?? resolveNixosWslImage, opts.resolveWindowsWslRepository ?? resolveWslRepository, opts.resolveWindowsFont ?? resolveFontSource)
33
34
  : undefined;
34
35
  const nixOutput = nixHosts.length > 0 ? generateNix(workspace, nixHosts) : undefined;
35
36
  const runtimeVersions = windowsLock && opts.windowsPackageVersions
@@ -91,7 +92,7 @@ export async function applyWorkspace(cwd, opts) {
91
92
  export async function apply(cwd, opts) {
92
93
  await applyWorkspace(cwd, opts);
93
94
  }
94
- async function prepareWindowsLock(configDir, windowsHosts, dry, resolveVersion, resolveModuleVersion, resolveWslImage, resolveRepository) {
95
+ async function prepareWindowsLock(configDir, windowsHosts, dry, resolveVersion, resolveModuleVersion, resolveWslImage, resolveRepository, resolveFont) {
95
96
  const now = new Date();
96
97
  const lock = readWindowsLock(configDir) ?? emptyWindowsLock(now);
97
98
  const reconciled = reconcileInlinePins(lock, windowsHosts, now);
@@ -101,9 +102,10 @@ async function prepareWindowsLock(configDir, windowsHosts, dry, resolveVersion,
101
102
  ? await resolveWindowsWslImages(modules.lock, resolveWslImage, now, true)
102
103
  : { lock: modules.lock, changed: false };
103
104
  const repositories = resolveWindowsWslRepositories(images.lock, windowsHosts, resolveRepository, now, true);
104
- const changed = windowsLockChanged(lock, repositories.lock);
105
+ const fonts = await resolveWindowsFonts(repositories.lock, collectFontSources(windowsHosts).values(), resolveFont, now, true);
106
+ const changed = windowsLockChanged(lock, fonts.lock);
105
107
  if (!changed)
106
- return repositories.lock;
108
+ return fonts.lock;
107
109
  if (dry) {
108
110
  if (windowsLockChanged(lock, resolved.lock))
109
111
  printWindowsLockDryRun(resolved.resolutions);
@@ -113,9 +115,11 @@ async function prepareWindowsLock(configDir, windowsHosts, dry, resolveVersion,
113
115
  console.warn("Would pin verified NixOS-WSL images for x64/arm64 in winix-windows.lock");
114
116
  if (repositories.changed)
115
117
  console.warn("Would pin WSL setup repository commits in winix-windows.lock");
116
- return repositories.lock;
118
+ if (fonts.changed)
119
+ console.warn("Would pin verified font sources in winix-windows.lock");
120
+ return fonts.lock;
117
121
  }
118
- writeWindowsLock(configDir, repositories.lock);
122
+ writeWindowsLock(configDir, fonts.lock);
119
123
  if (windowsLockChanged(lock, resolved.lock))
120
124
  printWindowsLockUpdate(resolved.resolutions);
121
125
  for (const entry of modules.resolutions)
@@ -124,7 +128,9 @@ async function prepareWindowsLock(configDir, windowsHosts, dry, resolveVersion,
124
128
  console.log("✓ Pinned verified NixOS-WSL images for x64/arm64 in winix-windows.lock");
125
129
  if (repositories.changed)
126
130
  console.log("✓ Pinned WSL setup repository commits in winix-windows.lock");
127
- return repositories.lock;
131
+ if (fonts.changed)
132
+ console.log("✓ Pinned verified font sources in winix-windows.lock");
133
+ return fonts.lock;
128
134
  }
129
135
  function printWindowsLockDryRun(resolutions) {
130
136
  if (resolutions.length === 0) {
@@ -1,7 +1,9 @@
1
1
  import { type WindowsPackageVersionResolver, type WindowsModuleVersionResolver } from "../../backends/windows/lockfile.js";
2
2
  import { type WindowsWslImageResolver } from "../../backends/windows/wsl.js";
3
3
  import { type WindowsWslRepositoryResolver } from "../../backends/windows/wsl-setup.js";
4
+ import { type WindowsFontResolver } from "../../backends/windows/fonts.js";
4
5
  interface UpdateOptions {
6
+ resolveWindowsFont?: WindowsFontResolver;
5
7
  inputs: string[];
6
8
  dry: boolean;
7
9
  windows?: boolean;
@@ -12,6 +12,7 @@ import { platformForEvaluatedHost } from "../activation.js";
12
12
  import { loadWorkspace } from "../loader.js";
13
13
  import { runCommand } from "../run.js";
14
14
  import { applyWorkspace } from "./apply.js";
15
+ import { collectFontSources, resolveWindowsFonts, resolveFontSource } from "../../backends/windows/fonts.js";
15
16
  export async function update(cwd, opts) {
16
17
  if (opts.windows) {
17
18
  await updateWindowsLock(cwd, opts);
@@ -75,11 +76,13 @@ async function updateWindowsLock(cwd, opts) {
75
76
  const pinned = collectInlinePinnedPackages(windowsHosts);
76
77
  const floating = collectFloatingPackages(windowsHosts, pinned);
77
78
  const modules = collectWindowsModules(windowsHosts);
79
+ const fonts = collectFontSources(windowsHosts);
78
80
  const wslImages = hasWindowsWslDistros(windowsHosts);
79
81
  const wslSetup = windowsHosts.some((host) => host.windows.dsc?.some((resource) => resource.winix?.kind === "wsl-distro" && resource.winix.distro.setup));
80
82
  for (const id of opts.inputs) {
81
83
  if (!floating.has(id) && !pinned.has(id) &&
82
84
  ![...modules.values()].some((module) => module.name.toLowerCase() === id.toLowerCase()) &&
85
+ !(id === "fonts" && fonts.size > 0) &&
83
86
  !(id === "nixos-wsl" && wslImages) && !(id === "wsl-setup" && wslSetup)) {
84
87
  throw new Error(`Windows package, PowerShell module, WSL image or setup repository "${id}" is not declared in this workspace.`);
85
88
  }
@@ -116,6 +119,12 @@ async function updateWindowsLock(cwd, opts) {
116
119
  changed = changed || repositories.changed;
117
120
  console.log(` ${repositories.changed ? "resolved" : "up to date"} WSL setup repository commits (first-run only)`);
118
121
  }
122
+ if (fonts.size > 0 && (opts.inputs.length === 0 || opts.inputs.includes("fonts"))) {
123
+ const result = await resolveWindowsFonts(lock, fonts.values(), opts.resolveWindowsFont ?? resolveFontSource, now);
124
+ lock = result.lock;
125
+ changed = changed || result.changed;
126
+ console.log(` ${result.changed ? "resolved" : "up to date"} font sources`);
127
+ }
119
128
  for (const resolution of resolved.resolutions) {
120
129
  if (resolution.status === "up-to-date") {
121
130
  console.log(` up to date ${resolution.id} ${resolution.source} ${resolution.version}`);
package/dist/cli/index.js CHANGED
@@ -13,6 +13,7 @@ import { renderSkill } from "../skill.js";
13
13
  import { bootstrapCheckout, runCheckout } from "./commands/bootstrap.js";
14
14
  import { forgetWindowsResource, windowsStatePath, listWindowsOwners, migrateWindowsOwner, windowsStateOwner, } from "./windows-state.js";
15
15
  import { findConfig } from "./loader.js";
16
+ import { nerdFontsCatalog } from "../backends/windows/fonts.js";
16
17
  if (process.argv[2] === "run") {
17
18
  try {
18
19
  await runCheckout(process.cwd(), process.argv.slice(3));
@@ -27,6 +28,7 @@ const { positionals, values } = parseArgs({
27
28
  allowPositionals: true,
28
29
  options: {
29
30
  host: { type: "string" },
31
+ provider: { type: "string" },
30
32
  dry: { type: "boolean", default: false },
31
33
  yes: { type: "boolean", short: "y", default: false },
32
34
  diff: { type: "boolean", default: false },
@@ -67,6 +69,7 @@ Commands:
67
69
  switch Generate output and run the host activation command
68
70
  update Update generated flake.lock and copy it to project root
69
71
  inspect Print host composition and fragment graph
72
+ fonts search [query] --provider nerd-fonts Search official font release IDs
70
73
  state forget Release Windows removal ownership without deleting a resource
71
74
  state owners List Windows applied-state owners and their migration IDs
72
75
  state migrate-owner <id> Transfer an old owner's requirements to this checkout/--host
@@ -110,6 +113,25 @@ if (values.yes && command !== "switch" && command !== "bootstrap" &&
110
113
  process.exit(2);
111
114
  }
112
115
  switch (command) {
116
+ case "fonts":
117
+ try {
118
+ if (positionals[1] !== "search" || positionals.length > 3 || values.provider !== "nerd-fonts") {
119
+ throw new Error("Usage: winix fonts search [query] --provider nerd-fonts");
120
+ }
121
+ const catalog = await nerdFontsCatalog();
122
+ const query = positionals[2]?.toLowerCase() ?? "";
123
+ const fonts = catalog.fonts.filter((font) => font.family.toLowerCase().includes(query));
124
+ if (!fonts.length)
125
+ throw new Error(`No Nerd Fonts IDs match "${query}"`);
126
+ console.log(`Nerd Fonts ${catalog.version} (download IDs, not installed family names):`);
127
+ for (const font of fonts)
128
+ console.log(` ${font.family}`);
129
+ }
130
+ catch (error) {
131
+ console.error(`Error: ${error.message}`);
132
+ process.exit(1);
133
+ }
134
+ break;
113
135
  case "bootstrap":
114
136
  try {
115
137
  await bootstrapCheckout(cwd, {
@@ -0,0 +1,10 @@
1
+ import type { WinFontSource, WinPersonalization, WinWallpaper } from "../types/windows.js";
2
+ export declare function fontHttpsUrl(value: string): string;
3
+ export declare function validateFontSources(sources: WinFontSource[]): void;
4
+ export declare function validateWallpaper(wallpaper: WinWallpaper): void;
5
+ export interface PersonalizationRegistryValue {
6
+ path: string;
7
+ name: string;
8
+ value: number;
9
+ }
10
+ export declare function personalizationValues(options: WinPersonalization): PersonalizationRegistryValue[];
@@ -0,0 +1,140 @@
1
+ export function fontHttpsUrl(value) {
2
+ let url;
3
+ try {
4
+ url = new URL(value);
5
+ }
6
+ catch {
7
+ throw new Error("Font source must be an absolute HTTPS URL");
8
+ }
9
+ if (url.protocol !== "https:" || url.username || url.password || url.hash) {
10
+ throw new Error("Font sources require HTTPS without credentials or fragments");
11
+ }
12
+ return url.href;
13
+ }
14
+ export function validateFontSources(sources) {
15
+ if (!Array.isArray(sources) || sources.length === 0)
16
+ throw new Error("windows.fonts requires nonempty sources");
17
+ for (const source of sources) {
18
+ if (typeof source === "string") {
19
+ if (!source.trim() || /[\0\r\n]/.test(source) || !/\.(ttf|otf)$/i.test(source) || /^https?:/i.test(source)) {
20
+ throw new Error("Local font sources must be TTF/OTF file paths; use { url } for downloads");
21
+ }
22
+ }
23
+ else if (source && typeof source === "object" && "url" in source) {
24
+ fontHttpsUrl(source.url);
25
+ if (source.sha256 !== undefined && !/^[a-f0-9]{64}$/i.test(source.sha256)) {
26
+ throw new Error("Font sha256 must contain 64 hexadecimal characters");
27
+ }
28
+ if (source.files !== undefined && (!Array.isArray(source.files) || source.files.length === 0 ||
29
+ source.files.some((file) => typeof file !== "string" ||
30
+ (!/^\*\*\/\*\.(ttf|otf)$/i.test(file) &&
31
+ (!/^[^:*?\\\0]+?\.(ttf|otf)$/i.test(file) || file.startsWith("/") ||
32
+ file.split("/").some((part) => !part || part === "." || part === "..")))))) {
33
+ throw new Error("Font files must be safe ZIP member names or **/*.ttf / **/*.otf selectors");
34
+ }
35
+ if (!/\.(zip|ttf|otf)$/i.test(new URL(source.url).pathname)) {
36
+ throw new Error("Remote fonts must be a .zip, .ttf or .otf URL");
37
+ }
38
+ if (source.files !== undefined && !/\.zip$/i.test(new URL(source.url).pathname)) {
39
+ throw new Error("Font file selectors are only supported for ZIP sources");
40
+ }
41
+ }
42
+ else if (source && typeof source === "object" && "provider" in source &&
43
+ source.provider === "nerd-fonts") {
44
+ if (!/^[a-z0-9][a-z0-9_-]*$/i.test(source.family) ||
45
+ (source.version !== undefined && !/^v\d+\.\d+\.\d+$/.test(source.version))) {
46
+ throw new Error("Nerd Fonts requires a catalog family ID and an optional vX.Y.Z release tag");
47
+ }
48
+ }
49
+ else {
50
+ throw new Error("Unsupported font source/provider");
51
+ }
52
+ }
53
+ }
54
+ export function validateWallpaper(wallpaper) {
55
+ if (!wallpaper || typeof wallpaper !== "object")
56
+ throw new Error("windows.wallpaper requires an object");
57
+ const source = wallpaper.source;
58
+ if (typeof source === "string") {
59
+ if (!source.trim() || /[\0\r\n]/.test(source) || /^https?:/i.test(source)) {
60
+ throw new Error("Wallpaper requires a local image path");
61
+ }
62
+ }
63
+ else if (!source || source.kind !== "knownFolder" ||
64
+ !["documents", "desktop", "localAppData", "appData", "userProfile"].includes(source.folder) ||
65
+ typeof source.path !== "string" || /[\0\r\n]/.test(source.path) ||
66
+ /^[\\/]|^[a-z]:/i.test(source.path) || source.path.split(/[\\/]/).includes("..")) {
67
+ throw new Error("Wallpaper requires a valid known-folder or local image path");
68
+ }
69
+ if (wallpaper.style !== undefined &&
70
+ !["Fill", "Fit", "Stretch", "Tile", "Center", "Span"].includes(wallpaper.style)) {
71
+ throw new Error("Unsupported wallpaper style");
72
+ }
73
+ }
74
+ export function personalizationValues(options) {
75
+ if (!options || typeof options !== "object" || Array.isArray(options)) {
76
+ throw new Error("windows.personalization requires an object");
77
+ }
78
+ const values = [];
79
+ const advanced = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Advanced";
80
+ const add = (path, name, value) => values.push({ path, name, value });
81
+ for (const key of Object.keys(options)) {
82
+ if (!["accentColor", "explorer", "taskbar"].includes(key))
83
+ throw new Error(`Unknown personalization option ${key}`);
84
+ }
85
+ if (options.accentColor !== undefined) {
86
+ if (!/^#[a-f0-9]{6}$/i.test(options.accentColor))
87
+ throw new Error("accentColor must be #RRGGBB");
88
+ const rgb = options.accentColor.slice(1);
89
+ const bgr = parseInt(`${rgb.slice(4)}${rgb.slice(2, 4)}${rgb.slice(0, 2)}`, 16);
90
+ add("Software\\Microsoft\\Windows\\DWM", "AccentColor", (0xff000000 + bgr) >>> 0);
91
+ add("Software\\Microsoft\\Windows\\DWM", "ColorizationColor", (0xff000000 + parseInt(rgb, 16)) >>> 0);
92
+ add("Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Accent", "AccentColorMenu", (0xff000000 + bgr) >>> 0);
93
+ add("Control Panel\\Desktop", "AutoColorization", 0);
94
+ }
95
+ if (options.explorer !== undefined) {
96
+ if (!options.explorer || typeof options.explorer !== "object" || Array.isArray(options.explorer)) {
97
+ throw new Error("explorer personalization must be an object");
98
+ }
99
+ for (const [key, value] of Object.entries(options.explorer)) {
100
+ if (key === "openTo") {
101
+ if (value !== "ThisPC" && value !== "Home")
102
+ throw new Error("explorer.openTo must be ThisPC or Home");
103
+ add(advanced, "LaunchTo", value === "ThisPC" ? 1 : 2);
104
+ }
105
+ else {
106
+ if (!["showExtensions", "showHiddenFiles"].includes(key) || typeof value !== "boolean") {
107
+ throw new Error(`Invalid explorer personalization ${key}`);
108
+ }
109
+ add(advanced, key === "showExtensions" ? "HideFileExt" : "Hidden", key === "showExtensions" ? (value ? 0 : 1) : (value ? 1 : 2));
110
+ }
111
+ }
112
+ }
113
+ if (options.taskbar !== undefined) {
114
+ if (!options.taskbar || typeof options.taskbar !== "object" || Array.isArray(options.taskbar)) {
115
+ throw new Error("taskbar personalization must be an object");
116
+ }
117
+ for (const [key, value] of Object.entries(options.taskbar)) {
118
+ if (key === "autoHide") {
119
+ if (typeof value !== "boolean")
120
+ throw new Error("taskbar.autoHide must be boolean");
121
+ continue;
122
+ }
123
+ if (key === "search") {
124
+ const modes = ["Hidden", "Icon", "Box", "IconAndLabel"];
125
+ if (typeof value !== "string" || !modes.includes(value))
126
+ throw new Error("Invalid taskbar.search mode");
127
+ add("Software\\Microsoft\\Windows\\CurrentVersion\\Search", "SearchboxTaskbarMode", modes.indexOf(value));
128
+ }
129
+ else {
130
+ if (!["taskView", "widgets"].includes(key) || typeof value !== "boolean") {
131
+ throw new Error(`Invalid taskbar personalization ${key}`);
132
+ }
133
+ add(advanced, key === "taskView" ? "ShowTaskViewButton" : "TaskbarDa", value ? 1 : 0);
134
+ }
135
+ }
136
+ }
137
+ if (!values.length && options.taskbar?.autoHide === undefined)
138
+ throw new Error("windows.personalization requires at least one setting");
139
+ return values;
140
+ }
@@ -1,5 +1,5 @@
1
1
  import type { Fragment, ResourceHandle } from "../core/types.js";
2
- import type { WinDscProperties, WinDscResource, WinPackageSource, WinSettings, WinFilePath, WinKnownFolder, WinKnownFolderName, WinStartupCommand, WinWslConfig, WinWslDistro, WinWslSetup, WinPowerShellRepositoryPolicy } from "../types/index.js";
2
+ import type { WinDscProperties, WinDscResource, WinPackageSource, WinSettings, WinFilePath, WinKnownFolder, WinKnownFolderName, WinStartupCommand, WinWslConfig, WinWslDistro, WinWslSetup, WinPowerShellRepositoryPolicy, WinFontSource, WinWallpaper, WinPersonalization } from "../types/index.js";
3
3
  /**
4
4
  * Accepted call shapes for `windows.package(...)`.
5
5
  *
@@ -99,6 +99,7 @@ export interface WinFileOpts {
99
99
  }
100
100
  /** Rebuild scripts after the emitter supplies the config directory. */
101
101
  export declare function resolveWindowsFileProperties(resource: WinDscResource, configDir?: string, sourcePath?: (path: string) => string): WinDscProperties | undefined;
102
+ export declare function resolveWindowsSource(original: string, configDir?: string, sourcePath?: (path: string) => string): string;
102
103
  export declare function filePathPrelude(): string[];
103
104
  export interface WinEnvNamespace {
104
105
  set(name: string, value: string, opts?: WinEnvOpts): ResourceHandle;
@@ -115,6 +116,14 @@ export interface WinFileNamespace {
115
116
  remove(target: WinFilePath, opts?: WinFileOpts): ResourceHandle;
116
117
  }
117
118
  export interface WindowsHelper {
119
+ fonts(spec: {
120
+ sources: WinFontSource[];
121
+ dependsOn?: ResourceHandle | ResourceHandle[];
122
+ }): ResourceHandle;
123
+ wallpaper(spec: WinWallpaper & {
124
+ dependsOn?: ResourceHandle | ResourceHandle[];
125
+ }): ResourceHandle;
126
+ personalization(options: WinPersonalization, opts?: WinSettingOpts): ResourceHandle;
118
127
  optionalFeature(name: string, opts?: WinOptionalFeatureOpts): ResourceHandle;
119
128
  wsl: WinWslNamespace;
120
129
  /** Manage named current-user Startup shortcuts without running the commands during apply. */
@@ -7,6 +7,8 @@ import { resolve, win32, posix } from "node:path";
7
7
  import { fileURLToPath } from "node:url";
8
8
  import { powerShellLiteral as psSingleQuoted } from "./utils.js";
9
9
  import { validatePowerShellRepositoryPolicy } from "./windows-repositories.js";
10
+ import { validateFontSources, validateWallpaper, personalizationValues } from "./windows-personalization.js";
11
+ import { personalizationProperties } from "../backends/windows/personalization.js";
10
12
  const KNOWN_FOLDERS = {
11
13
  documents: "MyDocuments",
12
14
  desktop: "Desktop",
@@ -502,7 +504,16 @@ export function resolveWindowsFileProperties(resource, configDir, sourcePath = (
502
504
  const file = resource.winix;
503
505
  if (file?.kind !== "file")
504
506
  return resource.properties;
505
- let source = file.source;
507
+ const source = file.source === undefined ? undefined : resolveWindowsSource(file.source, configDir, sourcePath);
508
+ switch (file.action) {
509
+ case "text": return buildFileTextScriptProperties({ ...file, content: file.content });
510
+ case "remove": return buildFileRemoveScriptProperties(file);
511
+ case "symlink": return buildFileSymlinkScriptProperties({ ...file, source: source });
512
+ case "copy": return buildFileCopyScriptProperties({ ...file, source: source });
513
+ }
514
+ }
515
+ export function resolveWindowsSource(original, configDir, sourcePath = (path) => path) {
516
+ let source = original;
506
517
  if (source !== undefined && !/%[^%]+%/.test(source) &&
507
518
  !win32.isAbsolute(source) && !posix.isAbsolute(source)) {
508
519
  if (!configDir)
@@ -517,12 +528,7 @@ export function resolveWindowsFileProperties(resource, configDir, sourcePath = (
517
528
  }
518
529
  if (source !== undefined && !/%[^%]+%/.test(source))
519
530
  source = sourcePath(source);
520
- switch (file.action) {
521
- case "text": return buildFileTextScriptProperties({ ...file, content: file.content });
522
- case "remove": return buildFileRemoveScriptProperties(file);
523
- case "symlink": return buildFileSymlinkScriptProperties({ ...file, source: source });
524
- case "copy": return buildFileCopyScriptProperties({ ...file, source: source });
525
- }
531
+ return source;
526
532
  }
527
533
  function buildPathScriptProperties(opts) {
528
534
  const registryPath = envRegistryPath(opts.scope);
@@ -1064,6 +1070,25 @@ export const windows = {
1064
1070
  return asHandle(fragment, { kind: "dsc", token: resource.token });
1065
1071
  },
1066
1072
  setting: (settings, opts) => dscHandle(normalizeSetting(settings, opts)),
1073
+ fonts: (spec) => {
1074
+ validateFontSources(spec?.sources);
1075
+ return dscHandle(withDscMetadata(withDscToken({
1076
+ resourceType: POWERSHELL_SCRIPT_RESOURCE, name: "Windows fonts",
1077
+ dependsOn: resolveDependsOn(spec.dependsOn),
1078
+ }), { kind: "fonts", sources: spec.sources }));
1079
+ },
1080
+ wallpaper: (spec) => {
1081
+ validateWallpaper(spec);
1082
+ return dscHandle(withDscMetadata(withDscToken({
1083
+ resourceType: POWERSHELL_SCRIPT_RESOURCE, name: "Windows wallpaper",
1084
+ dependsOn: resolveDependsOn(spec.dependsOn),
1085
+ }), { kind: "wallpaper", wallpaper: { source: spec.source, style: spec.style } }));
1086
+ },
1087
+ personalization: (options, opts) => dscHandle(withDscToken({
1088
+ resourceType: POWERSHELL_SCRIPT_RESOURCE, name: "Windows personalization",
1089
+ properties: personalizationProperties(personalizationValues(options), options.taskbar?.autoHide),
1090
+ dependsOn: resolveDependsOn(opts?.dependsOn),
1091
+ })),
1067
1092
  env: {
1068
1093
  set: (name, value, opts) => dscHandle(normalizeEnv(name, "Present", value, opts)),
1069
1094
  remove: (name, opts) => dscHandle(normalizeEnv(name, "Absent", undefined, opts)),
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type { Fragment, ResourceHandle, 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, WinSettings, WinColorMode, WinStartFolder, WinTaskbarAlignment, WinTaskbarGroupingMode, WinTaskbarMultiMonMode, WinKnownFolder, WinKnownFolderName, WinFilePath, WinPowerShellModule, WinPowerShellRepositoryPolicy, WinStartupCommand, WinStartupWindowStyle, } 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, WinFontSource, WinWallpaper, WinPersonalization, WinColorMode, WinStartFolder, WinTaskbarAlignment, WinTaskbarGroupingMode, WinTaskbarMultiMonMode, WinKnownFolder, WinKnownFolderName, WinFilePath, WinPowerShellModule, WinPowerShellRepositoryPolicy, WinStartupCommand, WinStartupWindowStyle, } 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";
package/dist/skill.js CHANGED
@@ -257,6 +257,33 @@ Available helpers:
257
257
  Windows hosts generate a DSC v3 configuration for \`winget configure\`.
258
258
  Resources return handles that can be passed through \`dependsOn\`.
259
259
 
260
+ - \`windows.wallpaper({ source: "../wallpapers/desktop.jpg", style: "Fill" })\`
261
+ manages the current-user desktop image; source is a local/config-relative or
262
+ known-folder path. Styles: Fill, Fit, Stretch, Tile, Center, Span. Source
263
+ hashes detect changed images; remote wallpapers and per-monitor assignments
264
+ are not supported.
265
+ - \`windows.personalization({ accentColor: "#336699", explorer: {
266
+ showExtensions: true, showHiddenFiles: false, openTo: "ThisPC" }, taskbar: {
267
+ autoHide: false, search: "Hidden", taskView: true, widgets: false } })\`
268
+ changes only declared current-user values. Accent disables automatic coloring;
269
+ do not contradict it with windows.setting AutoColorization. Explorer openTo is
270
+ ThisPC/Home; search is Hidden/Icon/IconAndLabel/Box. Some preferences require
271
+ signing out and depend on Windows version/policy; never restart Explorer.
272
+ - \`windows.fonts({ sources: ["../fonts/font.ttf", {
273
+ url: "https://example.com/fonts.zip", files: ["**/*.ttf"] }, {
274
+ provider: "nerd-fonts", family: "JetBrainsMono" }] })\` installs current-user
275
+ TTF/OTF fonts. URL sources require HTTPS without credentials, optionally sha256;
276
+ files selects exact ZIP members or **/*.ttf / **/*.otf. Nerd Fonts is the only
277
+ provider, with optional exact version vX.Y.Z. Discover IDs with
278
+ \`winix fonts search [query] --provider nerd-fonts\`; IDs are not installed family
279
+ names. Remote sources lock URL/version/checksum; first resolution trusts upstream
280
+ unless an independent sha256 is supplied. \`winix update --windows fonts\`
281
+ refreshes only font pins. Apply reuses pins; dry runs don't write/install.
282
+ Installation verifies hashes, bounds/safely extracts ZIPs, reports actual font
283
+ families and rejects differing existing files/registry entries. Identical
284
+ files are reused; no font removal or automatic app font selection. Native
285
+ desktop/font activation remains unverified; don't rehearse on a shared machine.
286
+
260
287
  - \`windows.package()\` installs a winget or Microsoft Store package. A string
261
288
  means a floating winget package ID. The object form accepts \`id\`,
262
289
  \`source\`, \`version\`, and dependency options.
@@ -6,6 +6,35 @@ export interface WinKnownFolder {
6
6
  path: string;
7
7
  }
8
8
  export type WinFilePath = string | WinKnownFolder;
9
+ export type WinFontSource = string | {
10
+ url: string;
11
+ sha256?: string;
12
+ /** ZIP member names or recursive extension selectors; defaults to all TTF/OTF files. */
13
+ files?: string[];
14
+ } | {
15
+ provider: "nerd-fonts";
16
+ family: string;
17
+ /** Official release tag; omitted tags resolve latest once, then remain locked. */
18
+ version?: string;
19
+ };
20
+ export interface WinWallpaper {
21
+ source: WinFilePath;
22
+ style?: "Fill" | "Fit" | "Stretch" | "Tile" | "Center" | "Span";
23
+ }
24
+ export interface WinPersonalization {
25
+ accentColor?: string;
26
+ explorer?: {
27
+ showExtensions?: boolean;
28
+ showHiddenFiles?: boolean;
29
+ openTo?: "ThisPC" | "Home";
30
+ };
31
+ taskbar?: {
32
+ autoHide?: boolean;
33
+ search?: "Hidden" | "Icon" | "IconAndLabel" | "Box";
34
+ taskView?: boolean;
35
+ widgets?: boolean;
36
+ };
37
+ }
9
38
  export type WinStartupWindowStyle = "normal" | "minimized" | "maximized";
10
39
  export interface WinStartupCommand {
11
40
  /** Absolute/environment-variable path, known-folder path, or application name on PATH. */
@@ -186,6 +215,12 @@ export interface WinDscResource {
186
215
  dependsOn?: ResourceRef[];
187
216
  }
188
217
  export type WinDscMetadata = {
218
+ kind: "fonts";
219
+ sources: WinFontSource[];
220
+ } | {
221
+ kind: "wallpaper";
222
+ wallpaper: WinWallpaper;
223
+ } | {
189
224
  kind: "optional-features";
190
225
  names: string[];
191
226
  enabled: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adrifer/winix",
3
- "version": "0.3.0-preview.5",
3
+ "version": "0.3.0-preview.6",
4
4
  "description": "TypeScript-first system configuration for NixOS, nix-darwin, and Home Manager",
5
5
  "license": "MIT",
6
6
  "author": "Adrian Fernandez",