mirror of
https://github.com/mitchellh/zig-overlay.git
synced 2025-05-08 18:46:02 +03:00
rewritten default.nix/flake.nix
This commit is contained in:
parent
1e89c6da81
commit
f0c4a8c91b
2 changed files with 31 additions and 15 deletions
39
default.nix
39
default.nix
|
@ -3,8 +3,10 @@
|
|||
|
||||
let
|
||||
inherit (pkgs) lib;
|
||||
releases = builtins.fromJSON (lib.strings.fileContents ./sources.json);
|
||||
mkDerivation = { url, version, sha256 }: pkgs.stdenv.mkDerivation {
|
||||
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;
|
||||
|
||||
pname = "zig";
|
||||
|
@ -20,13 +22,26 @@ let
|
|||
cp zig $out/bin/zig
|
||||
'';
|
||||
};
|
||||
in lib.attrsets.mapAttrs (k: v:
|
||||
if k == "master" then
|
||||
lib.attrsets.mapAttrs (k: v: (mkDerivation {
|
||||
inherit (v.${system}) version url sha256;
|
||||
})) v
|
||||
else
|
||||
mkDerivation {
|
||||
inherit (v.${system}) version url sha256;
|
||||
})
|
||||
releases
|
||||
|
||||
# This determines the latest /released/ version.
|
||||
latest = lib.lists.last (
|
||||
builtins.sort
|
||||
(x: y: (builtins.compareVersions x y) < 0)
|
||||
(builtins.filter (x: x != "master") (builtins.attrNames sources))
|
||||
);
|
||||
|
||||
# This is the full list of packages
|
||||
packages = lib.attrsets.mapAttrs (k: v:
|
||||
if k == "master" then
|
||||
lib.attrsets.mapAttrs (k: v: (mkBinaryInstall {
|
||||
inherit (v.${system}) version url sha256;
|
||||
})) v
|
||||
else
|
||||
mkBinaryInstall {
|
||||
inherit (v.${system}) version url sha256;
|
||||
})
|
||||
sources;
|
||||
in
|
||||
# We want the packages but also add a "default" that just points to the
|
||||
# latest released version.
|
||||
packages // { "default" = packages.${latest}; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue