Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,30 @@
}: let
inherit (pkgs) lib;
sources = builtins.fromJSON (lib.strings.fileContents ./sources.json);
mirrors = builtins.fromJSON (lib.strings.fileContents ./mirrors.json);

# mkBinaryInstall makes a derivation that installs Zig from a binary.
mkBinaryInstall = {
url,
version,
sha256,
}:
}: let
tarballName = lib.lists.last (lib.strings.split "/" url);
srcIsFromZigLang = lib.strings.hasPrefix "https://ziglang.org/" url;
urlFromMirrors =
builtins.map
(mirror: "${mirror}/${tarballName}?source=nix-zig-overlay")
mirrors;
urls =
if srcIsFromZigLang
then urlFromMirrors ++ [url]
else [url];
in
pkgs.stdenv.mkDerivation {
inherit version;

pname = "zig";
src = pkgs.fetchurl {inherit url sha256;};
src = pkgs.fetchurl {inherit urls sha256;};
dontConfigure = true;
dontBuild = true;
dontFixup = true;
Expand Down
9 changes: 9 additions & 0 deletions mirrors.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
[
"https://pkg.machengine.org/zig",
"https://zigmirror.hryx.net/zig",
"https://zig.linus.dev/zig",
"https://zig.squirl.dev",
"https://zig.florent.dev",
"https://zig.mirror.mschae23.de/zig",
"https://zigmirror.meox.dev"
]
2 changes: 2 additions & 0 deletions update
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#! nix-shell -p curl jq minisign -i sh
set -e

curl -s 'https://ziglang.org/download/community-mirrors.txt' | jq -R '.' | jq -s . > mirrors.json

# The well known public key for Zig
PUBLIC_KEY="RWSGOq2NVecA2UPNdBUZykf1CCb147pkmdtYxgb3Ti+JO/wCYvhbAb/U"

Expand Down