@adrifer/winix 0.2.1 → 0.2.2
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 +47 -0
- package/dist/helpers/index.d.ts +1 -1
- package/dist/helpers/nix.d.ts +8 -3
- package/dist/helpers/nix.js +35 -6
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -333,6 +333,53 @@ licenses that aren't a simple `pkgs.lib.licenses.<id>` lookup. See
|
|
|
333
333
|
[`spec/proposals/binary-release.md`](spec/proposals/binary-release.md)
|
|
334
334
|
for the full reference.
|
|
335
335
|
|
|
336
|
+
Release assets can also be raw executables. Set `format: "raw"` explicitly;
|
|
337
|
+
Winix never guesses that an extensionless file is executable. The format is
|
|
338
|
+
per-platform, so raw and archive assets can be mixed in one release:
|
|
339
|
+
|
|
340
|
+
```ts
|
|
341
|
+
home.packages(
|
|
342
|
+
nix.binaryRelease({
|
|
343
|
+
name: "herdr",
|
|
344
|
+
version: "0.8.2",
|
|
345
|
+
binary: "herdr",
|
|
346
|
+
urlTemplate:
|
|
347
|
+
"https://github.com/herdrdev/herdr/releases/download/v{version}/{file}",
|
|
348
|
+
platforms: {
|
|
349
|
+
"x86_64-linux": {
|
|
350
|
+
file: "herdr-linux-x86_64",
|
|
351
|
+
hash: "sha256-...",
|
|
352
|
+
format: "raw",
|
|
353
|
+
},
|
|
354
|
+
"aarch64-linux": {
|
|
355
|
+
file: "herdr-linux-aarch64",
|
|
356
|
+
hash: "sha256-...",
|
|
357
|
+
format: "raw",
|
|
358
|
+
},
|
|
359
|
+
"x86_64-darwin": {
|
|
360
|
+
file: "herdr-macos-x86_64",
|
|
361
|
+
hash: "sha256-...",
|
|
362
|
+
format: "raw",
|
|
363
|
+
},
|
|
364
|
+
"aarch64-darwin": {
|
|
365
|
+
file: "herdr-macos-aarch64",
|
|
366
|
+
hash: "sha256-...",
|
|
367
|
+
format: "raw",
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
meta: {
|
|
371
|
+
description: "The runtime your coding agents live on",
|
|
372
|
+
homepage: "https://github.com/herdrdev/herdr",
|
|
373
|
+
license: "asl20",
|
|
374
|
+
},
|
|
375
|
+
}),
|
|
376
|
+
);
|
|
377
|
+
```
|
|
378
|
+
|
|
379
|
+
When `format` is omitted, `.zip`, `.tar.gz`, and `.tgz` filenames retain the
|
|
380
|
+
legacy extension-based archive behavior. Other extensions are rejected unless
|
|
381
|
+
a supported format (`"raw"`, `"zip"`, `"tar.gz"`, or `"tgz"`) is explicit.
|
|
382
|
+
|
|
336
383
|
For bigger migrations, import existing Nix modules:
|
|
337
384
|
|
|
338
385
|
```ts
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export type { AccountGroupFactory, AccountGroupMember, AccountGroupOpts, Account
|
|
|
3
3
|
export { platforms } from "./platforms.js";
|
|
4
4
|
export type { DarwinPlatformOpts, NixosPlatformOpts, WindowsPlatformOpts, PlatformsHelper } from "./platforms.js";
|
|
5
5
|
export { nix } from "./nix.js";
|
|
6
|
-
export type { BinaryReleaseArch, BinaryReleaseCompletions, BinaryReleaseMeta, BinaryReleaseOpts, BinaryReleasePlatform, NixNamespace, PkgHelper, ScriptHelper, } from "./nix.js";
|
|
6
|
+
export type { BinaryReleaseArch, BinaryReleaseCompletions, BinaryReleaseFormat, BinaryReleaseMeta, BinaryReleaseOpts, BinaryReleasePlatform, NixNamespace, PkgHelper, ScriptHelper, } from "./nix.js";
|
|
7
7
|
export { overlay } from "./overlay.js";
|
|
8
8
|
export type { OverlayHelper } from "./overlay.js";
|
|
9
9
|
export { home } from "./home.js";
|
package/dist/helpers/nix.d.ts
CHANGED
|
@@ -30,8 +30,9 @@ export interface NixNamespace {
|
|
|
30
30
|
*
|
|
31
31
|
* Picks the right `(file, hash)` per `pkgs.stdenv.hostPlatform.system`,
|
|
32
32
|
* substitutes `{version}`, `{file}`, and (optionally) `{platform}` into
|
|
33
|
-
* `urlTemplate`, fetches with `pkgs.fetchurl`, unpacks tarballs/zips
|
|
34
|
-
* and `install -Dm755`s the binary
|
|
33
|
+
* `urlTemplate`, fetches with `pkgs.fetchurl`, unpacks tarballs/zips (or
|
|
34
|
+
* directly installs raw executables), and `install -Dm755`s the binary
|
|
35
|
+
* into `$out/bin/<binary>`.
|
|
35
36
|
*
|
|
36
37
|
* Optional extensions:
|
|
37
38
|
* - `completions` — emits `installShellCompletion` for `bash`/`fish`/`zsh`.
|
|
@@ -79,11 +80,15 @@ export interface NixNamespace {
|
|
|
79
80
|
}
|
|
80
81
|
/** Supported `(os, arch)` strings for `nix.binaryRelease`. */
|
|
81
82
|
export type BinaryReleaseArch = "x86_64-linux" | "aarch64-linux" | "x86_64-darwin" | "aarch64-darwin";
|
|
83
|
+
export type BinaryReleaseFormat = "raw" | "zip" | "tar.gz" | "tgz";
|
|
82
84
|
export interface BinaryReleasePlatform {
|
|
83
85
|
/** Filename to download (substituted into `urlTemplate`'s `{file}`). */
|
|
84
86
|
file: string;
|
|
85
|
-
/** SRI hash (`sha256-...`) of the downloaded
|
|
87
|
+
/** SRI hash (`sha256-...`) of the downloaded file. */
|
|
86
88
|
hash: string;
|
|
89
|
+
/** Download format. When omitted, archive format is inferred from `file`.
|
|
90
|
+
* Raw executables must explicitly set `"raw"`. */
|
|
91
|
+
format?: BinaryReleaseFormat;
|
|
87
92
|
/** Optional: name of the extracted binary, if it differs from the outer `binary`. */
|
|
88
93
|
binary?: string;
|
|
89
94
|
/** Optional: vendor-specific platform tag substituted into `urlTemplate`'s `{platform}`
|
package/dist/helpers/nix.js
CHANGED
|
@@ -73,6 +73,12 @@ const KNOWN_BINARY_RELEASE_ARCHES = [
|
|
|
73
73
|
"x86_64-darwin",
|
|
74
74
|
"aarch64-darwin",
|
|
75
75
|
];
|
|
76
|
+
const KNOWN_BINARY_RELEASE_FORMATS = [
|
|
77
|
+
"raw",
|
|
78
|
+
"zip",
|
|
79
|
+
"tar.gz",
|
|
80
|
+
"tgz",
|
|
81
|
+
];
|
|
76
82
|
function binaryRelease(opts) {
|
|
77
83
|
if (!opts || typeof opts !== "object") {
|
|
78
84
|
throw new Error("nix.binaryRelease: `opts` is required");
|
|
@@ -118,6 +124,7 @@ function binaryRelease(opts) {
|
|
|
118
124
|
if (!platform.hash) {
|
|
119
125
|
throw new Error(`nix.binaryRelease: platforms.${arch}.hash is required`);
|
|
120
126
|
}
|
|
127
|
+
resolveBinaryReleaseFormat(arch, platform);
|
|
121
128
|
}
|
|
122
129
|
const usesPlatformPlaceholder = opts.urlTemplate.includes("{platform}");
|
|
123
130
|
if (usesPlatformPlaceholder) {
|
|
@@ -133,6 +140,7 @@ function binaryRelease(opts) {
|
|
|
133
140
|
`file = ${nixStringLiteral(platform.file)};`,
|
|
134
141
|
`hash = ${nixStringLiteral(platform.hash)};`,
|
|
135
142
|
`binary = ${nixStringLiteral(platform.binary ?? opts.binary)};`,
|
|
143
|
+
`format = ${nixStringLiteral(resolveBinaryReleaseFormat(arch, platform))};`,
|
|
136
144
|
];
|
|
137
145
|
if (usesPlatformPlaceholder) {
|
|
138
146
|
const platformName = platform.platform;
|
|
@@ -208,14 +216,16 @@ in pkgs.stdenvNoCC.mkDerivation {
|
|
|
208
216
|
|
|
209
217
|
nativeBuildInputs = ${nativeBuildInputsExpr};${linuxBuildInputs}${dontStripLine}
|
|
210
218
|
|
|
219
|
+
dontUnpack = source.format == "raw";
|
|
220
|
+
|
|
211
221
|
unpackPhase = ''
|
|
212
222
|
runHook preUnpack
|
|
213
223
|
mkdir source
|
|
214
|
-
case "
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
*) echo "nix.binaryRelease: unsupported archive
|
|
224
|
+
case "\${source.format}" in
|
|
225
|
+
zip) unzip -q "$src" -d source ;;
|
|
226
|
+
tar.gz) tar -xzf "$src" -C source ;;
|
|
227
|
+
tgz) tar -xzf "$src" -C source ;;
|
|
228
|
+
*) echo "nix.binaryRelease: unsupported archive format \${source.format}" >&2; exit 1 ;;
|
|
219
229
|
esac
|
|
220
230
|
sourceRoot=source
|
|
221
231
|
runHook postUnpack
|
|
@@ -223,7 +233,11 @@ in pkgs.stdenvNoCC.mkDerivation {
|
|
|
223
233
|
|
|
224
234
|
installPhase = ''
|
|
225
235
|
runHook preInstall
|
|
226
|
-
|
|
236
|
+
installSource="$src"
|
|
237
|
+
if [ "\${source.format}" != raw ]; then
|
|
238
|
+
installSource="\${source.binary}"
|
|
239
|
+
fi
|
|
240
|
+
install -Dm755 "$installSource" "$out/bin/${opts.binary}"${extraInstallBlock}
|
|
227
241
|
runHook postInstall
|
|
228
242
|
'';${completionsBlock}
|
|
229
243
|
|
|
@@ -233,6 +247,21 @@ ${metaLines.join("\n")}
|
|
|
233
247
|
})`;
|
|
234
248
|
return expr(text);
|
|
235
249
|
}
|
|
250
|
+
function resolveBinaryReleaseFormat(arch, platform) {
|
|
251
|
+
if (platform.format !== undefined) {
|
|
252
|
+
if (!KNOWN_BINARY_RELEASE_FORMATS.includes(platform.format)) {
|
|
253
|
+
throw new Error(`nix.binaryRelease: platforms.${arch}.format must be one of "raw", "zip", "tar.gz", or "tgz"`);
|
|
254
|
+
}
|
|
255
|
+
return platform.format;
|
|
256
|
+
}
|
|
257
|
+
if (platform.file.endsWith(".tar.gz"))
|
|
258
|
+
return "tar.gz";
|
|
259
|
+
if (platform.file.endsWith(".tgz"))
|
|
260
|
+
return "tgz";
|
|
261
|
+
if (platform.file.endsWith(".zip"))
|
|
262
|
+
return "zip";
|
|
263
|
+
throw new Error(`nix.binaryRelease: platforms.${arch}.file has an unsupported archive extension; set \`format\` explicitly`);
|
|
264
|
+
}
|
|
236
265
|
function renderBuildInput(value) {
|
|
237
266
|
if (isNixExpr(value))
|
|
238
267
|
return value.expr;
|
package/dist/index.d.ts
CHANGED
|
@@ -9,4 +9,4 @@ export type { NixOutput } from "./backends/nix/index.js";
|
|
|
9
9
|
export { generateWindows, isWindowsHost } from "./backends/windows/index.js";
|
|
10
10
|
export type { WindowsOutput, WindowsHostOutput } from "./backends/windows/index.js";
|
|
11
11
|
export { account, darwin, home, nix, nixos, overlay, platforms, windows } from "./helpers/index.js";
|
|
12
|
-
export type { AccountGroupFactory, AccountGroupMember, AccountGroupOpts, AccountNamespace, AccountOpts, AccountUserFactory, AccountUserRef, ActivationOpts, BinaryReleaseArch, BinaryReleaseCompletions, BinaryReleaseMeta, BinaryReleaseOpts, BinaryReleasePlatform, DarwinHelper, DarwinPlatformOpts, DarwinProgramOptions, DarwinServiceOptions, HomeHelper, HomeProgramOptions, HomeServiceOptions, LaunchdHelper, NixNamespace, NixosHelper, NixosPlatformOpts, NixosProgramOptions, NixosServiceOptions, OverlayHelper, PkgHelper, PlatformsHelper, ScriptHelper, SysctlSettings, SystemdHelper, VirtualisationHelper, WindowsHelper, WindowsPlatformOpts, WinEnvNamespace, WinEnvOpts, WinEnvScope, WinFileEncoding, WinFileNamespace, WinFileOpts, WinPackageArg, WinPackageSpec, WinPathNamespace, WinRawCommandArg, WinRawCommandSpec, WinSettingOpts } from "./helpers/index.js";
|
|
12
|
+
export type { AccountGroupFactory, AccountGroupMember, AccountGroupOpts, AccountNamespace, AccountOpts, AccountUserFactory, AccountUserRef, ActivationOpts, BinaryReleaseArch, BinaryReleaseCompletions, BinaryReleaseFormat, BinaryReleaseMeta, BinaryReleaseOpts, BinaryReleasePlatform, DarwinHelper, DarwinPlatformOpts, DarwinProgramOptions, DarwinServiceOptions, HomeHelper, HomeProgramOptions, HomeServiceOptions, LaunchdHelper, NixNamespace, NixosHelper, NixosPlatformOpts, NixosProgramOptions, NixosServiceOptions, OverlayHelper, PkgHelper, PlatformsHelper, ScriptHelper, SysctlSettings, SystemdHelper, VirtualisationHelper, WindowsHelper, WindowsPlatformOpts, WinEnvNamespace, WinEnvOpts, WinEnvScope, WinFileEncoding, WinFileNamespace, WinFileOpts, WinPackageArg, WinPackageSpec, WinPathNamespace, WinRawCommandArg, WinRawCommandSpec, WinSettingOpts } from "./helpers/index.js";
|