mirror of
https://github.com/mitchellh/zig-overlay.git
synced 2025-05-08 18:46:02 +03:00
nix fmt and support aarch64-darwin
This commit is contained in:
parent
941ed4d57e
commit
c4a460a991
2 changed files with 77 additions and 55 deletions
72
default.nix
72
default.nix
|
@ -1,50 +1,64 @@
|
|||
{ pkgs ? import <nixpkgs> {},
|
||||
system ? builtins.currentSystem }:
|
||||
|
||||
let
|
||||
{
|
||||
pkgs ? import <nixpkgs> {},
|
||||
system ? builtins.currentSystem,
|
||||
}: let
|
||||
inherit (pkgs) lib;
|
||||
sources = builtins.fromJSON (lib.strings.fileContents ./sources.json);
|
||||
|
||||
# mkBinaryInstall makes a derivation that installs Zig from a binary.
|
||||
mkBinaryInstall = { url, version, sha256 }: pkgs.stdenv.mkDerivation {
|
||||
inherit version;
|
||||
mkBinaryInstall = {
|
||||
url,
|
||||
version,
|
||||
sha256,
|
||||
}:
|
||||
pkgs.stdenv.mkDerivation {
|
||||
inherit version;
|
||||
|
||||
pname = "zig";
|
||||
src = pkgs.fetchurl { inherit url sha256; };
|
||||
dontConfigure = true;
|
||||
dontBuild = true;
|
||||
dontFixup = true;
|
||||
installPhase = ''
|
||||
mkdir -p $out/{doc,bin,lib}
|
||||
[ -d docs ] && cp -r docs/* $out/doc
|
||||
[ -d doc ] && cp -r doc/* $out/doc
|
||||
cp -r lib/* $out/lib
|
||||
cp zig $out/bin/zig
|
||||
'';
|
||||
};
|
||||
pname = "zig";
|
||||
src = pkgs.fetchurl {inherit url sha256;};
|
||||
dontConfigure = true;
|
||||
dontBuild = true;
|
||||
dontFixup = true;
|
||||
installPhase = ''
|
||||
mkdir -p $out/{doc,bin,lib}
|
||||
[ -d docs ] && cp -r docs/* $out/doc
|
||||
[ -d doc ] && cp -r doc/* $out/doc
|
||||
cp -r lib/* $out/lib
|
||||
cp zig $out/bin/zig
|
||||
'';
|
||||
};
|
||||
|
||||
# The packages that are tagged releases
|
||||
taggedPackages = lib.attrsets.mapAttrs
|
||||
(k: v: mkBinaryInstall { inherit (v.${system}) version url sha256; })
|
||||
taggedPackages =
|
||||
lib.attrsets.mapAttrs
|
||||
(k: v: mkBinaryInstall {inherit (v.${system}) version url sha256;})
|
||||
(lib.attrsets.filterAttrs
|
||||
(k: v: (builtins.hasAttr system v) && (v.${system}.url != null))
|
||||
(builtins.removeAttrs sources ["master"]));
|
||||
|
||||
# The master packages
|
||||
masterPackages = lib.attrsets.mapAttrs'
|
||||
(k: v: lib.attrsets.nameValuePair
|
||||
(if k == "latest" then "master" else ("master-" + k))
|
||||
(mkBinaryInstall { inherit (v.${system}) version url sha256; })
|
||||
masterPackages =
|
||||
lib.attrsets.mapAttrs' (
|
||||
k: v:
|
||||
lib.attrsets.nameValuePair
|
||||
(
|
||||
if k == "latest"
|
||||
then "master"
|
||||
else ("master-" + k)
|
||||
)
|
||||
(mkBinaryInstall {inherit (v.${system}) version url sha256;})
|
||||
)
|
||||
sources.master;
|
||||
(lib.attrsets.filterAttrs
|
||||
(k: v: (builtins.hasAttr system v) && (v.${system}.url != null))
|
||||
sources.master);
|
||||
|
||||
# This determines the latest /released/ version.
|
||||
latest = lib.lists.last (
|
||||
builtins.sort
|
||||
(x: y: (builtins.compareVersions x y) < 0)
|
||||
(builtins.attrNames taggedPackages)
|
||||
(x: y: (builtins.compareVersions x y) < 0)
|
||||
(builtins.attrNames taggedPackages)
|
||||
);
|
||||
in
|
||||
# We want the packages but also add a "default" that just points to the
|
||||
# latest released version.
|
||||
taggedPackages // masterPackages // { "default" = taggedPackages.${latest}; }
|
||||
taggedPackages // masterPackages // {"default" = taggedPackages.${latest};}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue