mirror of
https://github.com/mitchellh/zig-overlay.git
synced 2025-02-05 17:02:48 +02:00
rewritten default.nix/flake.nix
This commit is contained in:
parent
1e89c6da81
commit
f0c4a8c91b
2 changed files with 31 additions and 15 deletions
27
default.nix
27
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:
|
||||
|
||||
# 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: (mkDerivation {
|
||||
lib.attrsets.mapAttrs (k: v: (mkBinaryInstall {
|
||||
inherit (v.${system}) version url sha256;
|
||||
})) v
|
||||
else
|
||||
mkDerivation {
|
||||
mkBinaryInstall {
|
||||
inherit (v.${system}) version url sha256;
|
||||
})
|
||||
releases
|
||||
sources;
|
||||
in
|
||||
# We want the packages but also add a "default" that just points to the
|
||||
# latest released version.
|
||||
packages // { "default" = packages.${latest}; }
|
||||
|
|
|
@ -14,8 +14,9 @@
|
|||
let pkgs = nixpkgs.legacyPackages.${system};
|
||||
in rec {
|
||||
packages = import ./default.nix { inherit system pkgs; };
|
||||
defaultPackage = packages."0.9.1";
|
||||
apps.zig = flake-utils.lib.mkApp { drv = defaultPackage; };
|
||||
defaultApp = apps.zig;
|
||||
apps = rec {
|
||||
default = apps.zig;
|
||||
zig = flake-utils.lib.mkApp { drv = packages.default; };
|
||||
};
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue