crane/flake.nix
2022-10-09 11:33:57 -10:00

94 lines
2.2 KiB
Nix

{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = inputs@{ self, nixpkgs, flake-utils, ... }:
let
mkLib = pkgs: import ./lib {
inherit (pkgs) lib newScope;
};
myPkgsFor = { pkgs, myLib }: import ./pkgs {
inherit pkgs myLib;
};
in
{
inherit mkLib;
overlays.default = final: prev: myPkgsFor {
pkgs = final;
myLib = mkLib final;
};
templates = rec {
alt-registry = {
description = "Build a cargo project with alternative crate registries";
path = ./examples/alt-registry;
};
cross-musl = {
description = "Building static binaries with musl";
path = ./examples/cross-musl;
};
cross-rust-overlay = {
description = "Cross compiling a rust program using rust-overlay";
path = ./examples/cross-rust-overlay;
};
custom-toolchain = {
description = "Build a cargo project with a custom toolchain";
path = ./examples/custom-toolchain;
};
default = quick-start;
quick-start = {
description = "Build a cargo project";
path = ./examples/quick-start;
};
quick-start-simple = {
description = "Build a cargo project without extra checks";
path = ./examples/quick-start-simple;
};
};
} // flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
# To override do: lib.overrideScope' (self: super: { ... });
lib = mkLib pkgs;
myPkgs = myPkgsFor {
inherit pkgs;
myLib = lib;
};
checks = pkgs.callPackages ./checks {
inherit pkgs myPkgs;
myLib = lib;
};
in
{
inherit checks lib;
packages = myPkgs;
devShells.default = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
jq
nixpkgs-fmt
];
};
});
}