Files
rust-overlay/flake.nix

99 lines
2.8 KiB
Nix
Raw Permalink Normal View History

2021-01-01 10:21:00 +08:00
{
description = ''
Pure and reproducible overlay for binary distributed rust toolchains.
2021-01-02 20:49:12 +08:00
A compatible but better replacement for rust overlay of github:mozilla/nixpkgs-mozilla.
2021-01-01 10:21:00 +08:00
'';
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
2021-01-01 10:21:00 +08:00
};
outputs =
{ self, nixpkgs }@inputs:
let
inherit (nixpkgs) lib;
inherit (lib) filterAttrs mapAttrs' replaceStrings;
2021-01-02 20:49:12 +08:00
forEachSystem = lib.genAttrs lib.systems.flakeExposed;
2021-01-01 10:21:00 +08:00
overlay = import ./.;
defaultDistRoot = import ./lib/dist-root.nix;
mkManifests = distRoot: import ./lib/manifests.nix { inherit lib distRoot; };
# Builder to construct `rust-bin` interface on an existing `pkgs`.
# This would be immutable, non-intrusive and (hopefully) can benefit from
# flake eval-cache.
#
# Note that this does not contain compatible attrs for mozilla-overlay.
mkRustBin =
{
distRoot ? defaultDistRoot,
}:
pkgs:
lib.fix (
rust-bin:
import ./lib/rust-bin.nix {
inherit lib pkgs;
inherit (rust-bin) nightly;
manifests = mkManifests distRoot;
}
);
in
{
lib = {
# Internal use only!
_internal = {
defaultManifests = mkManifests defaultDistRoot;
};
inherit mkRustBin;
};
overlays = {
default = overlay;
rust-overlay = overlay;
};
2021-08-05 21:22:13 +03:00
# TODO: Flake outputs except `overlay[s]` are not stabilized yet.
packages =
let
select =
version: comps:
if comps ? default then
comps.default
// {
minimal = comps.minimal or (throw "missing profile 'minimal' for ${version}");
}
else
null;
result =
rust-bin:
mapAttrs' (version: comps: {
name = if version == "latest" then "rust" else "rust_${replaceStrings [ "." ] [ "_" ] version}";
value = select version comps;
}) rust-bin.stable
// mapAttrs' (version: comps: {
name = if version == "latest" then "rust-nightly" else "rust-nightly_${version}";
value = select version comps;
}) rust-bin.nightly
// mapAttrs' (version: comps: {
name = if version == "latest" then "rust-beta" else "rust-beta_${version}";
value = select version comps;
}) rust-bin.beta;
result' = rust-bin: filterAttrs (name: drv: drv != null) (result rust-bin);
in
forEachSystem (
system:
result' (mkRustBin { } nixpkgs.legacyPackages.${system})
// {
default = self.packages.${system}.rust;
}
);
checks = forEachSystem (import ./tests inputs);
};
2021-01-01 10:21:00 +08:00
}