li7y/flake.nix

106 lines
2.7 KiB
Nix

# SPDX-FileCopyrightText: 2024 Simon Bruder <simon@sbruder.de>
#
# SPDX-License-Identifier: AGPL-3.0-or-later
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
rust-overlay.url = "github:oxalica/rust-overlay";
naersk.url = "github:nix-community/naersk";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
pre-commit-hooks.inputs.flake-utils.follows = "flake-utils";
pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, flake-utils, nixpkgs, rust-overlay, naersk, pre-commit-hooks }: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
rustPackage = pkgs.rust-bin.stable.latest.default;
rustPackageNightly = pkgs.rust-bin.nightly.latest.default;
rustPackageDev = rustPackageNightly;
naersk' = pkgs.callPackage naersk {
rustc = rustPackage;
cargo = rustPackage;
};
in
{
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = self;
hooks = {
cargo-check = {
enable = true;
package = rustPackageDev;
};
cargo-deny = {
enable = true;
name = "cargo-deny";
entry = "cargo deny check";
pass_filenames = false;
};
clippy = {
enable = true;
packageOverrides = {
cargo = rustPackageDev;
clippy = rustPackageDev;
};
};
nixpkgs-fmt.enable = true;
reuse = {
enable = true;
name = "reuse";
entry = "reuse lint";
pass_filenames = false;
};
rustfmt = {
enable = true;
packageOverrides = {
cargo = rustPackageDev;
rustfmt = rustPackageDev;
};
};
};
};
};
packages = rec {
li7y = naersk'.buildPackage {
src = self;
buildInputs = with pkgs; [
postgresql.lib
];
};
default = li7y;
};
devShells.default = pkgs.mkShell {
buildInputs = [
rustPackageDev
] ++ (with pkgs; [
cargo-deny
cargo-watch
clippy
diesel-cli
postgresql.lib
postgresql
reuse
]);
shellHook = ''
${self.checks.${system}.pre-commit-check.shellHook}
'';
};
});
}