File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ { pkgs ? import <nixpkgs> { } } :
2+
3+ let
4+ zigVersion = builtins . replaceStrings [ "\n " ] [ "" ] ( builtins . readFile ./.zigversion ) ;
5+
6+ # Determine platform-specific details
7+ platform = if pkgs . stdenv . isDarwin then "macos" else "linux" ;
8+ arch = if pkgs . stdenv . isAarch64 then "aarch64" else "x86_64" ;
9+
10+ # URL for the Zig binary
11+ zigUrl = "https://pkg.machengine.org/zig/zig-${ platform } -${ arch } -${ zigVersion } .tar.xz" ;
12+
13+ zigSrc = pkgs . fetchurl {
14+ url = zigUrl ;
15+ hash = "sha256-/vTDPMiyya8cr0ffmHhsa8BJ3XDsbAXHlKMnOyk3gBs=" ;
16+ } ;
17+
18+ zigVersionCompatibleWithMach = pkgs . stdenv . mkDerivation {
19+ pname = "zig" ;
20+ version = zigVersion ;
21+
22+ src = zigSrc ;
23+
24+ dontBuild = true ;
25+ dontConfigure = true ;
26+
27+ installPhase = ''
28+ mkdir -p $out/bin
29+ cp -r ./* $out/
30+ chmod +x $out/zig
31+ ln -s $out/zig $out/bin/zig
32+ '' ;
33+ } ;
34+
35+ in pkgs . mkShell {
36+ buildInputs = [
37+ pkgs . git
38+ zigVersionCompatibleWithMach
39+ ] ;
40+
41+ shellHook = ''
42+ echo "Zig ${ zigVersion } loaded"
43+ zig version
44+ '' ;
45+ }
You can’t perform that action at this time.
0 commit comments