Nix packages for third-party projects that don't ship their own flakes
0

Configure Feed

Select the types of activity you want to include in your feed.

Add zed-preview package (official x86_64 Linux binaries)

Package the Zed preview channel from GitHub release tarballs, expose it on
x86_64-linux only, and teach the weekly updater about github-release-binary.

+285 -19
+40
README.md
··· 29 29 | `vit` | [solpbc/vit](https://github.com/solpbc/vit) | `npm install -g vit` | 30 30 | `rook` | [solpbc/rook](https://github.com/solpbc/rook) | `npm install -g @solpbc/rook` | 31 31 | `spinel` | [matz/spinel](https://github.com/matz/spinel) | build from source (`make deps && make && make install`) | 32 + | `zed-preview` | [zed-industries/zed](https://github.com/zed-industries/zed) (preview channel) | [official Linux installer](https://zed.dev/docs/linux) / `zed-linux-x86_64.tar.gz` | 32 33 33 34 ## Usage 34 35 ··· 37 38 nix build .#vit 38 39 nix build .#rook 39 40 nix build .#spinel 41 + nix build .#zed-preview # x86_64-linux only 40 42 41 43 # run without installing 42 44 nix run .#vit -- --help 43 45 nix run .#rook -- --help 44 46 nix run .#spinel -- --help 45 47 nix run .#spin -- new myapp # spin project tool (from the spinel package) 48 + nix run .#zed-preview -- --version 46 49 47 50 # install into your profile 48 51 nix profile install .#vit 49 52 nix profile install .#rook 50 53 nix profile install .#spinel 54 + nix profile install .#zed-preview 51 55 ``` 52 56 53 57 ## Updating packages ··· 101 105 Versions are `0-unstable-YYYY-MM-DD` with a pinned `rev` in `fetchFromGitHub`. 102 106 For spinel, the updater also re-reads `PRISM_VERSION` / `RBS_VERSION` from the 103 107 upstream Makefile and refreshes the vendored gem hashes when they change. 108 + 109 + **github-release-binary** — prebuilt release assets (no source build): 110 + 111 + ```json 112 + { 113 + "type": "github-release-binary", 114 + "github": "owner/repo", 115 + "tag_prefix": "v", 116 + "tag_suffix": "-pre", 117 + "asset": "zed-linux-x86_64.tar.gz" 118 + } 119 + ``` 120 + 121 + Tracks the newest non-draft GitHub release whose tag matches 122 + `{tag_prefix}{semver}{tag_suffix}` and refreshes the `fetchurl` hash for 123 + `asset`. Used by `zed-preview` (x86_64-linux only). 104 124 105 125 ### Manual steps (vit / rook) 106 126 ··· 147 167 nix hash convert --hash-algo sha256 --to sri <base32> 148 168 ``` 149 169 3. `nix build .#spinel` and smoke-test `./result/bin/spinel -e 'puts 1'`. 170 + 171 + ### Manual steps (zed-preview) 172 + 173 + `zed-preview` ships official Linux x86_64 preview binaries (tags `vX.Y.Z-pre`). 174 + Prefer the updater: 175 + 176 + ```bash 177 + ./scripts/update-packages.sh zed-preview 178 + ``` 179 + 180 + By hand: 181 + 182 + 1. Bump `version` in `packages/zed-preview/default.nix` (e.g. `1.12.0-pre`). 183 + 2. Prefetch the tarball hash: 184 + ```bash 185 + nix-prefetch-url "https://github.com/zed-industries/zed/releases/download/vX.Y.Z-pre/zed-linux-x86_64.tar.gz" 186 + nix hash convert --hash-algo sha256 --to sri <base32> 187 + ``` 188 + 3. Paste the SRI hash into `fetchurl.hash`, then `nix build .#zed-preview` and 189 + smoke-test `./result/bin/zed-preview --version`.
+32 -19
flake.nix
··· 28 28 rook = pkgs.callPackage ./packages/rook { }; 29 29 default = self.packages.${system}.vit; 30 30 } 31 + // pkgs.lib.optionalAttrs (system == "x86_64-linux") { 32 + # Official preview tarball is only fetched for x86_64-linux. 33 + zed-preview = pkgs.callPackage ./packages/zed-preview { }; 34 + } 31 35 ); 32 36 33 37 # Convenience: `nix run .#vit -- --help`, `nix run .#spinel -- --help` 34 - apps = forAllSystems (system: { 35 - vit = { 36 - type = "app"; 37 - program = "${self.packages.${system}.vit}/bin/vit"; 38 - }; 39 - spinel = { 40 - type = "app"; 41 - program = "${self.packages.${system}.spinel}/bin/spinel"; 42 - }; 43 - spin = { 44 - type = "app"; 45 - program = "${self.packages.${system}.spinel}/bin/spin"; 46 - }; 47 - rook = { 48 - type = "app"; 49 - program = "${self.packages.${system}.rook}/bin/rook"; 50 - }; 51 - default = self.apps.${system}.vit; 52 - }); 38 + apps = forAllSystems ( 39 + system: 40 + { 41 + vit = { 42 + type = "app"; 43 + program = "${self.packages.${system}.vit}/bin/vit"; 44 + }; 45 + spinel = { 46 + type = "app"; 47 + program = "${self.packages.${system}.spinel}/bin/spinel"; 48 + }; 49 + spin = { 50 + type = "app"; 51 + program = "${self.packages.${system}.spinel}/bin/spin"; 52 + }; 53 + rook = { 54 + type = "app"; 55 + program = "${self.packages.${system}.rook}/bin/rook"; 56 + }; 57 + default = self.apps.${system}.vit; 58 + } 59 + // nixpkgs.lib.optionalAttrs (system == "x86_64-linux") { 60 + zed-preview = { 61 + type = "app"; 62 + program = "${self.packages.${system}.zed-preview}/bin/zed-preview"; 63 + }; 64 + } 65 + ); 53 66 }; 54 67 }
+88
packages/zed-preview/default.nix
··· 1 + { 2 + lib, 3 + stdenv, 4 + fetchurl, 5 + autoPatchelfHook, 6 + makeWrapper, 7 + alsa-lib, 8 + libGL, 9 + libgcc, 10 + vulkan-loader, 11 + wayland, 12 + versionCheckHook, 13 + }: 14 + 15 + stdenv.mkDerivation (finalAttrs: { 16 + pname = "zed-preview"; 17 + # Official preview channel tags are vX.Y.Z-pre (prerelease on GitHub). 18 + version = "1.12.0-pre"; 19 + 20 + src = fetchurl { 21 + url = "https://github.com/zed-industries/zed/releases/download/v${finalAttrs.version}/zed-linux-x86_64.tar.gz"; 22 + hash = "sha256-KqqXibrYxLzt+HInAJla86wbqgVlDE4PKLha6BOflgc="; 23 + }; 24 + 25 + sourceRoot = "zed-preview.app"; 26 + 27 + nativeBuildInputs = [ 28 + autoPatchelfHook 29 + makeWrapper 30 + ]; 31 + 32 + buildInputs = [ 33 + alsa-lib 34 + libgcc 35 + ]; 36 + 37 + # Bundled $ORIGIN/../lib covers most deps; these are either NEEDED (alsa) or 38 + # commonly dlopened at runtime (GPU / Wayland). 39 + runtimeDependencies = [ 40 + alsa-lib 41 + libGL 42 + vulkan-loader 43 + wayland 44 + ]; 45 + 46 + installPhase = '' 47 + runHook preInstall 48 + 49 + mkdir -p $out 50 + cp -a bin lib libexec share $out/ 51 + # Coexist with nixpkgs zed-editor (zeditor) and a stable zed binary. 52 + mv $out/bin/zed $out/bin/zed-preview 53 + 54 + # Point the desktop entry at our binary name (line-anchored; plain 55 + # substitute would also rewrite TryExec when matching Exec=zed). 56 + sed -i \ 57 + -e 's/^TryExec=zed$/TryExec=zed-preview/' \ 58 + -e 's/^Exec=zed/Exec=zed-preview/' \ 59 + $out/share/applications/dev.zed.Zed-Preview.desktop 60 + 61 + runHook postInstall 62 + ''; 63 + 64 + postFixup = '' 65 + wrapProgram $out/bin/zed-preview \ 66 + --set ZED_UPDATE_EXPLANATION "Zed Preview has been installed using Nix. Auto-updates have thus been disabled." 67 + ''; 68 + 69 + nativeInstallCheckInputs = [ versionCheckHook ]; 70 + versionCheckProgram = "${placeholder "out"}/bin/zed-preview"; 71 + versionCheckProgramArg = "--version"; 72 + # Upstream prints "Zed preview 1.12.0 <sha> …" (no -pre suffix). 73 + preInstallCheck = '' 74 + export version="${lib.removeSuffix "-pre" finalAttrs.version}" 75 + ''; 76 + doInstallCheck = true; 77 + 78 + meta = { 79 + description = "High-performance, multiplayer code editor (official Linux preview binaries)"; 80 + homepage = "https://zed.dev"; 81 + changelog = "https://github.com/zed-industries/zed/releases/tag/v${finalAttrs.version}"; 82 + # AGPL for the editor; some bundled components differ — see licenses.md in the tarball. 83 + license = lib.licenses.gpl3Only; 84 + mainProgram = "zed-preview"; 85 + platforms = [ "x86_64-linux" ]; 86 + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; 87 + }; 88 + })
+8
packages/zed-preview/upstream.json
··· 1 + { 2 + "type": "github-release-binary", 3 + "github": "zed-industries/zed", 4 + "tag_prefix": "v", 5 + "tag_suffix": "-pre", 6 + "asset": "zed-linux-x86_64.tar.gz", 7 + "description": "Official Linux x86_64 preview tarball. Tracks latest vX.Y.Z-pre GitHub release." 8 + }
+117
scripts/update-packages.sh
··· 411 411 log "${name}: updated successfully to ${latest}" 412 412 } 413 413 414 + latest_github_tag_with_suffix() { 415 + # latest_github_tag_with_suffix <owner/repo> <prefix> <suffix> 416 + # e.g. prefix=v suffix=-pre => matches v1.12.0-pre, prints 1.12.0-pre 417 + local repo="$1" prefix="$2" suffix="$3" 418 + local url="https://api.github.com/repos/${repo}/releases?per_page=30" 419 + local args=(-fsSL) 420 + if [[ -n "${GITHUB_TOKEN:-}" ]]; then 421 + args+=(-H "Authorization: Bearer ${GITHUB_TOKEN}") 422 + fi 423 + curl "${args[@]}" "$url" | python3 -c ' 424 + import json, re, sys 425 + prefix, suffix = sys.argv[1], sys.argv[2] 426 + releases = json.load(sys.stdin) 427 + pat = re.compile( 428 + r"^" + re.escape(prefix) + r"(\d+\.\d+\.\d+)" + re.escape(suffix) + r"$" 429 + ) 430 + versions = [] 431 + for r in releases: 432 + if r.get("draft"): 433 + continue 434 + name = r.get("tag_name") or "" 435 + m = pat.match(name) 436 + if m: 437 + versions.append(m.group(1) + suffix) 438 + if not versions: 439 + sys.exit("no matching release tags for prefix=%r suffix=%r" % (prefix, suffix)) 440 + def key(v): 441 + core = re.split(r"[+-]", v, maxsplit=1)[0] 442 + return [int(x) for x in core.split(".")] 443 + versions.sort(key=key) 444 + print(versions[-1]) 445 + ' "$prefix" "$suffix" 446 + } 447 + 448 + set_fetchurl_hash() { 449 + # set_fetchurl_hash <file> <value> 450 + # Replaces hash = "..." inside the first fetchurl { ... } block. 451 + local file="$1" value="$2" 452 + python3 -c ' 453 + import re, sys 454 + path, value = sys.argv[1], sys.argv[2] 455 + text = open(path).read() 456 + pat = re.compile( 457 + r"(fetchurl\s*\{[^}]*?hash\s*=\s*\")([^\"]+)(\")", 458 + re.S, 459 + ) 460 + new, n = pat.subn(rf"\g<1>{value}\g<3>", text, count=1) 461 + if n != 1: 462 + sys.exit(f"failed to set fetchurl.hash in {path} (matches={n})") 463 + open(path, "w").write(new) 464 + ' "$file" "$value" 465 + } 466 + 467 + update_github_release_binary() { 468 + # Official prebuilt release assets (e.g. zed-preview Linux tarball). 469 + # version in default.nix is the tag without the leading "v" (e.g. 1.12.0-pre). 470 + local name="$1" 471 + local pkg_dir="$ROOT/packages/${name}" 472 + local default_nix="$pkg_dir/default.nix" 473 + local upstream="$pkg_dir/upstream.json" 474 + local repo tag_prefix tag_suffix asset 475 + repo="$(read_field "$upstream" github)" 476 + tag_prefix="$(read_field "$upstream" tag_prefix)" 477 + tag_suffix="$(read_field "$upstream" tag_suffix)" 478 + asset="$(read_field "$upstream" asset)" 479 + [[ -n "$repo" ]] || die "${name}: upstream.json missing github" 480 + [[ -n "$asset" ]] || die "${name}: upstream.json missing asset" 481 + tag_prefix="${tag_prefix:-v}" 482 + tag_suffix="${tag_suffix:-}" 483 + 484 + local cur latest 485 + cur="$(current_version "$default_nix")" 486 + log "${name}: current=${cur}" 487 + latest="$(latest_github_tag_with_suffix "$repo" "$tag_prefix" "$tag_suffix")" 488 + log "${name}: latest upstream=${latest}" 489 + 490 + if [[ "$latest" == "$cur" ]]; then 491 + log "${name}: already up to date" 492 + return 0 493 + fi 494 + 495 + # Semver compare on the numeric core (ignore -pre etc.) 496 + local cur_core latest_core 497 + cur_core="${cur%%-*}"; cur_core="${cur_core%%+*}" 498 + latest_core="${latest%%-*}"; latest_core="${latest_core%%+*}" 499 + if ! version_gt "$latest_core" "$cur_core" && [[ "$latest" != "$cur" ]]; then 500 + # Same core version but different suffix, or non-monotonic tag: still update 501 + # when the full tag string differs (handled above). If latest core is older, 502 + # skip to avoid downgrades. 503 + if ! version_gt "$latest_core" "$cur_core" && [[ "$latest_core" != "$cur_core" ]]; then 504 + log "${name}: latest core ${latest_core} is not newer than ${cur_core}; skipping" 505 + return 0 506 + fi 507 + fi 508 + 509 + if [[ "$CHECK_ONLY" -eq 1 ]]; then 510 + log "${name}: OUTDATED (${cur} -> ${latest})" 511 + return 10 512 + fi 513 + 514 + log "${name}: updating ${cur} -> ${latest}" 515 + set_field_string "$default_nix" version "$latest" 516 + 517 + local src_url src_hash 518 + src_url="https://github.com/${repo}/releases/download/${tag_prefix}${latest}/${asset}" 519 + log "${name}: prefetching ${src_url}" 520 + src_hash="$(sri_from_url_file "$src_url")" 521 + set_fetchurl_hash "$default_nix" "$src_hash" 522 + log "${name}: src hash ${src_hash}" 523 + 524 + verify_build "$name" 525 + log "${name}: updated successfully to ${latest}" 526 + } 527 + 414 528 update_github_unstable() { 415 529 # Track tip of a branch for projects without release tags. 416 530 # version format: 0-unstable-YYYY-MM-DD ··· 477 591 ;; 478 592 github-unstable) 479 593 update_github_unstable "$name" || status=$? 594 + ;; 595 + github-release-binary) 596 + update_github_release_binary "$name" || status=$? 480 597 ;; 481 598 *) 482 599 die "${name}: unsupported upstream type '${type}'"