flake-checker/flake.nix

97 lines
2.9 KiB
Nix
Raw Normal View History

2023-05-19 16:36:19 +03:00
{
inputs = {
2023-09-18 14:25:49 +03:00
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2305.*.tar.gz";
2023-05-25 05:17:28 +03:00
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
crane = {
2023-10-02 11:06:13 +03:00
url = "https://flakehub.com/f/ipetkov/crane/0.14.*.tar.gz";
2023-05-25 05:17:28 +03:00
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-compat.follows = "flake-compat";
inputs.flake-utils.follows = "flake-utils";
};
2023-10-10 23:12:51 +03:00
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.0.1.tar.gz";
2023-05-19 16:36:19 +03:00
};
outputs = { self, nixpkgs, flake-utils, rust-overlay, crane, ... }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f rec {
pkgs = import nixpkgs {
inherit system;
overlays = [
rust-overlay.overlays.default
];
};
2023-05-19 16:36:19 +03:00
cranePkgs = pkgs.callPackage ./crane.nix {
inherit crane supportedSystems;
2023-10-03 20:09:16 +03:00
darwinFrameworks = with pkgs.darwin.apple_sdk.frameworks; [ Security SystemConfiguration ];
};
});
in
{
packages = forAllSystems ({ cranePkgs, ... }: rec {
inherit (cranePkgs) flake-checker;
default = flake-checker;
});
devShells = forAllSystems ({ pkgs, cranePkgs }: {
2023-05-26 15:27:27 +03:00
default =
let
check-nixpkgs-fmt = pkgs.writeShellApplication {
name = "check-nixpkgs-fmt";
runtimeInputs = with pkgs; [ git nixpkgs-fmt ];
text = ''
git ls-files '*.nix' | xargs nixpkgs-fmt --check
'';
};
check-rustfmt = pkgs.writeShellApplication {
name = "check-rustfmt";
runtimeInputs = [ cranePkgs.rustNightly ];
text = "cargo fmt --check";
};
2023-08-28 09:39:17 +03:00
get-allowed-refs = pkgs.writeShellApplication {
name = "get-allowed-refs";
runtimeInputs = [ cranePkgs.rustNightly ];
text = "cargo run --features allowed-refs -- --get-allowed-refs";
};
2023-05-26 15:27:27 +03:00
in
pkgs.mkShell {
packages = (with pkgs; [
bashInteractive
# Rust
cranePkgs.rustNightly
cargo-bloat
cargo-edit
2023-11-30 16:29:02 +03:00
cargo-machete
2023-05-26 15:27:27 +03:00
cargo-watch
rust-analyzer
# Nix
nixpkgs-fmt
# CI checks
check-nixpkgs-fmt
check-rustfmt
2023-08-28 09:39:17 +03:00
# Scripts
get-allowed-refs
2023-11-30 16:29:02 +03:00
]) ++ pkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [ Security SystemConfiguration ]);
2023-11-30 16:33:06 +03:00
env = {
# Required by rust-analyzer
RUST_SRC_PATH = "${cranePkgs.rustNightly}/lib/rustlib/src/rust/library";
};
};
});
};
2023-05-19 16:36:19 +03:00
}