@adrifer/winix 0.1.2 → 0.1.3-preview.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -2
- package/dist/backends/nix/index.js +17 -10
- package/dist/backends/windows/index.d.ts +28 -0
- package/dist/backends/windows/index.js +151 -0
- package/dist/cli/activation.d.ts +4 -2
- package/dist/cli/activation.js +36 -4
- package/dist/cli/commands/apply.d.ts +2 -1
- package/dist/cli/commands/apply.js +75 -32
- package/dist/cli/commands/switch.d.ts +2 -0
- package/dist/cli/commands/switch.js +15 -3
- package/dist/cli/commands/update.d.ts +1 -0
- package/dist/cli/commands/update.js +19 -0
- package/dist/cli/index.js +2 -2
- package/dist/core/types.d.ts +2 -1
- package/dist/evaluator/index.d.ts +1 -0
- package/dist/evaluator/index.js +4 -0
- package/dist/helpers/index.d.ts +3 -1
- package/dist/helpers/index.js +1 -0
- package/dist/helpers/platforms.d.ts +5 -0
- package/dist/helpers/platforms.js +14 -1
- package/dist/helpers/windows.d.ts +28 -0
- package/dist/helpers/windows.js +39 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +2 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/windows.d.ts +45 -0
- package/dist/types/windows.js +8 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -35,7 +35,7 @@ const inputs = defineInputs({
|
|
|
35
35
|
});
|
|
36
36
|
|
|
37
37
|
const wsl = feature("wsl", () => [
|
|
38
|
-
nixos.imports("nixos-wsl"),
|
|
38
|
+
nixos.imports("inputs.nixos-wsl.nixosModules.wsl"),
|
|
39
39
|
nixos({ wsl: { enable: true } }),
|
|
40
40
|
nixos.program("nix-ld"),
|
|
41
41
|
]);
|
|
@@ -82,6 +82,12 @@ export default workspace({
|
|
|
82
82
|
|
|
83
83
|
> Winix is early software. The core pipeline works end-to-end, but the public API is still evolving.
|
|
84
84
|
|
|
85
|
+
### Why the name?
|
|
86
|
+
|
|
87
|
+
It started as a half-joke about wrapping Nix for **Win**dows (early prototypes targeted WSL first). The name stuck because **Win + Nix** also reads as "winning at Nix", which felt apt for a project that's trying to make the Nix ecosystem a bit less painful to onboard into.
|
|
88
|
+
|
|
89
|
+
For what it's worth: Winix today works just as well on macOS and native NixOS as it does on WSL. The Windows-flavored origin survives in the name only.
|
|
90
|
+
|
|
85
91
|
## Install and create a config
|
|
86
92
|
|
|
87
93
|
```bash
|
|
@@ -239,7 +245,7 @@ host("wsl", platforms.nixos({ stateVersion: "25.05" }), [
|
|
|
239
245
|
Winix includes helpers for common Nix namespaces:
|
|
240
246
|
|
|
241
247
|
```ts
|
|
242
|
-
nixos.imports("nixos-wsl")
|
|
248
|
+
nixos.imports("inputs.nixos-wsl.nixosModules.wsl")
|
|
243
249
|
nixos.networking({ hostName: "server", firewall: { allowedTCPPorts: [22, 443] } })
|
|
244
250
|
nixos.service("openssh", { settings: { PermitRootLogin: "no" } })
|
|
245
251
|
nixos.systemd.service("backup", { script: "echo backup" })
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
// Nix backend: generates .nix files from evaluated host IR
|
|
2
|
+
import { posix as pathPosix } from "node:path";
|
|
2
3
|
/**
|
|
3
4
|
* Generate Nix files from an evaluated workspace.
|
|
4
5
|
*/
|
|
@@ -23,7 +24,7 @@ function generateFlake(workspace, hosts) {
|
|
|
23
24
|
.filter((h) => Object.keys(h.nixos).length > 0)
|
|
24
25
|
.map((h) => ` nixosConfigurations.${h.name} = nixpkgs.lib.nixosSystem {\n` +
|
|
25
26
|
` system = "${systemForHost(h, "nixos")}";\n` +
|
|
26
|
-
` modules = [
|
|
27
|
+
` modules = [ ${nixRelativePath("hosts", `${h.name}.nix`)} ];\n` +
|
|
27
28
|
` specialArgs = { inherit inputs; };\n` +
|
|
28
29
|
` };`)
|
|
29
30
|
.join("\n\n");
|
|
@@ -31,7 +32,7 @@ function generateFlake(workspace, hosts) {
|
|
|
31
32
|
.filter((h) => Object.keys(h.darwin).length > 0)
|
|
32
33
|
.map((h) => ` darwinConfigurations.${h.name} = inputs.nix-darwin.lib.darwinSystem {\n` +
|
|
33
34
|
` system = "${systemForHost(h, "darwin")}";\n` +
|
|
34
|
-
` modules = [
|
|
35
|
+
` modules = [ ${nixRelativePath("hosts", `${h.name}.nix`)} ];\n` +
|
|
35
36
|
` specialArgs = { inherit inputs; };\n` +
|
|
36
37
|
` };`)
|
|
37
38
|
.join("\n\n");
|
|
@@ -64,12 +65,6 @@ function formatInput(name, def) {
|
|
|
64
65
|
}
|
|
65
66
|
return lines.join("\n");
|
|
66
67
|
}
|
|
67
|
-
// Known input name → NixOS module path mapping
|
|
68
|
-
const MODULE_MAP = {
|
|
69
|
-
"home-manager": "inputs.home-manager.nixosModules.home-manager",
|
|
70
|
-
"nixos-wsl": "inputs.nixos-wsl.nixosModules.wsl",
|
|
71
|
-
"nix-darwin": "inputs.nix-darwin.darwinModules.default",
|
|
72
|
-
};
|
|
73
68
|
function generateHostModule(host) {
|
|
74
69
|
const lines = [
|
|
75
70
|
`# Generated by Winix — do not edit`,
|
|
@@ -213,10 +208,10 @@ function importsToNix(imports, indent) {
|
|
|
213
208
|
}
|
|
214
209
|
function formatImport(imp) {
|
|
215
210
|
if (isRawModuleRef(imp)) {
|
|
216
|
-
return
|
|
211
|
+
return pathPosix.join("..", "raw-modules", imp.path);
|
|
217
212
|
}
|
|
218
213
|
if (typeof imp === "string") {
|
|
219
|
-
return
|
|
214
|
+
return imp;
|
|
220
215
|
}
|
|
221
216
|
throw new Error("imports entries must be strings or rawModule() references");
|
|
222
217
|
}
|
|
@@ -393,8 +388,17 @@ function validateWorkspaceInputs(workspace, hosts) {
|
|
|
393
388
|
if (hosts.some((host) => Object.keys(host.darwin).length > 0) && !hasInput(workspace, "nix-darwin")) {
|
|
394
389
|
warnings.push("darwin host detected but workspace inputs do not include nix-darwin");
|
|
395
390
|
}
|
|
391
|
+
if (hosts.some(hasHomeManagerImport) && !hasInput(workspace, "home-manager")) {
|
|
392
|
+
warnings.push("home-manager module import detected but workspace inputs do not include home-manager");
|
|
393
|
+
}
|
|
396
394
|
return warnings;
|
|
397
395
|
}
|
|
396
|
+
function hasHomeManagerImport(host) {
|
|
397
|
+
return [
|
|
398
|
+
...getImports(host.nixos),
|
|
399
|
+
...getImports(host.darwin),
|
|
400
|
+
].some((imp) => typeof imp === "string" && imp.startsWith("inputs.home-manager."));
|
|
401
|
+
}
|
|
398
402
|
function hasInput(workspace, nixName) {
|
|
399
403
|
return Object.entries(workspace.inputs).some(([name, def]) => inputNixName(name, def) === nixName);
|
|
400
404
|
}
|
|
@@ -404,6 +408,9 @@ function inputNixName(name, def) {
|
|
|
404
408
|
function toKebabCase(str) {
|
|
405
409
|
return str.replace(/([a-z])([A-Z])/g, "$1-$2").toLowerCase();
|
|
406
410
|
}
|
|
411
|
+
function nixRelativePath(...segments) {
|
|
412
|
+
return `./${pathPosix.join(...segments)}`;
|
|
413
|
+
}
|
|
407
414
|
function filterKeys(obj, exclude) {
|
|
408
415
|
const result = {};
|
|
409
416
|
for (const [k, v] of Object.entries(obj)) {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { EvaluatedHost } from "../../evaluator/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Per-host generated output for the Windows backend.
|
|
4
|
+
*/
|
|
5
|
+
export interface WindowsHostOutput {
|
|
6
|
+
/** The WinGet Configuration document (YAML, DSC v3). */
|
|
7
|
+
"configuration.winget": string;
|
|
8
|
+
/** Thin PowerShell entry point that invokes `winget configure`. */
|
|
9
|
+
"apply.ps1": string;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Generated output for a workspace's Windows hosts, keyed by host name.
|
|
13
|
+
*/
|
|
14
|
+
export interface WindowsOutput {
|
|
15
|
+
hosts: Record<string, WindowsHostOutput>;
|
|
16
|
+
warnings: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* True when an evaluated host targets the Windows backend.
|
|
20
|
+
*/
|
|
21
|
+
export declare function isWindowsHost(host: {
|
|
22
|
+
windows?: Record<string, unknown>;
|
|
23
|
+
}): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Generate Windows bundles for every Windows host in the evaluated workspace.
|
|
26
|
+
* Non-Windows hosts are skipped.
|
|
27
|
+
*/
|
|
28
|
+
export declare function generateWindows(evaluatedHosts: EvaluatedHost[]): WindowsOutput;
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
// Windows backend: generates a winget Configuration bundle from evaluated host IR.
|
|
2
|
+
//
|
|
3
|
+
// MVP vertical slice: packages only, emitted as a WinGet Configuration document
|
|
4
|
+
// (`configuration.winget`) in native DSC v3 form plus a thin `apply.ps1` entry
|
|
5
|
+
// point.
|
|
6
|
+
//
|
|
7
|
+
// FORMAT: This emitter targets the native DSC v3 document shape, matching
|
|
8
|
+
// Microsoft's own WindowsDeveloperConfig workloads
|
|
9
|
+
// (github.com/microsoft/WindowsDeveloperConfig). That is:
|
|
10
|
+
//
|
|
11
|
+
// $schema: .../PowerShell/DSC/main/schemas/2023/08/config/document.json
|
|
12
|
+
// metadata:
|
|
13
|
+
// winget:
|
|
14
|
+
// processor: dscv3
|
|
15
|
+
// resources:
|
|
16
|
+
// - name: <friendly name>
|
|
17
|
+
// type: Microsoft.WinGet/Package
|
|
18
|
+
// properties:
|
|
19
|
+
// id: <package id>
|
|
20
|
+
// source: winget
|
|
21
|
+
// acceptAgreements: true
|
|
22
|
+
// metadata:
|
|
23
|
+
// winget:
|
|
24
|
+
// securityContext: elevated
|
|
25
|
+
//
|
|
26
|
+
// `winget configure -f configuration.winget` runs this directly; the dscv3
|
|
27
|
+
// processor is selected by the metadata block.
|
|
28
|
+
const DSC_SCHEMA = "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/config/document.json";
|
|
29
|
+
const WINGET_PACKAGE_TYPE = "Microsoft.WinGet/Package";
|
|
30
|
+
/**
|
|
31
|
+
* True when an evaluated host targets the Windows backend.
|
|
32
|
+
*/
|
|
33
|
+
export function isWindowsHost(host) {
|
|
34
|
+
return Boolean(host.windows && Object.keys(host.windows).length > 0);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Generate Windows bundles for every Windows host in the evaluated workspace.
|
|
38
|
+
* Non-Windows hosts are skipped.
|
|
39
|
+
*/
|
|
40
|
+
export function generateWindows(evaluatedHosts) {
|
|
41
|
+
const hosts = {};
|
|
42
|
+
const warnings = [];
|
|
43
|
+
for (const host of evaluatedHosts) {
|
|
44
|
+
if (!isWindowsHost(host))
|
|
45
|
+
continue;
|
|
46
|
+
const win = host.windows;
|
|
47
|
+
hosts[host.name] = {
|
|
48
|
+
"configuration.winget": generateConfiguration(host.name, win),
|
|
49
|
+
"apply.ps1": generateApplyScript(),
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return { hosts, warnings };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Render the WinGet Configuration YAML document (DSC v3) for one host.
|
|
56
|
+
*/
|
|
57
|
+
function generateConfiguration(hostName, win) {
|
|
58
|
+
const packages = sortedPackages(win.packages ?? {});
|
|
59
|
+
const lines = [];
|
|
60
|
+
lines.push(`# yaml-language-server: $schema=${DSC_SCHEMA}`);
|
|
61
|
+
lines.push(`# Generated by Winix for host "${hostName}". Do not edit.`);
|
|
62
|
+
lines.push(`$schema: ${DSC_SCHEMA}`);
|
|
63
|
+
lines.push("metadata:");
|
|
64
|
+
lines.push(" winget:");
|
|
65
|
+
lines.push(" processor: dscv3");
|
|
66
|
+
if (packages.length === 0) {
|
|
67
|
+
lines.push("resources: []");
|
|
68
|
+
return lines.join("\n") + "\n";
|
|
69
|
+
}
|
|
70
|
+
lines.push("resources:");
|
|
71
|
+
for (const pkg of packages) {
|
|
72
|
+
lines.push(...renderPackageResource(pkg));
|
|
73
|
+
}
|
|
74
|
+
return lines.join("\n") + "\n";
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Render one package as a DSC v3 `Microsoft.WinGet/Package` resource.
|
|
78
|
+
*
|
|
79
|
+
* ```yaml
|
|
80
|
+
* - name: Git.Git
|
|
81
|
+
* type: Microsoft.WinGet/Package
|
|
82
|
+
* properties:
|
|
83
|
+
* id: Git.Git
|
|
84
|
+
* source: winget
|
|
85
|
+
* acceptAgreements: true
|
|
86
|
+
* version: "2.44.0" # only when pinned
|
|
87
|
+
* metadata:
|
|
88
|
+
* winget:
|
|
89
|
+
* securityContext: elevated
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
function renderPackageResource(pkg) {
|
|
93
|
+
const out = [];
|
|
94
|
+
out.push(` - name: ${yamlScalar(pkg.id)}`);
|
|
95
|
+
out.push(` type: ${WINGET_PACKAGE_TYPE}`);
|
|
96
|
+
out.push(` properties:`);
|
|
97
|
+
out.push(` id: ${yamlScalar(pkg.id)}`);
|
|
98
|
+
out.push(` source: ${yamlScalar(pkg.source)}`);
|
|
99
|
+
out.push(` acceptAgreements: true`);
|
|
100
|
+
if (pkg.version !== undefined) {
|
|
101
|
+
// Quote versions so values like "1.0" are not parsed as numbers.
|
|
102
|
+
out.push(` version: ${yamlQuoted(pkg.version)}`);
|
|
103
|
+
}
|
|
104
|
+
// Only request elevation when explicitly asked. Per-user packages install
|
|
105
|
+
// fine without it, and forcing elevation makes `winget configure` fail with
|
|
106
|
+
// an internal error when run from a non-elevated shell.
|
|
107
|
+
if (pkg.elevated) {
|
|
108
|
+
out.push(` metadata:`);
|
|
109
|
+
out.push(` winget:`);
|
|
110
|
+
out.push(` securityContext: elevated`);
|
|
111
|
+
}
|
|
112
|
+
return out;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* The thin apply entry point. Idempotency, elevation, ordering, and error
|
|
116
|
+
* reporting all live inside `winget configure` / the DSC v3 processor.
|
|
117
|
+
*/
|
|
118
|
+
function generateApplyScript() {
|
|
119
|
+
return [
|
|
120
|
+
"# Generated by Winix. Do not edit.",
|
|
121
|
+
'$ErrorActionPreference = "Stop"',
|
|
122
|
+
"Set-Location -Path $PSScriptRoot",
|
|
123
|
+
"",
|
|
124
|
+
"winget configure `",
|
|
125
|
+
" -f .\\configuration.winget `",
|
|
126
|
+
" --accept-configuration-agreements `",
|
|
127
|
+
" --disable-interactivity",
|
|
128
|
+
"",
|
|
129
|
+
].join("\n");
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Stable ordering: packages sorted by id so the emitted document is
|
|
133
|
+
* deterministic regardless of declaration/merge order.
|
|
134
|
+
*/
|
|
135
|
+
function sortedPackages(packages) {
|
|
136
|
+
return Object.keys(packages)
|
|
137
|
+
.sort((a, b) => (a < b ? -1 : a > b ? 1 : 0))
|
|
138
|
+
.map((id) => packages[id]);
|
|
139
|
+
}
|
|
140
|
+
/**
|
|
141
|
+
* Render a YAML scalar. Package ids and sources are simple tokens; quote
|
|
142
|
+
* defensively only if the value contains YAML-significant characters.
|
|
143
|
+
*/
|
|
144
|
+
function yamlScalar(value) {
|
|
145
|
+
if (/^[A-Za-z0-9._+\-]+$/.test(value))
|
|
146
|
+
return value;
|
|
147
|
+
return yamlQuoted(value);
|
|
148
|
+
}
|
|
149
|
+
function yamlQuoted(value) {
|
|
150
|
+
return `"${value.replace(/\\/g, "\\\\").replace(/"/g, '\\"')}"`;
|
|
151
|
+
}
|
package/dist/cli/activation.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export type ActivationPlatform = "nixos" | "darwin";
|
|
2
|
-
export declare function activationCommand(platform: ActivationPlatform, flake: string, isRoot?: boolean): string[];
|
|
1
|
+
export type ActivationPlatform = "nixos" | "darwin" | "windows";
|
|
2
|
+
export declare function activationCommand(platform: ActivationPlatform, flake: string, isRoot?: boolean, osPlatform?: NodeJS.Platform): string[];
|
|
3
|
+
export declare function assertActivationSupported(platform: ActivationPlatform, osPlatform?: NodeJS.Platform): void;
|
|
3
4
|
export declare function platformForEvaluatedHost(host: {
|
|
4
5
|
nixos: Record<string, unknown>;
|
|
5
6
|
darwin: Record<string, unknown>;
|
|
7
|
+
windows: Record<string, unknown>;
|
|
6
8
|
}): ActivationPlatform;
|
package/dist/cli/activation.js
CHANGED
|
@@ -1,13 +1,45 @@
|
|
|
1
|
-
export function activationCommand(platform, flake, isRoot = isCurrentProcessRoot()) {
|
|
1
|
+
export function activationCommand(platform, flake, isRoot = isCurrentProcessRoot(), osPlatform = process.platform) {
|
|
2
|
+
if (platform === "windows") {
|
|
3
|
+
return [
|
|
4
|
+
"winget",
|
|
5
|
+
"configure",
|
|
6
|
+
"-f",
|
|
7
|
+
flake,
|
|
8
|
+
"--accept-configuration-agreements",
|
|
9
|
+
"--disable-interactivity",
|
|
10
|
+
];
|
|
11
|
+
}
|
|
2
12
|
const command = platform === "darwin"
|
|
3
13
|
? ["darwin-rebuild", "switch", "--flake", flake]
|
|
4
14
|
: ["nixos-rebuild", "switch", "--flake", flake];
|
|
15
|
+
if (osPlatform === "win32")
|
|
16
|
+
return command;
|
|
5
17
|
return withSudo(command, isRoot);
|
|
6
18
|
}
|
|
19
|
+
export function assertActivationSupported(platform, osPlatform = process.platform) {
|
|
20
|
+
if (platform === "windows") {
|
|
21
|
+
if (osPlatform === "win32")
|
|
22
|
+
return;
|
|
23
|
+
throw new Error("Windows activation is only supported on native Windows. " +
|
|
24
|
+
"`winget configure` only runs on Windows.");
|
|
25
|
+
}
|
|
26
|
+
if (osPlatform !== "win32")
|
|
27
|
+
return;
|
|
28
|
+
const target = platform === "darwin" ? "nix-darwin" : "NixOS";
|
|
29
|
+
const supportedEnvironment = platform === "darwin" ? "macOS" : "WSL or Linux";
|
|
30
|
+
throw new Error(`${target} activation is not supported from native Windows yet. ` +
|
|
31
|
+
"Use `winix apply` or `winix apply --dry` to generate output, then run " +
|
|
32
|
+
`\`winix switch\` from ${supportedEnvironment}.`);
|
|
33
|
+
}
|
|
7
34
|
export function platformForEvaluatedHost(host) {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
35
|
+
const hasNixos = Object.keys(host.nixos).length > 0;
|
|
36
|
+
const hasDarwin = Object.keys(host.darwin).length > 0;
|
|
37
|
+
const hasWindows = Object.keys(host.windows).length > 0;
|
|
38
|
+
if (hasDarwin && !hasNixos)
|
|
39
|
+
return "darwin";
|
|
40
|
+
if (hasWindows && !hasNixos && !hasDarwin)
|
|
41
|
+
return "windows";
|
|
42
|
+
return "nixos";
|
|
11
43
|
}
|
|
12
44
|
function withSudo(command, isRoot) {
|
|
13
45
|
if (isRoot)
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type ActivationPlatform } from "../activation.js";
|
|
1
2
|
interface ApplyOptions {
|
|
2
3
|
host?: string;
|
|
3
4
|
dry: boolean;
|
|
@@ -7,7 +8,7 @@ export interface ApplyResult {
|
|
|
7
8
|
configDir: string;
|
|
8
9
|
outDir: string;
|
|
9
10
|
hostNames: string[];
|
|
10
|
-
hostPlatforms: Map<string,
|
|
11
|
+
hostPlatforms: Map<string, ActivationPlatform>;
|
|
11
12
|
}
|
|
12
13
|
export declare function applyWorkspace(cwd: string, opts: ApplyOptions): Promise<ApplyResult>;
|
|
13
14
|
export declare function apply(cwd: string, opts: ApplyOptions): Promise<void>;
|
|
@@ -5,6 +5,7 @@ import { existsSync } from "node:fs";
|
|
|
5
5
|
import { loadWorkspace } from "../loader.js";
|
|
6
6
|
import { evaluate } from "../../evaluator/index.js";
|
|
7
7
|
import { generateNix } from "../../backends/nix/index.js";
|
|
8
|
+
import { generateWindows } from "../../backends/windows/index.js";
|
|
8
9
|
import { platformForEvaluatedHost } from "../activation.js";
|
|
9
10
|
export async function applyWorkspace(cwd, opts) {
|
|
10
11
|
const { workspace, configDir } = await loadWorkspace(cwd);
|
|
@@ -17,39 +18,55 @@ export async function applyWorkspace(cwd, opts) {
|
|
|
17
18
|
all.map((h) => ` - ${h.name}`).join("\n"));
|
|
18
19
|
}
|
|
19
20
|
}
|
|
20
|
-
const
|
|
21
|
-
|
|
21
|
+
const hostPlatforms = platformsForHosts(evaluated);
|
|
22
|
+
const nixHosts = evaluated.filter((host) => hostPlatforms.get(host.name) !== "windows");
|
|
23
|
+
const windowsHosts = evaluated.filter((host) => hostPlatforms.get(host.name) === "windows");
|
|
24
|
+
const nixOutput = nixHosts.length > 0 ? generateNix(workspace, nixHosts) : undefined;
|
|
25
|
+
const windowsOutput = windowsHosts.length > 0 ? generateWindows(windowsHosts) : undefined;
|
|
26
|
+
printWarnings(nixOutput?.warnings ?? []);
|
|
27
|
+
printWarnings(windowsOutput?.warnings ?? []);
|
|
22
28
|
const outDir = join(configDir, ".winix", "out");
|
|
23
29
|
if (opts.dry) {
|
|
24
|
-
|
|
25
|
-
console.log(output["flake.nix"]);
|
|
26
|
-
for (const [name, content] of Object.entries(output.hosts)) {
|
|
27
|
-
console.log(`\n=== .winix/out/hosts/${name} ===`);
|
|
28
|
-
console.log(content);
|
|
29
|
-
}
|
|
30
|
+
printDryOutput(nixOutput, windowsOutput);
|
|
30
31
|
return resultFor(configDir, outDir, evaluated);
|
|
31
32
|
}
|
|
32
33
|
if (opts.diff) {
|
|
33
|
-
await showDiff(configDir, outDir,
|
|
34
|
+
await showDiff(configDir, outDir, nixOutput, windowsOutput);
|
|
34
35
|
return resultFor(configDir, outDir, evaluated);
|
|
35
36
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
37
|
+
if (nixOutput) {
|
|
38
|
+
await mkdir(join(outDir, "hosts"), { recursive: true });
|
|
39
|
+
await writeFile(join(outDir, "flake.nix"), nixOutput["flake.nix"]);
|
|
40
|
+
for (const [name, content] of Object.entries(nixOutput.hosts)) {
|
|
41
|
+
await writeFile(join(outDir, "hosts", name), content);
|
|
42
|
+
}
|
|
43
|
+
await copyRawModules(configDir, outDir, nixOutput.rawModules);
|
|
44
|
+
// Copy flake.lock from project root if it exists.
|
|
45
|
+
const rootLock = join(cwd, "flake.lock");
|
|
46
|
+
const outLock = join(outDir, "flake.lock");
|
|
47
|
+
if (existsSync(rootLock)) {
|
|
48
|
+
await rm(outLock, { force: true });
|
|
49
|
+
await copyFile(rootLock, outLock);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (windowsOutput) {
|
|
53
|
+
for (const [hostName, bundle] of Object.entries(windowsOutput.hosts)) {
|
|
54
|
+
const hostDir = join(outDir, hostName);
|
|
55
|
+
await mkdir(hostDir, { recursive: true });
|
|
56
|
+
for (const [fileName, content] of Object.entries(bundle)) {
|
|
57
|
+
await writeFile(join(hostDir, fileName), content);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
console.log(`✓ Generated ${evaluated.length} host(s) in .winix/out/`);
|
|
62
|
+
for (const name of Object.keys(nixOutput?.hosts ?? {})) {
|
|
51
63
|
console.log(` → hosts/${name}`);
|
|
52
64
|
}
|
|
65
|
+
for (const [hostName, bundle] of Object.entries(windowsOutput?.hosts ?? {})) {
|
|
66
|
+
for (const fileName of Object.keys(bundle)) {
|
|
67
|
+
console.log(` → ${hostName}/${fileName}`);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
53
70
|
printNextSteps(cwd, outDir, evaluated);
|
|
54
71
|
return resultFor(configDir, outDir, evaluated);
|
|
55
72
|
}
|
|
@@ -61,12 +78,14 @@ function resultFor(configDir, outDir, evaluated) {
|
|
|
61
78
|
configDir,
|
|
62
79
|
outDir,
|
|
63
80
|
hostNames: evaluated.map((host) => host.name),
|
|
64
|
-
hostPlatforms:
|
|
81
|
+
hostPlatforms: platformsForHosts(evaluated),
|
|
65
82
|
};
|
|
66
83
|
}
|
|
67
84
|
function printNextSteps(_cwd, _outDir, evaluated) {
|
|
68
85
|
if (evaluated.length === 1) {
|
|
69
|
-
|
|
86
|
+
const [host] = evaluated;
|
|
87
|
+
const suffix = platformForEvaluatedHost(host) === "windows" ? ` --host ${host.name}` : "";
|
|
88
|
+
console.log(`\nNext: winix switch${suffix}`);
|
|
70
89
|
return;
|
|
71
90
|
}
|
|
72
91
|
console.log("\nNext:");
|
|
@@ -79,11 +98,35 @@ function printWarnings(warnings) {
|
|
|
79
98
|
console.warn(`Warning: ${warning}`);
|
|
80
99
|
}
|
|
81
100
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
101
|
+
function platformsForHosts(evaluated) {
|
|
102
|
+
return new Map(evaluated.map((host) => [host.name, platformForEvaluatedHost(host)]));
|
|
103
|
+
}
|
|
104
|
+
function printDryOutput(nixOutput, windowsOutput) {
|
|
105
|
+
if (nixOutput) {
|
|
106
|
+
console.log("=== .winix/out/flake.nix ===");
|
|
107
|
+
console.log(nixOutput["flake.nix"]);
|
|
108
|
+
for (const [name, content] of Object.entries(nixOutput.hosts)) {
|
|
109
|
+
console.log(`\n=== .winix/out/hosts/${name} ===`);
|
|
110
|
+
console.log(content);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
for (const [hostName, bundle] of Object.entries(windowsOutput?.hosts ?? {})) {
|
|
114
|
+
for (const [fileName, content] of Object.entries(bundle)) {
|
|
115
|
+
console.log(`\n=== .winix/out/${hostName}/${fileName} ===`);
|
|
116
|
+
console.log(content);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
async function showDiff(configDir, outDir, nixOutput, windowsOutput) {
|
|
121
|
+
const files = [];
|
|
122
|
+
if (nixOutput) {
|
|
123
|
+
files.push([join(outDir, "flake.nix"), nixOutput["flake.nix"]], ...Object.entries(nixOutput.hosts).map(([name, content]) => [join(outDir, "hosts", name), content]));
|
|
124
|
+
}
|
|
125
|
+
for (const [hostName, bundle] of Object.entries(windowsOutput?.hosts ?? {})) {
|
|
126
|
+
for (const [fileName, content] of Object.entries(bundle)) {
|
|
127
|
+
files.push([join(outDir, hostName, fileName), content]);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
87
130
|
let hasDiff = false;
|
|
88
131
|
for (const [path, newContent] of files) {
|
|
89
132
|
try {
|
|
@@ -100,7 +143,7 @@ async function showDiff(configDir, outDir, output) {
|
|
|
100
143
|
console.log(`\n+++ ${relative(process.cwd(), path)} (new file)`);
|
|
101
144
|
}
|
|
102
145
|
}
|
|
103
|
-
for (const rawModule of
|
|
146
|
+
for (const rawModule of nixOutput?.rawModules ?? []) {
|
|
104
147
|
const source = await resolveRawModuleSource(configDir, rawModule.path);
|
|
105
148
|
const target = rawModuleTarget(outDir, rawModule.path);
|
|
106
149
|
const sourceContent = await readFile(source);
|
|
@@ -4,4 +4,6 @@ interface SwitchOptions {
|
|
|
4
4
|
}
|
|
5
5
|
export declare function switchCommand(cwd: string, opts: SwitchOptions): Promise<void>;
|
|
6
6
|
export declare function selectHost(hosts: string[], requested?: string, currentHostname?: string): string;
|
|
7
|
+
export declare function flakeRefForHost(outDir: string, hostName: string): string;
|
|
8
|
+
export declare function windowsConfigurationForHost(outDir: string, hostName: string): string;
|
|
7
9
|
export {};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { hostname } from "node:os";
|
|
2
|
+
import { join } from "node:path";
|
|
2
3
|
import { evaluate } from "../../evaluator/index.js";
|
|
3
4
|
import { loadWorkspace } from "../loader.js";
|
|
4
5
|
import { runCommand } from "../run.js";
|
|
5
|
-
import { activationCommand, platformForEvaluatedHost } from "../activation.js";
|
|
6
|
+
import { activationCommand, assertActivationSupported, platformForEvaluatedHost, } from "../activation.js";
|
|
6
7
|
import { applyWorkspace } from "./apply.js";
|
|
7
8
|
export async function switchCommand(cwd, opts) {
|
|
8
9
|
const { workspace } = await loadWorkspace(cwd);
|
|
@@ -12,13 +13,18 @@ export async function switchCommand(cwd, opts) {
|
|
|
12
13
|
if (!selected)
|
|
13
14
|
throw new Error(`Host "${hostName}" not found`);
|
|
14
15
|
const platform = platformForEvaluatedHost(selected);
|
|
16
|
+
if (!opts.dry) {
|
|
17
|
+
assertActivationSupported(platform);
|
|
18
|
+
}
|
|
15
19
|
const result = await applyWorkspace(cwd, {
|
|
16
20
|
host: hostName,
|
|
17
21
|
dry: false,
|
|
18
22
|
diff: false,
|
|
19
23
|
});
|
|
20
|
-
const
|
|
21
|
-
|
|
24
|
+
const activationTarget = platform === "windows"
|
|
25
|
+
? windowsConfigurationForHost(result.outDir, hostName)
|
|
26
|
+
: flakeRefForHost(result.outDir, hostName);
|
|
27
|
+
const command = activationCommand(platform, activationTarget);
|
|
22
28
|
console.log(`\nRunning: ${command.join(" ")}`);
|
|
23
29
|
await runCommand(command[0], command.slice(1), { dry: opts.dry });
|
|
24
30
|
}
|
|
@@ -38,3 +44,9 @@ export function selectHost(hosts, requested, currentHostname = hostname()) {
|
|
|
38
44
|
"`winix switch` needs --host. Available hosts:\n" +
|
|
39
45
|
hosts.map((host) => ` - ${host}`).join("\n"));
|
|
40
46
|
}
|
|
47
|
+
export function flakeRefForHost(outDir, hostName) {
|
|
48
|
+
return `path:${outDir.replace(/\\/g, "/")}#${hostName}`;
|
|
49
|
+
}
|
|
50
|
+
export function windowsConfigurationForHost(outDir, hostName) {
|
|
51
|
+
return join(outDir, hostName, "configuration.winget");
|
|
52
|
+
}
|
|
@@ -4,7 +4,20 @@ import { cp, mkdtemp, readFile, rename, rm, writeFile } from "node:fs/promises";
|
|
|
4
4
|
import { runCommand } from "../run.js";
|
|
5
5
|
import { applyWorkspace } from "./apply.js";
|
|
6
6
|
export async function update(cwd, opts) {
|
|
7
|
+
if (!opts.dry) {
|
|
8
|
+
assertUpdateSupported();
|
|
9
|
+
}
|
|
7
10
|
const result = await applyWorkspace(cwd, { dry: false, diff: false });
|
|
11
|
+
// `winix update` resolves the Nix flake lock. A Windows-only workspace has
|
|
12
|
+
// no flake.nix, so there is nothing to update; fail clearly instead of
|
|
13
|
+
// letting `nix flake update` error out generically.
|
|
14
|
+
const hasNixHost = [...result.hostPlatforms.values()].some((platform) => platform !== "windows");
|
|
15
|
+
if (!hasNixHost) {
|
|
16
|
+
throw new Error("`winix update` updates the Nix flake lock, but this workspace has no " +
|
|
17
|
+
"NixOS or nix-darwin hosts (Windows packages are pinned via " +
|
|
18
|
+
"`winix-windows.lock`, resolved by a future `winix` milestone). " +
|
|
19
|
+
"Nothing to update.");
|
|
20
|
+
}
|
|
8
21
|
const updateDir = await mkdtemp(join(tmpdir(), "winix-update-"));
|
|
9
22
|
await cp(result.outDir, updateDir, { recursive: true });
|
|
10
23
|
const args = [
|
|
@@ -31,3 +44,9 @@ export async function update(cwd, opts) {
|
|
|
31
44
|
await rm(updateDir, { recursive: true, force: true });
|
|
32
45
|
}
|
|
33
46
|
}
|
|
47
|
+
export function assertUpdateSupported(osPlatform = process.platform) {
|
|
48
|
+
if (osPlatform !== "win32")
|
|
49
|
+
return;
|
|
50
|
+
throw new Error("`winix update` is not supported from native Windows yet because it requires " +
|
|
51
|
+
"the Nix CLI. Run it from WSL, Linux, or macOS.");
|
|
52
|
+
}
|
package/dist/cli/index.js
CHANGED
|
@@ -26,9 +26,9 @@ winix - TypeScript-first system configuration
|
|
|
26
26
|
|
|
27
27
|
Commands:
|
|
28
28
|
init Scaffold a Winix project
|
|
29
|
-
apply Generate
|
|
29
|
+
apply Generate backend output in .winix/out/
|
|
30
30
|
check Validate configuration
|
|
31
|
-
switch Generate output and run
|
|
31
|
+
switch Generate output and run the host activation command
|
|
32
32
|
update Update generated flake.lock and copy it to project root
|
|
33
33
|
inspect Print host composition and fragment graph
|
|
34
34
|
|
package/dist/core/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DarwinOptions, HomeOptions, NixosOptions } from "../types/index.js";
|
|
1
|
+
import type { DarwinOptions, HomeOptions, NixosOptions, WindowsOptions } from "../types/index.js";
|
|
2
2
|
/**
|
|
3
3
|
* The output shape of any fragment. Keys correspond to target scopes.
|
|
4
4
|
* Values are deep-merged by the evaluator according to merge rules.
|
|
@@ -7,6 +7,7 @@ export interface Fragment {
|
|
|
7
7
|
nixos?: NixosOptions;
|
|
8
8
|
homeManager?: HomeOptions;
|
|
9
9
|
darwin?: DarwinOptions;
|
|
10
|
+
windows?: WindowsOptions;
|
|
10
11
|
/** Internal: platform/feature ID for .isActive resolution */
|
|
11
12
|
__id?: string;
|
|
12
13
|
/** Internal: marks this as a platform fragment */
|
package/dist/evaluator/index.js
CHANGED
|
@@ -34,6 +34,7 @@ function evaluateHost(host) {
|
|
|
34
34
|
nixos: {},
|
|
35
35
|
homeManager: {},
|
|
36
36
|
darwin: {},
|
|
37
|
+
windows: {},
|
|
37
38
|
};
|
|
38
39
|
for (const fragment of resolvedFragments) {
|
|
39
40
|
if (fragment.nixos && shouldMergeScope(resolvedFragments, "nixos")) {
|
|
@@ -45,6 +46,9 @@ function evaluateHost(host) {
|
|
|
45
46
|
if (fragment.darwin && shouldMergeScope(resolvedFragments, "darwin")) {
|
|
46
47
|
result.darwin = deepMerge(result.darwin, fragment.darwin);
|
|
47
48
|
}
|
|
49
|
+
if (fragment.windows && shouldMergeScope(resolvedFragments, "windows")) {
|
|
50
|
+
result.windows = deepMerge(result.windows, fragment.windows);
|
|
51
|
+
}
|
|
48
52
|
}
|
|
49
53
|
return result;
|
|
50
54
|
}
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export { account } from "./account.js";
|
|
2
2
|
export type { AccountGroupFactory, AccountGroupMember, AccountGroupOpts, AccountNamespace, AccountOpts, AccountUserFactory, AccountUserRef, } from "./account.js";
|
|
3
3
|
export { platforms } from "./platforms.js";
|
|
4
|
-
export type { DarwinPlatformOpts, NixosPlatformOpts, PlatformsHelper } from "./platforms.js";
|
|
4
|
+
export type { DarwinPlatformOpts, NixosPlatformOpts, WindowsPlatformOpts, PlatformsHelper } from "./platforms.js";
|
|
5
5
|
export { nix } from "./nix.js";
|
|
6
6
|
export type { BinaryReleaseArch, BinaryReleaseCompletions, BinaryReleaseMeta, BinaryReleaseOpts, BinaryReleasePlatform, NixNamespace, PkgHelper, ScriptHelper, } from "./nix.js";
|
|
7
7
|
export { overlay } from "./overlay.js";
|
|
@@ -12,3 +12,5 @@ export { nixos } from "./nixos.js";
|
|
|
12
12
|
export type { NixosHelper, NixosProgramOptions, NixosServiceOptions, SysctlSettings, SystemdHelper, VirtualisationHelper } from "./nixos.js";
|
|
13
13
|
export { darwin } from "./darwin.js";
|
|
14
14
|
export type { DarwinHelper, DarwinProgramOptions, DarwinServiceOptions, LaunchdHelper } from "./darwin.js";
|
|
15
|
+
export { windows } from "./windows.js";
|
|
16
|
+
export type { WindowsHelper, WinPackageArg, WinPackageSpec } from "./windows.js";
|
package/dist/helpers/index.js
CHANGED
|
@@ -14,8 +14,13 @@ export interface DarwinPlatformOpts {
|
|
|
14
14
|
homebrew?: boolean;
|
|
15
15
|
hostname?: string | false;
|
|
16
16
|
}
|
|
17
|
+
export interface WindowsPlatformOpts {
|
|
18
|
+
/** Hostname override; falls back to the host name from eval context. */
|
|
19
|
+
hostname?: string | false;
|
|
20
|
+
}
|
|
17
21
|
export interface PlatformsHelper {
|
|
18
22
|
nixos: PlatformFactory<[opts?: NixosPlatformOpts]>;
|
|
19
23
|
darwin: PlatformFactory<[opts?: DarwinPlatformOpts]>;
|
|
24
|
+
windows: PlatformFactory<[opts?: WindowsPlatformOpts]>;
|
|
20
25
|
}
|
|
21
26
|
export declare const platforms: PlatformsHelper;
|
|
@@ -6,7 +6,7 @@ export const platforms = {
|
|
|
6
6
|
const useHomeManager = opts.homeManager ?? true;
|
|
7
7
|
return {
|
|
8
8
|
nixos: {
|
|
9
|
-
...(useHomeManager && { imports: ["home-manager"] }),
|
|
9
|
+
...(useHomeManager && { imports: ["inputs.home-manager.nixosModules.home-manager"] }),
|
|
10
10
|
nixpkgs: {
|
|
11
11
|
hostPlatform: opts.system ?? "x86_64-linux",
|
|
12
12
|
config: { allowUnfree: opts.allowUnfree ?? true },
|
|
@@ -59,4 +59,17 @@ export const platforms = {
|
|
|
59
59
|
},
|
|
60
60
|
};
|
|
61
61
|
}),
|
|
62
|
+
windows: platform("windows", (opts = {}) => {
|
|
63
|
+
const ctx = getOptionalEvalContext();
|
|
64
|
+
const hostname = opts.hostname === false ? undefined : opts.hostname ?? ctx?.hostname;
|
|
65
|
+
return {
|
|
66
|
+
windows: {
|
|
67
|
+
// Empty packages map establishes the `windows` scope so the host is
|
|
68
|
+
// recognized as a Windows target by the evaluator and emitter, even
|
|
69
|
+
// before any windows.package(...) fragment contributes.
|
|
70
|
+
packages: {},
|
|
71
|
+
...(hostname && { hostname }),
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}),
|
|
62
75
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Fragment } from "../core/types.js";
|
|
2
|
+
import type { WinPackageSource } from "../types/index.js";
|
|
3
|
+
/**
|
|
4
|
+
* Accepted call shapes for `windows.package(...)`.
|
|
5
|
+
*
|
|
6
|
+
* - `"Git.Git"` → sugar for `{ source: "winget", id: "Git.Git" }`
|
|
7
|
+
* - `{ id, source?, version? }` → explicit form
|
|
8
|
+
*/
|
|
9
|
+
export interface WinPackageSpec {
|
|
10
|
+
id: string;
|
|
11
|
+
source?: WinPackageSource;
|
|
12
|
+
version?: string;
|
|
13
|
+
elevated?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export type WinPackageArg = string | WinPackageSpec;
|
|
16
|
+
export interface WindowsHelper {
|
|
17
|
+
/**
|
|
18
|
+
* Declare a winget/msstore package.
|
|
19
|
+
*
|
|
20
|
+
* ```ts
|
|
21
|
+
* windows.package("Git.Git")
|
|
22
|
+
* windows.package({ source: "msstore", id: "9NKSQGP7F2NH" })
|
|
23
|
+
* windows.package({ id: "Git.Git", version: "2.44.0" })
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
package(arg: WinPackageArg): Fragment;
|
|
27
|
+
}
|
|
28
|
+
export declare const windows: WindowsHelper;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Windows helper namespace: `windows.*` authoring surface.
|
|
2
|
+
//
|
|
3
|
+
// MVP vertical slice: only `windows.package(...)`. Mirrors the shape and
|
|
4
|
+
// naming of the `nixos.*` / `darwin.*` namespaces. Additional helpers
|
|
5
|
+
// (env, path, file, raw, dsc, wsl, programs) land in follow-up milestones.
|
|
6
|
+
function normalizePackage(arg) {
|
|
7
|
+
if (typeof arg === "string") {
|
|
8
|
+
if (arg.length === 0) {
|
|
9
|
+
throw new Error("windows.package(id) requires a non-empty package id");
|
|
10
|
+
}
|
|
11
|
+
return { id: arg, source: "winget" };
|
|
12
|
+
}
|
|
13
|
+
if (!arg || typeof arg !== "object") {
|
|
14
|
+
throw new Error("windows.package(...) requires an id string or a spec object");
|
|
15
|
+
}
|
|
16
|
+
if (!arg.id || typeof arg.id !== "string") {
|
|
17
|
+
throw new Error("windows.package({ id }) requires a non-empty id");
|
|
18
|
+
}
|
|
19
|
+
const pkg = {
|
|
20
|
+
id: arg.id,
|
|
21
|
+
source: arg.source ?? "winget",
|
|
22
|
+
};
|
|
23
|
+
if (arg.version !== undefined) {
|
|
24
|
+
if (typeof arg.version !== "string" || arg.version.length === 0) {
|
|
25
|
+
throw new Error(`windows.package("${arg.id}") version must be a non-empty string`);
|
|
26
|
+
}
|
|
27
|
+
pkg.version = arg.version;
|
|
28
|
+
}
|
|
29
|
+
if (arg.elevated !== undefined) {
|
|
30
|
+
pkg.elevated = arg.elevated;
|
|
31
|
+
}
|
|
32
|
+
return pkg;
|
|
33
|
+
}
|
|
34
|
+
export const windows = {
|
|
35
|
+
package: (arg) => {
|
|
36
|
+
const pkg = normalizePackage(arg);
|
|
37
|
+
return { windows: { packages: { [pkg.id]: pkg } } };
|
|
38
|
+
},
|
|
39
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
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, } 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, } from "./types/index.js";
|
|
3
3
|
export { platform, feature, profile, host, workspace, input, defineInputs, rawModule, withContext } from "./sdk/index.js";
|
|
4
4
|
export { evaluate } from "./evaluator/index.js";
|
|
5
5
|
export type { EvaluatedHost } from "./evaluator/index.js";
|
|
6
6
|
export { generateNix } from "./backends/nix/index.js";
|
|
7
7
|
export type { NixOutput } from "./backends/nix/index.js";
|
|
8
|
-
export {
|
|
9
|
-
export type {
|
|
8
|
+
export { generateWindows, isWindowsHost } from "./backends/windows/index.js";
|
|
9
|
+
export type { WindowsOutput, WindowsHostOutput } from "./backends/windows/index.js";
|
|
10
|
+
export { account, darwin, home, nix, nixos, overlay, platforms, windows } from "./helpers/index.js";
|
|
11
|
+
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 } from "./helpers/index.js";
|
package/dist/index.js
CHANGED
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
export { platform, feature, profile, host, workspace, input, defineInputs, rawModule, withContext } from "./sdk/index.js";
|
|
3
3
|
export { evaluate } from "./evaluator/index.js";
|
|
4
4
|
export { generateNix } from "./backends/nix/index.js";
|
|
5
|
-
export {
|
|
5
|
+
export { generateWindows, isWindowsHost } from "./backends/windows/index.js";
|
|
6
|
+
export { account, darwin, home, nix, nixos, overlay, platforms, windows } from "./helpers/index.js";
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A winget package source. MVP supports the two first-party catalogues.
|
|
3
|
+
* Additional sources (chocolatey, scoop) can plug in later without changing
|
|
4
|
+
* this union's consumers.
|
|
5
|
+
*/
|
|
6
|
+
export type WinPackageSource = "winget" | "msstore";
|
|
7
|
+
/**
|
|
8
|
+
* A single declared Windows package, normalized from any of the
|
|
9
|
+
* `windows.package(...)` call shapes into a stable internal record.
|
|
10
|
+
*/
|
|
11
|
+
export interface WinPackage {
|
|
12
|
+
/** Winget/msstore package identifier, e.g. "Git.Git". */
|
|
13
|
+
id: string;
|
|
14
|
+
/** Catalogue the id resolves against. Defaults to "winget". */
|
|
15
|
+
source: WinPackageSource;
|
|
16
|
+
/**
|
|
17
|
+
* Absolute version pin. When present, this exact version is emitted to
|
|
18
|
+
* `configuration.winget` regardless of what is available upstream. When
|
|
19
|
+
* absent, the version floats (resolved at `winix update` time via the
|
|
20
|
+
* lockfile in a later milestone).
|
|
21
|
+
*/
|
|
22
|
+
version?: string;
|
|
23
|
+
/**
|
|
24
|
+
* When true, the package is installed in an elevated (admin) security
|
|
25
|
+
* context via `metadata.winget.securityContext: elevated`. Required for
|
|
26
|
+
* machine-wide installers (drivers, system services). Defaults to false so
|
|
27
|
+
* per-user packages install without prompting for / requiring elevation,
|
|
28
|
+
* which also avoids the DSC cross-process elevation failure when
|
|
29
|
+
* `winget configure` is run from a non-elevated shell.
|
|
30
|
+
*/
|
|
31
|
+
elevated?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* The `windows` scope of a Fragment. Deep-merged across all fragments for a
|
|
35
|
+
* host, then handed to the Windows emitter.
|
|
36
|
+
*
|
|
37
|
+
* `packages` is keyed by package id so that merging is idempotent and a later
|
|
38
|
+
* fragment pinning a version overrides an earlier float for the same id.
|
|
39
|
+
*/
|
|
40
|
+
export interface WindowsOptions extends Record<string, unknown> {
|
|
41
|
+
/** Declared packages, keyed by package id. */
|
|
42
|
+
packages?: Record<string, WinPackage>;
|
|
43
|
+
/** Hostname for the target, set by the platform baseline. */
|
|
44
|
+
hostname?: string;
|
|
45
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// Windows backend types: the IR carried by fragments under the `windows` key.
|
|
2
|
+
//
|
|
3
|
+
// These are intentionally minimal for the MVP vertical slice (packages only).
|
|
4
|
+
// They will grow to cover env/path/file/raw/dsc/wsl/programs as the backend
|
|
5
|
+
// matures. The shape here is the *internal* representation produced by the
|
|
6
|
+
// `windows.*` helpers and consumed by the Windows emitter, not the public
|
|
7
|
+
// authoring surface.
|
|
8
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@adrifer/winix",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.3-preview.1",
|
|
4
4
|
"description": "TypeScript-first system configuration for NixOS, nix-darwin, and Home Manager",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Adrian Fernandez",
|
|
@@ -50,7 +50,8 @@
|
|
|
50
50
|
"README.md"
|
|
51
51
|
],
|
|
52
52
|
"scripts": {
|
|
53
|
-
"
|
|
53
|
+
"clean": "node scripts/clean-dist.mjs",
|
|
54
|
+
"build": "npm run clean && tsc -p tsconfig.build.json && node scripts/fix-dts-imports.mjs",
|
|
54
55
|
"dev": "tsc --watch",
|
|
55
56
|
"test": "vitest",
|
|
56
57
|
"lint": "eslint src/",
|