2023-05-19 16:36:19 +03:00
|
|
|
{
|
2023-05-25 17:28:59 +03:00
|
|
|
inputs = {
|
2024-07-01 22:09:48 +03:00
|
|
|
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2405.*";
|
2024-07-02 00:48:46 +03:00
|
|
|
rust-overlay = {
|
|
|
|
url = "github:oxalica/rust-overlay";
|
2023-05-25 05:17:28 +03:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
|
|
|
crane = {
|
2024-07-02 00:48:46 +03:00
|
|
|
url = "https://flakehub.com/f/ipetkov/crane/0.17.*";
|
2023-05-25 05:17:28 +03:00
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2024-07-06 01:43:12 +03:00
|
|
|
flake-schemas.url = "https://flakehub.com/f/DeterminateSystems/flake-schemas/*";
|
2024-07-02 00:48:46 +03:00
|
|
|
flake-compat.url = "https://flakehub.com/f/edolstra/flake-compat/1.0.1";
|
2023-05-19 16:36:19 +03:00
|
|
|
};
|
|
|
|
|
2024-07-06 01:43:12 +03:00
|
|
|
outputs = { self, nixpkgs, rust-overlay, crane, flake-schemas, ... }:
|
2023-05-25 17:28:59 +03:00
|
|
|
let
|
2023-05-26 14:21:28 +03:00
|
|
|
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
|
|
|
|
forAllSystems = f: nixpkgs.lib.genAttrs supportedSystems (system: f rec {
|
2023-05-25 17:28:59 +03:00
|
|
|
pkgs = import nixpkgs {
|
|
|
|
inherit system;
|
2024-07-02 00:48:46 +03:00
|
|
|
overlays = [
|
|
|
|
rust-overlay.overlays.default
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
|
|
|
cranePkgs = pkgs.callPackage ./crane.nix {
|
|
|
|
inherit crane supportedSystems;
|
|
|
|
darwinFrameworks = with pkgs.darwin.apple_sdk.frameworks; [ Security SystemConfiguration ];
|
2023-05-25 17:28:59 +03:00
|
|
|
};
|
2023-05-26 14:21:28 +03:00
|
|
|
});
|
|
|
|
in
|
|
|
|
{
|
2024-07-06 01:43:12 +03:00
|
|
|
schemas = {
|
|
|
|
inherit (flake-schemas) devShells packages;
|
|
|
|
};
|
|
|
|
|
2024-07-02 00:48:46 +03:00
|
|
|
packages = forAllSystems ({ cranePkgs, ... }: rec {
|
|
|
|
inherit (cranePkgs) flake-checker;
|
2023-05-26 14:21:28 +03:00
|
|
|
default = flake-checker;
|
|
|
|
});
|
|
|
|
|
2024-07-02 00:48:46 +03:00
|
|
|
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";
|
2024-07-02 00:48:46 +03:00
|
|
|
runtimeInputs = [ cranePkgs.rustNightly ];
|
2023-05-26 15:27:27 +03:00
|
|
|
text = "cargo fmt --check";
|
|
|
|
};
|
2024-06-18 02:49:02 +03:00
|
|
|
get-allowed-refs = pkgs.writeShellApplication {
|
|
|
|
name = "get-allowed-refs";
|
2024-07-02 00:48:46 +03:00
|
|
|
runtimeInputs = [ cranePkgs.rustNightly ];
|
2024-06-18 02:49:02 +03:00
|
|
|
text = "cargo run --features allowed-refs -- --get-allowed-refs";
|
2023-08-28 09:39:17 +03:00
|
|
|
};
|
2023-05-26 15:27:27 +03:00
|
|
|
in
|
|
|
|
pkgs.mkShell {
|
|
|
|
packages = (with pkgs; [
|
|
|
|
bashInteractive
|
|
|
|
|
|
|
|
# Rust
|
2024-07-02 00:48:46 +03:00
|
|
|
cranePkgs.rustNightly
|
2023-05-26 15:27:27 +03:00
|
|
|
cargo-bloat
|
|
|
|
cargo-edit
|
2023-11-30 16:29:02 +03:00
|
|
|
cargo-machete
|
2024-07-02 00:48:46 +03:00
|
|
|
cargo-watch
|
2023-05-26 15:27:27 +03:00
|
|
|
rust-analyzer
|
|
|
|
|
|
|
|
# Nix
|
|
|
|
nixpkgs-fmt
|
|
|
|
|
|
|
|
# CI checks
|
|
|
|
check-nixpkgs-fmt
|
|
|
|
check-rustfmt
|
2023-08-28 09:39:17 +03:00
|
|
|
|
|
|
|
# Scripts
|
2024-06-18 02:49:02 +03:00
|
|
|
get-allowed-refs
|
2024-07-02 00:48:46 +03:00
|
|
|
]) ++ pkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [ Security SystemConfiguration ]);
|
2023-11-30 16:29:02 +03:00
|
|
|
|
2023-11-30 16:33:06 +03:00
|
|
|
env = {
|
|
|
|
# Required by rust-analyzer
|
2024-07-02 00:48:46 +03:00
|
|
|
RUST_SRC_PATH = "${cranePkgs.rustNightly}/lib/rustlib/src/rust/library";
|
2023-11-30 16:33:06 +03:00
|
|
|
};
|
|
|
|
};
|
2023-05-25 17:28:59 +03:00
|
|
|
});
|
2023-05-26 14:21:28 +03:00
|
|
|
};
|
2023-05-19 16:36:19 +03:00
|
|
|
}
|