-
Notifications
You must be signed in to change notification settings - Fork 3
/
flake.nix
89 lines (81 loc) · 2.7 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
{
inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.2405.*";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
crane = {
url = "https://flakehub.com/f/ipetkov/crane/0.17.*";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, ... }@inputs:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forAllSystems = f: inputs.nixpkgs.lib.genAttrs supportedSystems (system: f rec {
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
inputs.rust-overlay.overlays.default
];
};
cranePkgs = pkgs.callPackage ./crane.nix {
inherit (inputs) crane;
inherit supportedSystems;
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 }: {
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";
};
get-allowed-refs = pkgs.writeShellApplication {
name = "get-allowed-refs";
runtimeInputs = [ cranePkgs.rustNightly ];
text = "cargo run --features allowed-refs -- --get-allowed-refs";
};
in
pkgs.mkShell {
packages = (with pkgs; [
bashInteractive
# Rust
cranePkgs.rustNightly
cargo-bloat
cargo-edit
cargo-machete
cargo-watch
rust-analyzer
# Nix
nixpkgs-fmt
# CI checks
check-nixpkgs-fmt
check-rustfmt
# Scripts
get-allowed-refs
]) ++ pkgs.lib.optionals pkgs.stdenv.isDarwin (with pkgs.darwin.apple_sdk.frameworks; [ Security SystemConfiguration ]);
env = {
# Required by rust-analyzer
RUST_SRC_PATH = "${cranePkgs.rustNightly}/lib/rustlib/src/rust/library";
};
};
});
};
}