Skip to content

Commit 2e9580b

Browse files
committed
This is working for the simple example on MacOS
1 parent 0049f03 commit 2e9580b

1 file changed

Lines changed: 45 additions & 0 deletions

File tree

shell.nix

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
}

0 commit comments

Comments
 (0)