@adrifer/winix 0.1.2-preview.4 → 0.1.3-preview.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +14 -2
- package/dist/backends/nix/index.js +10 -7
- package/dist/helpers/platforms.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# Winix
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/@adrifer/winix)
|
|
4
|
+
[](https://www.npmjs.com/package/@adrifer/winix?activeTab=versions)
|
|
5
|
+
[](https://github.com/adrifer/winix/actions/workflows/ci.yml)
|
|
6
|
+
[](./LICENSE)
|
|
7
|
+
[](./types)
|
|
8
|
+
|
|
3
9
|
**TypeScript-first system configuration for NixOS, nix-darwin, and Home Manager.**
|
|
4
10
|
|
|
5
11
|
Winix lets you write system configuration as typed, composable TypeScript fragments and generates a normal Nix flake that `nixos-rebuild`, `darwin-rebuild`, and Home Manager can consume.
|
|
@@ -29,7 +35,7 @@ const inputs = defineInputs({
|
|
|
29
35
|
});
|
|
30
36
|
|
|
31
37
|
const wsl = feature("wsl", () => [
|
|
32
|
-
nixos.imports("nixos-wsl"),
|
|
38
|
+
nixos.imports("inputs.nixos-wsl.nixosModules.wsl"),
|
|
33
39
|
nixos({ wsl: { enable: true } }),
|
|
34
40
|
nixos.program("nix-ld"),
|
|
35
41
|
]);
|
|
@@ -76,6 +82,12 @@ export default workspace({
|
|
|
76
82
|
|
|
77
83
|
> Winix is early software. The core pipeline works end-to-end, but the public API is still evolving.
|
|
78
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
|
+
|
|
79
91
|
## Install and create a config
|
|
80
92
|
|
|
81
93
|
```bash
|
|
@@ -233,7 +245,7 @@ host("wsl", platforms.nixos({ stateVersion: "25.05" }), [
|
|
|
233
245
|
Winix includes helpers for common Nix namespaces:
|
|
234
246
|
|
|
235
247
|
```ts
|
|
236
|
-
nixos.imports("nixos-wsl")
|
|
248
|
+
nixos.imports("inputs.nixos-wsl.nixosModules.wsl")
|
|
237
249
|
nixos.networking({ hostName: "server", firewall: { allowedTCPPorts: [22, 443] } })
|
|
238
250
|
nixos.service("openssh", { settings: { PermitRootLogin: "no" } })
|
|
239
251
|
nixos.systemd.service("backup", { script: "echo backup" })
|
|
@@ -64,12 +64,6 @@ function formatInput(name, def) {
|
|
|
64
64
|
}
|
|
65
65
|
return lines.join("\n");
|
|
66
66
|
}
|
|
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
67
|
function generateHostModule(host) {
|
|
74
68
|
const lines = [
|
|
75
69
|
`# Generated by Winix — do not edit`,
|
|
@@ -216,7 +210,7 @@ function formatImport(imp) {
|
|
|
216
210
|
return `../raw-modules/${imp.path}`;
|
|
217
211
|
}
|
|
218
212
|
if (typeof imp === "string") {
|
|
219
|
-
return
|
|
213
|
+
return imp;
|
|
220
214
|
}
|
|
221
215
|
throw new Error("imports entries must be strings or rawModule() references");
|
|
222
216
|
}
|
|
@@ -393,8 +387,17 @@ function validateWorkspaceInputs(workspace, hosts) {
|
|
|
393
387
|
if (hosts.some((host) => Object.keys(host.darwin).length > 0) && !hasInput(workspace, "nix-darwin")) {
|
|
394
388
|
warnings.push("darwin host detected but workspace inputs do not include nix-darwin");
|
|
395
389
|
}
|
|
390
|
+
if (hosts.some(hasHomeManagerImport) && !hasInput(workspace, "home-manager")) {
|
|
391
|
+
warnings.push("home-manager module import detected but workspace inputs do not include home-manager");
|
|
392
|
+
}
|
|
396
393
|
return warnings;
|
|
397
394
|
}
|
|
395
|
+
function hasHomeManagerImport(host) {
|
|
396
|
+
return [
|
|
397
|
+
...getImports(host.nixos),
|
|
398
|
+
...getImports(host.darwin),
|
|
399
|
+
].some((imp) => typeof imp === "string" && imp.startsWith("inputs.home-manager."));
|
|
400
|
+
}
|
|
398
401
|
function hasInput(workspace, nixName) {
|
|
399
402
|
return Object.entries(workspace.inputs).some(([name, def]) => inputNixName(name, def) === nixName);
|
|
400
403
|
}
|
|
@@ -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 },
|
package/package.json
CHANGED