Initial commit
This commit is contained in:
commit
e483f73dd4
12 changed files with 479 additions and 0 deletions
67
fenix.nix
Normal file
67
fenix.nix
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
fenixFlake:
|
||||
{ config, inputs, lib, flake-parts-lib, ... }:
|
||||
with builtins;
|
||||
let
|
||||
inherit (lib) mkDefault mkOption types;
|
||||
inherit (flake-parts-lib) mkPerSystemOption;
|
||||
cfg = config.rust.fenix;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
rust.fenix = {
|
||||
manifestFile = mkOption {
|
||||
type = types.path;
|
||||
};
|
||||
|
||||
channel = mkOption {
|
||||
type = types.str;
|
||||
default = "stable";
|
||||
};
|
||||
|
||||
components = mkOption {
|
||||
type = types.listOf types.str;
|
||||
};
|
||||
|
||||
targetComponents = mkOption {
|
||||
type = types.attrsOf (types.listOf types.str);
|
||||
};
|
||||
};
|
||||
|
||||
perSystem = mkPerSystemOption {
|
||||
_file = ./fenix.nix;
|
||||
options = {
|
||||
rust.fenix.toolchain = mkOption {
|
||||
type = types.package;
|
||||
readOnly = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config.rust.fenix = {
|
||||
components = [
|
||||
"cargo"
|
||||
"rustc"
|
||||
];
|
||||
};
|
||||
|
||||
config.perSystem = { pkgs, system, inputs', ... }: {
|
||||
_module.args.fenixToolchain =
|
||||
let
|
||||
fenix = fenixFlake.packages.${system};
|
||||
|
||||
inherit (fenix) combine;
|
||||
|
||||
nativeToolchain = fenix.fromManifestFile cfg.manifestFile;
|
||||
targetToolchain = t: fenix.targets.${t}.fromManifestFile cfg.manifestFile;
|
||||
|
||||
component = tc: c: getAttr c tc;
|
||||
components = tc: cs: map (component tc) cs;
|
||||
nativeComponents = components nativeToolchain cfg.components;
|
||||
targetComponents = concatMap
|
||||
(t: components (targetToolchain t) cfg.targetComponents.${t})
|
||||
(attrNames cfg.targetComponents);
|
||||
in
|
||||
combine (nativeComponents ++ targetComponents);
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue