Initial commit
This commit is contained in:
commit
e483f73dd4
12 changed files with 479 additions and 0 deletions
77
crane.nix
Normal file
77
crane.nix
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
craneFlake:
|
||||
{ config, lib, flake-parts-lib, ... }:
|
||||
let
|
||||
inherit (lib) mkOption types mkIf mkDefault mkMerge;
|
||||
inherit (flake-parts-lib) mkPerSystemOption;
|
||||
cfg = config.rust.crane;
|
||||
mkTcDefault = lib.mkOverride 900;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
rust.crane = {
|
||||
lib = mkOption {
|
||||
type = types.anything;
|
||||
default = craneFlake.lib;
|
||||
};
|
||||
};
|
||||
|
||||
perSystem = mkPerSystemOption {
|
||||
_file = ./crane.nix;
|
||||
options = {
|
||||
rust.crane = {
|
||||
toolchain = mkOption {
|
||||
type = types.nullOr types.package;
|
||||
default = null;
|
||||
};
|
||||
|
||||
cargo = mkOption {
|
||||
type = types.package;
|
||||
};
|
||||
|
||||
clippy = mkOption {
|
||||
type = types.package;
|
||||
};
|
||||
|
||||
rustc = mkOption {
|
||||
type = types.package;
|
||||
};
|
||||
|
||||
rustfmt = mkOption {
|
||||
type = types.package;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
config.perSystem = psinputs@{ config, pkgs, system, inputs', ... }:
|
||||
let cfg' = config.rust.crane;
|
||||
in
|
||||
{
|
||||
config = mkMerge [
|
||||
{
|
||||
rust.crane.cargo = mkDefault pkgs.cargo;
|
||||
rust.crane.rustc = mkDefault pkgs.rustc;
|
||||
rust.crane.clippy = mkDefault pkgs.clippy;
|
||||
rust.crane.rustfmt = mkDefault pkgs.rustfmt;
|
||||
}
|
||||
|
||||
(mkIf (cfg'.toolchain != null) {
|
||||
rust.crane.cargo = mkTcDefault cfg'.toolchain;
|
||||
rust.crane.rustc = mkTcDefault cfg'.toolchain;
|
||||
rust.crane.clippy = mkTcDefault cfg'.toolchain;
|
||||
rust.crane.rustfmt = mkTcDefault cfg'.toolchain;
|
||||
})
|
||||
|
||||
{
|
||||
_module.args.craneLib = cfg.lib.${system}.overrideScope (_self: _super: {
|
||||
cargo = cfg'.cargo;
|
||||
clippy = cfg'.clippy;
|
||||
rustc = cfg'.rustc;
|
||||
rustfmt = cfg'.rustfmt;
|
||||
});
|
||||
}
|
||||
];
|
||||
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue