crane/flake.nix

76 lines
1.8 KiB
Nix
Raw Normal View History

2021-12-26 22:47:16 +03:00
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
2021-12-30 03:03:39 +03:00
nix-std.url = "github:chessai/nix-std";
2021-12-26 22:47:16 +03:00
utils = {
url = "github:numtide/flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
};
2021-12-30 03:03:39 +03:00
outputs = inputs@{ self, nixpkgs, nix-std, utils, ... }:
2021-12-26 22:47:16 +03:00
let
2021-12-27 02:32:57 +03:00
myPkgsFor = pkgs: pkgs.callPackages ./pkgs { };
2022-01-16 07:21:02 +03:00
mkLib = pkgs: import ./lib {
inherit (nix-std.lib.serde) fromTOML toTOML;
inherit (pkgs) lib newScope;
myPkgs = myPkgsFor pkgs;
};
2021-12-26 22:47:16 +03:00
in
{
2022-01-16 07:21:02 +03:00
inherit mkLib;
2021-12-27 02:32:57 +03:00
overlay = final: prev: myPkgsFor final;
2022-01-17 01:25:41 +03:00
defaultTemplate = self.templates.quick-start;
templates = {
custom-toolchain = {
description = "Build a cargo project with a custom toolchain";
path = ./examples/custom-toolchain;
};
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;
};
};
2021-12-27 02:32:57 +03:00
} // utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
};
myPkgs = myPkgsFor pkgs;
# To override do: lib.overrideScope' (self: super: { ... });
2022-01-16 07:21:02 +03:00
lib = mkLib pkgs;
2021-12-27 02:32:57 +03:00
2021-12-30 06:26:55 +03:00
checks = pkgs.callPackages ./checks {
inherit pkgs;
2021-12-30 06:26:55 +03:00
myLib = lib;
};
2021-12-27 02:32:57 +03:00
in
{
inherit checks lib;
packages = myPkgs;
2021-12-26 22:47:16 +03:00
2021-12-27 02:32:57 +03:00
devShell = pkgs.mkShell {
nativeBuildInputs = with pkgs; [
nixpkgs-fmt
];
2021-12-27 02:32:57 +03:00
};
});
2021-12-26 22:47:16 +03:00
}