-
-
Notifications
You must be signed in to change notification settings - Fork 54
/
flake.nix
91 lines (79 loc) · 2.71 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
{
description = ''
Pure and reproducible overlay for binary distributed rust toolchains.
A compatible but better replacement for rust overlay of github:mozilla/nixpkgs-mozilla.
'';
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
};
outputs = { self, nixpkgs }@inputs: let
inherit (nixpkgs) lib;
inherit (lib) filterAttrs mapAttrs' replaceStrings;
forEachSystem = lib.genAttrs lib.systems.flakeExposed;
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 (pkgs.rust) toRustTarget;
inherit (rust-bin) nightly;
manifests = mkManifests distRoot;
});
in {
lib = {
# Internal use only!
_internal = {
defaultManifests = mkManifests defaultDistRoot;
};
inherit mkRustBin;
};
overlays = {
default = overlay;
rust-overlay = overlay;
};
# 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);
};
}